/* === TIGA BI Design System === */
:root {
    --tiga-primary: #1a2744;
    --tiga-primary-light: #243354;
    --tiga-accent: #0d9488;
    --tiga-accent-hover: #0b7f74;
    --tiga-bg: #f1f5f9;
    --tiga-surface: #ffffff;
    --tiga-text: #1e293b;
    --tiga-text-muted: #64748b;
    --tiga-border: #cbd5e1;

    --tiga-green: #15803d;
    --tiga-green-bg: #dcfce7;
    --tiga-yellow: #ca8a04;
    --tiga-yellow-bg: #fef9c3;
    --tiga-red: #b91c1c;
    --tiga-red-bg: #fee2e2;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
    background-color: var(--tiga-bg) !important;
    color: var(--tiga-text);
}

/* === Cards === */
.tiga-card {
    background: var(--tiga-surface);
    border: 1px solid var(--tiga-border);
    border-radius: .75rem;
    padding: 1.25rem;
    color: var(--tiga-text);
    box-shadow: 0 2px 10px rgba(15, 23, 42, .08);
}

.tiga-kpi-card {
    background: var(--tiga-surface);
    border: 1px solid var(--tiga-border);
    border-radius: .75rem;
    padding: 1.25rem;
    color: var(--tiga-text);
    box-shadow: 0 2px 10px rgba(15, 23, 42, .08);
    border-left: 4px solid var(--tiga-border);
    transition: transform .15s ease, box-shadow .15s ease;
}

.tiga-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(15, 23, 42, .12);
}

.tiga-kpi-card.semaphore-green { border-left-color: var(--tiga-green); }
.tiga-kpi-card.semaphore-yellow { border-left-color: var(--tiga-yellow); }
.tiga-kpi-card.semaphore-red { border-left-color: var(--tiga-red); }

.mis-tiendas-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.mis-tiendas-grid-item {
    min-width: 0;
}

/* === Semaphore badges === */
.semaphore-badge-green {
    background-color: var(--tiga-green-bg) !important;
    color: var(--tiga-green) !important;
    font-weight: 600;
}
.semaphore-badge-yellow {
    background-color: var(--tiga-yellow-bg) !important;
    color: var(--tiga-yellow) !important;
    font-weight: 600;
}
.semaphore-badge-red {
    background-color: var(--tiga-red-bg) !important;
    color: var(--tiga-red) !important;
    font-weight: 600;
}

.delta-positive { color: var(--tiga-green) !important; }
.delta-negative { color: var(--tiga-red) !important; }

/* === Animations === */
.fade-in {
    animation: fadeInUp .4s ease both;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* === Spinner === */
.tiga-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    color: var(--tiga-text-muted);
}

.tiga-spinner::before {
    content: '';
    width: 2.5rem;
    height: 2.5rem;
    border: 3px solid var(--tiga-border);
    border-top-color: var(--tiga-accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    margin-bottom: .75rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === Navbar === */
.navbar-tiga {
    background-color: var(--tiga-primary) !important;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

.navbar-tiga .nav-link {
    color: rgba(255,255,255,.8) !important;
    font-weight: 500;
    transition: color .15s;
}

.navbar-tiga .nav-link:hover,
.navbar-tiga .nav-link.active {
    color: #fff !important;
}

.navbar-tiga .navbar-brand {
    color: #fff !important;
    font-weight: 700;
}

/* === Buttons — full override to ensure visibility === */
.btn-tiga {
    background-color: #0d9488 !important;
    border: 2px solid #0d9488 !important;
    color: #fff !important;
    font-weight: 600;
    padding: .45rem 1.1rem;
    border-radius: .5rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.btn-tiga:hover,
.btn-tiga:focus {
    background-color: #0b7f74 !important;
    border-color: #0b7f74 !important;
    color: #fff !important;
}

/* Outline buttons need visible borders */
.btn-outline-secondary {
    color: #334155 !important;
    border: 2px solid #94a3b8 !important;
    background-color: #fff !important;
    font-weight: 500;
    border-radius: .5rem;
    padding: .45rem 1.1rem;
    cursor: pointer;
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
    background-color: #e2e8f0 !important;
    color: #0f172a !important;
    border-color: #64748b !important;
}

.btn-outline-secondary.active,
.btn-outline-secondary:active {
    background-color: #334155 !important;
    color: #fff !important;
    border-color: #334155 !important;
}

.btn-outline-light {
    border: 2px solid rgba(255,255,255,.5) !important;
    color: #fff !important;
    background: transparent !important;
    border-radius: .5rem;
}

.btn-outline-light:hover {
    background-color: rgba(255,255,255,.15) !important;
    border-color: #fff !important;
    color: #fff !important;
}

.btn-outline-primary {
    color: #0d9488 !important;
    border: 1px solid #0d9488 !important;
    background: transparent !important;
}

.btn-outline-primary:hover {
    background-color: #0d9488 !important;
    color: #fff !important;
}

.btn-outline-danger {
    color: var(--tiga-red) !important;
    border: 1px solid var(--tiga-red) !important;
    background: transparent !important;
}

.btn-outline-danger:hover {
    background-color: var(--tiga-red) !important;
    color: #fff !important;
}

/* Button group — active state for filters */
.btn-group .btn-tiga {
    border-radius: 0;
}

.btn-group .btn-tiga:first-child {
    border-top-left-radius: .5rem;
    border-bottom-left-radius: .5rem;
}

.btn-group .btn-tiga:last-child {
    border-top-right-radius: .5rem;
    border-bottom-right-radius: .5rem;
}

.btn-group .btn-outline-secondary {
    border-radius: 0;
}

.btn-group .btn-outline-secondary:first-child {
    border-top-left-radius: .5rem;
    border-bottom-left-radius: .5rem;
}

.btn-group .btn-outline-secondary:last-child {
    border-top-right-radius: .5rem;
    border-bottom-right-radius: .5rem;
}

/* === Progress bars — explicit styling for visibility === */
.progress,
div.progress {
    background-color: #e2e8f0 !important;
    border-radius: 999px !important;
    overflow: hidden;
}

.progress-bar,
div.progress-bar {
    background-color: #0d9488 !important;
    border-radius: 999px;
    min-height: 100%;
}

/* Standalone bar rendering (fallback) */
.tiga-progress-track {
    height: 12px;
    background-color: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}

.tiga-progress-fill {
    height: 100%;
    background-color: #0d9488;
    border-radius: 999px;
    transition: width .4s ease;
}

/* === Login page === */
.login-bg {
    flex: 1 0 auto;
    background: linear-gradient(135deg, var(--tiga-primary) 0%, #0f172a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

/* === TV Mode === */
.tv-bg {
    min-height: 100%;
    background: #0f172a;
    color: #f8fafc;
}

.tv-screen {
    height: calc(100vh - 2rem);
    background: #0f172a;
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: .75rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tv-title {
    color: #f8fafc;
}

.tv-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
}

.tv-header-actions {
    justify-self: end;
}

.tv-tenant-title {
    text-align: center;
    font-size: clamp(1rem, 1.5vw, 1.35rem);
    color: #f8fafc;
    letter-spacing: .02em;
}

.tv-subtle {
    color: rgba(248, 250, 252, .78);
}

.tv-strong {
    color: #f8fafc;
}

.tv-meta-achieved {
    color: #22c55e;
}

.tv-summary-card {
    background: linear-gradient(135deg, rgba(15, 23, 42, .85), rgba(15, 118, 110, .8));
    border: 1px solid rgba(255,255,255,.2);
    border-radius: .75rem;
    padding: .7rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-around;
    gap: 1rem;
    flex-shrink: 0;
}

.tv-summary-item {
    display: flex;
    flex-direction: column;
    text-align: center;
}

.tv-summary-value {
    color: #f8fafc;
    font-size: clamp(1.15rem, 1.9vw, 1.8rem);
    line-height: 1.1;
}

.tv-card-grid {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(var(--tv-columns, 4), minmax(0, 1fr));
    grid-template-rows: repeat(var(--tv-rows, 1), minmax(0, 1fr));
    gap: .7rem;
    --tv-card-max-width: 32rem;
    --tv-card-max-height: 18rem;
}

.tv-card {
    background: var(--tiga-primary);
    border: 1px solid rgba(255,255,255,.15);
    border-radius: .75rem;
    padding: 1rem;
    color: #f8fafc;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    width: min(100%, var(--tv-card-max-width));
    max-width: var(--tv-card-max-width);
    height: min(100%, var(--tv-card-max-height));
    max-height: var(--tv-card-max-height);
    justify-self: center;
    align-self: center;
}

.tv-card-code {
    font-size: 1.2rem;
}

.tv-card-code-warn {
    color: #eab308;
}

.tv-card-code-alert {
    color: #ef4444;
}

.tv-card-sales {
    font-size: clamp(1.15rem, 1.6vw, 1.55rem);
}

.tv-card-sales-stale {
    color: #ef4444;
}

.tv-card-metrics {
    font-size: .86rem;
}

.tv-card-grid.tv-grid-dense .tv-card {
    padding: .8rem;
}

.tv-card-grid.tv-grid-dense .tv-card-code {
    font-size: 1.1rem;
}

.tv-card-grid.tv-grid-dense .tv-card-sales {
    font-size: clamp(1.02rem, 1.25vw, 1.3rem);
}

.tv-card-grid.tv-grid-dense .tv-card-metrics {
    font-size: .8rem;
}

.tv-card-grid.tv-grid-compact .tv-card {
    padding: .65rem;
}

.tv-card-grid.tv-grid-compact .tv-card-code {
    font-size: 1rem;
}

.tv-card-grid.tv-grid-compact .tv-card-sales {
    font-size: clamp(.95rem, 1vw, 1.15rem);
}

.tv-card-grid.tv-grid-compact .tv-card-metrics,
.tv-card-grid.tv-grid-compact .tv-subtle {
    font-size: .74rem;
}

.tv-live-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    background: #22c55e;
    border-radius: 50%;
    animation: pulse-live 1.5s ease infinite;
    margin-right: .4rem;
}

@keyframes pulse-live {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: .5; transform: scale(1.3); }
}


@media (max-width: 768px) {
    .mis-tiendas-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .tv-header {
        grid-template-columns: 1fr;
        gap: .5rem;
    }

    .tv-header-actions {
        justify-self: start;
        flex-wrap: wrap;
    }

    .tv-tenant-title {
        text-align: left;
    }

    .tv-screen {
        height: auto;
        min-height: calc(100vh - 2rem);
        overflow: visible;
    }

    .tv-summary-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .tv-summary-item {
        text-align: left;
    }

    .tv-card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-rows: none;
        height: auto;
    }

    .tv-card {
        width: 100%;
        max-width: none;
        height: auto;
        max-height: none;
    }
}

@media (max-width: 576px) {
    .mis-tiendas-grid {
        grid-template-columns: 1fr;
    }

    .tv-card-grid {
        grid-template-columns: 1fr;
    }
}

/* === Tabs — make them look like tabs, not plain text === */
.nav-tabs {
    border-bottom: 2px solid var(--tiga-border);
}

.nav-tabs .nav-link {
    color: #64748b;
    font-weight: 500;
    border: 1px solid transparent;
    border-bottom: 2px solid transparent;
    padding: .6rem 1rem;
    margin-bottom: -2px;
    cursor: pointer;
    background: transparent;
    transition: all .15s;
}

.nav-tabs .nav-link:hover {
    color: #1e293b;
    border-bottom-color: #94a3b8;
    background-color: rgba(0,0,0,.02);
}

.nav-tabs .nav-link.active {
    color: #0d9488 !important;
    background-color: var(--tiga-surface) !important;
    border-color: var(--tiga-border) var(--tiga-border) var(--tiga-surface) !important;
    border-bottom: 2px solid #0d9488 !important;
    font-weight: 600;
}

/* === Tables === */
.table {
    --bs-table-color: var(--tiga-text);
    --bs-table-striped-color: var(--tiga-text);
    --bs-table-hover-color: var(--tiga-text);
}

.table thead th {
    color: #334155;
    background-color: #f8fafc;
    font-weight: 600;
    border-bottom: 2px solid var(--tiga-border);
}

.table td {
    color: var(--tiga-text);
    vertical-align: middle;
}

/* === Badges === */
.badge {
    border: 1px solid rgba(15, 23, 42, .08);
    font-weight: 600;
    padding: .35em .65em;
}

/* === Forms === */
.form-control,
.form-select {
    border: 1px solid var(--tiga-border);
    color: var(--tiga-text);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--tiga-accent);
    box-shadow: 0 0 0 .2rem rgba(13, 148, 136, .2);
}

/* === Alerts === */
.alert {
    border-radius: .5rem;
}

/* === Links === */
a {
    color: var(--tiga-accent);
}

a:hover {
    color: var(--tiga-accent-hover);
}

/* === Breadcrumb === */
.breadcrumb-item a {
    color: var(--tiga-accent);
    text-decoration: none;
}

.breadcrumb-item a:hover {
    color: var(--tiga-accent-hover);
    text-decoration: underline;
}

.breadcrumb-item.active {
    color: var(--tiga-text-muted);
}

/* === Bar chart hover === */
.tiga-bar {
    transition: opacity .15s ease;
    padding: .25rem 0;
}
.tiga-bar:hover {
    opacity: .85;
}

/* === Page container === */
.tiga-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* === App shell and footer === */
.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-content {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
}

.app-footer {
    flex-shrink: 0;
    width: 100%;
    padding: .875rem 1.5rem;
    font-size: .8rem;
    color: var(--tiga-text-muted);
    border-top: 1px solid var(--tiga-border);
    background-color: rgba(255, 255, 255, .75);
}

.app-footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
}

.app-footer-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 600;
    opacity: .85;
}

.app-footer-logo {
    height: 18px;
    opacity: .75;
}

.app-footer-copy {
    opacity: .8;
}

.app-footer-dark {
    color: rgba(248, 250, 252, .85);
    border-top-color: rgba(255, 255, 255, .15);
    background-color: rgba(2, 6, 23, .35);
}

.app-footer-link {
    font-weight: 700;
    text-decoration: none;
    color: inherit;
}

.app-footer-link:hover {
    text-decoration: underline;
}

@media (max-width: 576px) {
    .app-footer-inner {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
}

/* === List group inside cards === */
.tiga-card .list-group-item {
    background: transparent;
    color: var(--tiga-text);
    border-color: var(--tiga-border);
}
