/* ==========================================================================
   LA YUNTA - MONITOR DE VENTAS NAPSE BRIDGE
   Harmonious Unified Dark Theme (Sleek Obsidian & Slate with Refined Red Accents)
   ========================================================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: #0b0f19;
    background-image: radial-gradient(circle at 50% 0%, #171e31 0%, #0b0f19 80%);
    color: #f8fafc;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* --------------------------------------------------------------------------
   LOGIN SCREEN
   -------------------------------------------------------------------------- */
.login-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at center, #1e293b 0%, #0b0f19 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

.login-card {
    background: #131c2e !important;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 42px 38px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
    text-align: center;
    color: #f8fafc !important;
}

.login-header {
    margin-bottom: 26px;
}

.brand-logo-img {
    height: 64px;
    object-fit: contain;
    margin-bottom: 14px;
}

.login-header h2 {
    font-size: 24px;
    font-weight: 800;
    color: #f8fafc !important;
    letter-spacing: -0.5px;
}

.login-header p {
    font-size: 13px;
    color: #94a3b8 !important;
    margin-top: 6px;
}

.form-group {
    text-align: left;
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #94a3b8 !important;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input {
    width: 100%;
    padding: 13px 16px;
    background: #0b0f19 !important;
    border: 1px solid #1e293b !important;
    border-radius: 10px;
    color: #f8fafc !important;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

.form-group input:focus {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
    background: #101726 !important;
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%) !important;
    color: #ffffff !important;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
    box-shadow: 0 4px 16px rgba(220, 38, 38, 0.35);
    transition: all 0.2s ease;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(220, 38, 38, 0.45);
}

.btn-login:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* --------------------------------------------------------------------------
   NAVBAR
   -------------------------------------------------------------------------- */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.navbar {
    background: #0d1322;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 14px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.nav-top-row {
    display: flex;
    align-items: center;
    gap: 24px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.nav-logo {
    height: 44px;
    object-fit: contain;
}

.brand-text h1 {
    font-size: 19px;
    font-weight: 900;
    color: #ffffff;
    letter-spacing: 0.5px;
    line-height: 1.1;
}

.brand-text p {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 2px;
}

.navbar-status {
    display: flex;
    align-items: center;
    gap: 10px;
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-info {
    background: #172136;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 7px 14px;
    color: #ffffff;
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.session-timer {
    background: rgba(220, 38, 38, 0.15);
    border: 1px solid rgba(220, 38, 38, 0.3);
    border-radius: 20px;
    padding: 7px 14px;
    color: #f87171;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-excel {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    font-weight: 700;
    font-size: 13px;
    border-radius: 10px;
    padding: 9px 16px;
    border: none;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
    transition: all 0.2s ease;
}

.btn-excel:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.35);
}

.btn-refresh {
    background: #172136;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #f8fafc;
    font-weight: 600;
    font-size: 13px;
    border-radius: 10px;
    padding: 9px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-refresh:hover {
    background: #1f2c47;
    transform: translateY(-2px);
}

.btn-logout {
    background: rgba(220, 38, 38, 0.15);
    border: 1px solid rgba(220, 38, 38, 0.3);
    color: #fca5a5;
    font-weight: 600;
    font-size: 13px;
    border-radius: 10px;
    padding: 9px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-logout:hover {
    background: rgba(220, 38, 38, 0.25);
    color: #ffffff;
    transform: translateY(-2px);
}

/* --------------------------------------------------------------------------
   DASHBOARD CONTENT
   -------------------------------------------------------------------------- */
.dashboard-content {
    flex: 1;
    padding: 28px 32px 48px;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
}

/* --------------------------------------------------------------------------
   TOP SUMMARY KPI CARDS (UNIFIED DARK SLATE CARDS)
   -------------------------------------------------------------------------- */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 28px;
}

@media (max-width: 1100px) {
    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .summary-cards {
        grid-template-columns: 1fr;
    }
}

.card {
    background: #131c2e !important;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 22px 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 140px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

.card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.card-top h3 {
    font-size: 12px;
    font-weight: 800;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.card-icon-box {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(220, 38, 38, 0.15);
    color: #f87171;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.stat-number {
    font-size: 28px;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.5px;
    margin: 4px 0;
}

.stat-subtitle {
    font-size: 13px;
    color: #94a3b8;
    font-weight: 500;
}

.pill-variation-summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 15px;
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    margin: 4px 0;
}

.pill-variation-summary.positive {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
}

/* --------------------------------------------------------------------------
   TABLE CONTROLS (FILTERS & SEARCH)
   -------------------------------------------------------------------------- */
.table-container {
    background: transparent;
    border: none;
    padding: 0;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
    flex-wrap: wrap;
    gap: 16px;
}

.filter-pills-group {
    background: #131c2e;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 30px;
    padding: 4px;
    display: flex;
    gap: 4px;
}

.filter-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 8px 18px;
    border-radius: 25px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-btn:hover {
    color: #ffffff;
}

.filter-btn.active {
    background: #dc2626;
    color: #ffffff;
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.4);
}

.table-controls-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.search-box {
    position: relative;
}

.search-box i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
    font-size: 14px;
}

.search-box input {
    background: #131c2e;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 25px;
    padding: 10px 20px 10px 42px;
    color: #f8fafc;
    font-size: 13px;
    font-weight: 500;
    outline: none;
    width: 290px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.search-box input:focus {
    border-color: #ef4444;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3), 0 0 0 2px rgba(239, 68, 68, 0.2);
}

.stores-count-badge {
    background: #131c2e;
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #ffffff;
    border-radius: 25px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 700;
}

/* --------------------------------------------------------------------------
   STORES GRID & STORE CARDS (COHESIVE UNIFIED DARK CARDS)
   -------------------------------------------------------------------------- */
.stores-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.store-card {
    background: #131c2e !important;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 22px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.store-card:hover {
    transform: translateY(-3px);
    border-color: rgba(255, 255, 255, 0.16);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
}

.store-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 14px;
}

.store-info h3 {
    font-size: 16px;
    font-weight: 800;
    color: #f8fafc;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.store-host {
    display: none;
}

.type-badge {
    font-size: 11px;
    font-weight: 800;
    border-radius: 6px;
    padding: 3px 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.type-badge.sucursal {
    background: rgba(239, 68, 68, 0.18);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.type-badge.franquicia {
    background: #1e293b;
    color: #94a3b8;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.status-badge {
    font-size: 12px;
    font-weight: 700;
    border-radius: 20px;
    padding: 4px 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.status-badge.online {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.status-badge.offline {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.sales-main-display {
    margin-bottom: 14px;
}

.sales-main-display .label {
    font-size: 13px;
    color: #94a3b8;
    font-weight: 500;
    margin-bottom: 2px;
}

.sales-main-display .amount {
    font-size: 26px;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.5px;
}

.comparison-box {
    background: #0b0f19;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.comp-info .c-label {
    font-size: 12px;
    color: #94a3b8;
    font-weight: 500;
    display: block;
}

.comp-info .c-value {
    font-size: 16px;
    font-weight: 700;
    color: #f1f5f9;
    display: block;
    margin-top: 2px;
}

.badge-variation {
    font-size: 15px;
    font-weight: 800;
}

.badge-variation.negative {
    color: #f87171;
}

.badge-variation.positive {
    color: #34d399;
}

.badge-variation.neutral {
    color: #94a3b8;
}

.metrics-row {
    display: flex;
    justify-content: space-between;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 14px;
    margin-bottom: 16px;
}

.metric-item .m-label {
    font-size: 12px;
    color: #94a3b8;
    font-weight: 500;
    display: block;
    margin-bottom: 2px;
}

.metric-item .m-value {
    font-size: 15px;
    font-weight: 700;
    color: #f8fafc;
    display: block;
}

.card-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.card-updated {
    font-size: 12px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-chart-detail {
    background: #1a253c;
    color: #f8fafc;
    border-radius: 8px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 700;
    border: 1px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.btn-chart-detail:hover {
    background: #dc2626;
    border-color: #dc2626;
    color: #ffffff;
}

/* --------------------------------------------------------------------------
   MODAL COMPARATIVAS (UNIFIED DARK MODAL)
   -------------------------------------------------------------------------- */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.modal-card {
    background: #131c2e;
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 28px 32px;
    width: 100%;
    max-width: 960px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 800;
    color: #f8fafc;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-close-modal {
    background: none;
    border: none;
    font-size: 26px;
    color: #94a3b8;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s ease;
}

.btn-close-modal:hover {
    color: #ef4444;
}

.modal-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.modal-tab {
    background: #0b0f19;
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: #94a3b8;
    padding: 9px 18px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.modal-tab:hover {
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.15);
}

.modal-tab.active {
    background: #dc2626;
    color: #ffffff;
    border-color: #dc2626;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.35);
}

.comparison-controls {
    background: #0b0f19;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 14px 20px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.select-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.select-group label {
    font-size: 13px;
    font-weight: 700;
    color: #94a3b8;
}

.select-group input {
    background: #131c2e;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    color: #f8fafc;
    outline: none;
}

.select-group input:focus {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.vs-badge {
    font-size: 13px;
    font-weight: 700;
    color: #64748b;
}

.btn-compare {
    background: #dc2626;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 10px rgba(220, 38, 38, 0.25);
    transition: all 0.2s ease;
}

.btn-compare:hover {
    background: #b91c1c;
    transform: translateY(-1px);
}

.comparison-summary-bar {
    background: #0b0f19;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 14px 20px;
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    text-align: center;
}

.comparison-summary-bar .metric-item .m-label {
    color: #94a3b8;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
}

.comparison-summary-bar .metric-item .m-value {
    color: #fca5a5;
    font-size: 18px;
    font-weight: 800;
}

.chart-wrapper {
    background: #0b0f19;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 16px;
    min-height: 320px;
}

/* --------------------------------------------------------------------------
   TOAST NOTIFICATIONS
   -------------------------------------------------------------------------- */
#toastContainer {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: #1e293b;
    color: #ffffff;
    padding: 14px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0,0,0,0.4);
    border-left: 4px solid #3b82f6;
    animation: toastIn 0.3s ease forwards;
}

.toast.success {
    border-left-color: #10b981;
}

.toast.error {
    border-left-color: #ef4444;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}



/* ==========================================================================
   RESPONSIVE NAVBAR & MOBILE OPTIMIZATIONS
   ========================================================================== */

@media (max-width: 768px) {
    .navbar {
        padding: 10px 14px;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .nav-top-row {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .navbar-brand {
        gap: 10px;
    }

    .nav-logo {
        height: 32px;
    }

    .brand-text h1 {
        font-size: 16px;
    }

    .brand-text p {
        display: none; /* Hide subtitle to preserve vertical space */
    }

    .navbar-status {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .user-info, .session-timer {
        padding: 5px 10px;
        font-size: 11px;
        border-radius: 14px;
        white-space: nowrap;
    }

    .navbar-actions {
        width: 100%;
        display: flex;
        gap: 8px;
    }

    .btn-excel, .btn-refresh, .btn-logout {
        flex: 1;
        padding: 8px 6px;
        font-size: 11px;
        justify-content: center;
        border-radius: 8px;
        white-space: nowrap;
        gap: 6px;
    }

    .dashboard-content {
        padding: 16px 12px 36px;
    }

    .summary-cards {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .table-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .filter-pills-group {
        width: 100%;
        display: flex;
        justify-content: space-between;
    }

    .filter-btn {
        flex: 1;
        text-align: center;
        padding: 7px 4px;
        font-size: 11px;
    }

    .table-controls-right {
        width: 100%;
        display: flex;
        gap: 10px;
    }

    .search-box {
        flex: 1;
    }

    .search-box input {
        width: 100%;
        padding: 8px 14px 8px 36px;
        font-size: 12px;
    }

    .stores-count-badge {
        padding: 6px 12px;
        font-size: 11px;
        white-space: nowrap;
    }

    .stores-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .modal-card {
        padding: 20px 16px;
    }
}

@media (max-width: 480px) {
    .navbar {
        padding: 8px 12px;
    }

    .nav-logo {
        height: 28px;
    }

    .brand-text h1 {
        font-size: 15px;
    }

    .user-info, .session-timer {
        padding: 4px 8px;
        font-size: 10px;
    }

    .btn-excel, .btn-refresh, .btn-logout {
        padding: 7px 4px;
        font-size: 10px;
        gap: 4px;
    }
}
