/* ================================
   QuickFin Dashboard Styles
   Dark mode, glassmorphism, modern
   ================================ */

:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: rgba(30, 30, 50, 0.7);
    --bg-card-hover: rgba(40, 40, 65, 0.85);
    --border-card: rgba(255, 255, 255, 0.08);
    --border-card-hover: rgba(255, 255, 255, 0.15);

    --text-primary: #e8e8f0;
    --text-secondary: #8888aa;
    --text-muted: #555570;
    --text-value: #ffffff;

    --accent-blue: #4e8cff;
    --accent-green: #34d399;
    --accent-amber: #fbbf24;
    --accent-red: #f87171;
    --accent-purple: #a78bfa;

    --gradient-header: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    --gradient-btn: linear-gradient(135deg, #4e8cff 0%, #7c3aed 100%);
    --gradient-btn-hover: linear-gradient(135deg, #6ba0ff 0%, #9058f0 100%);

    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-card-hover: 0 8px 32px rgba(0, 0, 0, 0.4);

    --radius: 16px;
    --radius-sm: 10px;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Reset */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── Dashboard Layout ── */

.dashboard {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ── Header ── */

.dashboard__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2rem 2.5rem;
    margin-bottom: 2rem;
    background: var(--gradient-header);
    border-radius: var(--radius);
    border: 1px solid var(--border-card);
    backdrop-filter: blur(12px);
}

.header__title {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header__logo {
    font-size: 1.6rem;
}

.header__subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 0.25rem;
    font-weight: 400;
}

/* ── Button ── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
}

.btn--refresh {
    background: var(--gradient-btn);
    color: white;
    box-shadow: 0 4px 16px rgba(78, 140, 255, 0.3);
}

.btn--refresh:hover {
    background: var(--gradient-btn-hover);
    box-shadow: 0 6px 20px rgba(78, 140, 255, 0.4);
    transform: translateY(-1px);
}

.btn--refresh:active {
    transform: translateY(0);
}

/* ── Spinner ── */

.spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.htmx-request .spinner,
.htmx-request.spinner {
    display: inline-block;
}

.htmx-request .btn__text {
    opacity: 0.7;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Alerts ── */

.alerts {
    margin-bottom: 1.5rem;
}

.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    line-height: 1.5;
}

.alert--warning {
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.25);
    color: var(--accent-amber);
}

.alert--warning a {
    color: var(--accent-amber);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.alert--warning a:hover {
    opacity: 0.8;
}

/* ── Indicators Grid ── */

.indicators-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
}

/* ── Cards ── */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-card);
    transition: all 0.3s ease;
    animation: fadeIn 0.4s ease-out;
}

.card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-card-hover);
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-2px);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card__header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.card__icon {
    font-size: 1.5rem;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    flex-shrink: 0;
}

.card__title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: -0.01em;
}

.card__body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.card__value-container {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.card__value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-value);
    letter-spacing: -0.03em;
    line-height: 1;
}

.card__unit {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.card__secondary {
    font-size: 0.85rem;
    color: var(--accent-green);
    font-weight: 500;
}

.card__meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-card);
}

.card__source,
.card__time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.card__no-data {
    color: var(--text-muted);
    font-style: italic;
    padding: 1rem 0;
}

/* ── Change Badges ── */

.card__changes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.change-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.2rem 0.5rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1;
    letter-spacing: -0.01em;
    transition: opacity 0.2s ease;
}

.change-badge:hover {
    opacity: 0.85;
}

.change-badge small {
    font-weight: 500;
    opacity: 0.7;
    font-size: 0.65rem;
    margin-left: 0.1rem;
}

.change-badge--up {
    color: var(--accent-green);
    background: rgba(52, 211, 153, 0.12);
    border: 1px solid rgba(52, 211, 153, 0.2);
}

.change-badge--down {
    color: var(--accent-red);
    background: rgba(248, 113, 113, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.2);
}

/* ── Empty State ── */

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.empty-state__text {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.empty-state__hint {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* ── Footer ── */

.dashboard__footer {
    max-width: 1200px;
    margin: 3rem auto 2rem;
    padding: 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.dashboard__footer a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.dashboard__footer a:hover {
    color: var(--accent-blue);
}

/* ── Responsive ── */

@media (max-width: 768px) {
    .dashboard {
        padding: 1rem;
    }

    .dashboard__header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        padding: 1.5rem;
    }

    .header__title {
        font-size: 1.5rem;
    }

    .indicators-grid {
        grid-template-columns: 1fr;
    }

    .card__value {
        font-size: 1.6rem;
    }

    .btn--refresh {
        width: 100%;
        justify-content: center;
    }
}

/* ── htmx swap transition ── */

.htmx-swapping {
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

/* ── Tag Filter Bar ── */

.tag-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding: 1rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius);
    backdrop-filter: blur(12px);
}

.tag-filter {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 1rem;
    border: 1px solid var(--border-card);
    border-radius: 20px;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    letter-spacing: 0.01em;
}

.tag-filter:hover {
    border-color: var(--border-card-hover);
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.tag-filter--active {
    background: var(--tag-color, var(--accent-blue));
    color: white;
    border-color: var(--tag-color, var(--accent-blue));
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.tag-filter--active:hover {
    background: var(--tag-color, var(--accent-blue));
    color: white;
    opacity: 0.9;
}

/* ── Tag Badges on Cards ── */

.card__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-left: auto;
}

.tag-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.65rem;
    font-weight: 700;
    color: white;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    line-height: 1.4;
}

/* ── Card hide/show for filtering ── */

.card--hidden {
    display: none;
}

/* ── Responsive additions ── */

@media (max-width: 768px) {
    .tag-filters {
        padding: 0.75rem;
        gap: 0.35rem;
    }

    .tag-filter {
        padding: 0.35rem 0.75rem;
        font-size: 0.78rem;
    }
}