/* ============================================
   VIFM Design System v2.0
   Shared styles for all pages
   ============================================ */

/* === Design Tokens === */
:root {
    /* VIFM Brand Colors (from Brand Kit) */
    --off-white: #FEFFF9;
    --dark-blue: #000032;          /* Brand navy - logo IFM */
    --primary-blue: #000032;       /* Brand navy - logo IFM */
    --accent-blue: #3878BE;        /* Brand blue darkened for WCAG AA 4.57:1 (brand: #5190D5) */
    --accent-blue-light: #E6EFF8;  /* Light tint of brand blue */
    --navy-blue: #000032;          /* Brand navy - logo IFM */

    /* Text */
    --text-secondary: #6B7280;
    --text-tertiary: #9CA3AF;

    /* Surfaces & Borders */
    --border: #E5E7EB;
    --surface: #F5F5F7;

    /* Semantic */
    --success: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;

    /* Expanded Accent Palette */
    --accent-teal: #0EA5E9;
    --accent-emerald: #10B981;
    --accent-violet: #8B5CF6;
    --accent-amber: #F59E0B;
    --accent-rose: #F43F5E;
    --accent-indigo: #6366F1;
    --accent-cyan: #06B6D4;
    --accent-orange: #F97316;

    /* Light tint backgrounds */
    --teal-light: rgba(14, 165, 233, 0.1);
    --emerald-light: rgba(16, 185, 129, 0.1);
    --violet-light: rgba(139, 92, 246, 0.1);
    --amber-light: rgba(245, 158, 11, 0.1);
    --rose-light: rgba(244, 63, 94, 0.1);
    --indigo-light: rgba(99, 102, 241, 0.1);
    --cyan-light: rgba(6, 182, 212, 0.1);
    --orange-light: rgba(249, 115, 22, 0.1);

    /* Typography */
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

    /* Spacing */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
}

/* === Dark Mode === */
[data-theme="dark"] {
    --off-white: #0F1117;
    --dark-blue: #E8E9ED;
    --primary-blue: #E8E9ED;
    --accent-blue: #5190D5;        /* Exact brand blue - passes AA on dark bg */
    --accent-blue-light: #1A2744;
    --navy-blue: #E0E1E6;

    --text-secondary: #9CA3AF;
    --text-tertiary: #6B7280;

    --border: #2A2D35;
    --surface: #1A1C24;

    --success: #34D399;
    --danger: #F87171;
    --warning: #FBBF24;

    /* Expanded Accent Palette (Dark Mode) */
    --accent-teal: #38BDF8;
    --accent-emerald: #34D399;
    --accent-violet: #A78BFA;
    --accent-amber: #FBBF24;
    --accent-rose: #FB7185;
    --accent-indigo: #818CF8;
    --accent-cyan: #22D3EE;
    --accent-orange: #FB923C;

    --teal-light: rgba(56, 189, 248, 0.12);
    --emerald-light: rgba(52, 211, 153, 0.12);
    --violet-light: rgba(167, 139, 250, 0.12);
    --amber-light: rgba(251, 191, 36, 0.12);
    --rose-light: rgba(251, 113, 133, 0.12);
    --indigo-light: rgba(129, 140, 248, 0.12);
    --cyan-light: rgba(34, 211, 238, 0.12);
    --orange-light: rgba(249, 146, 60, 0.12);

    color-scheme: dark;
}

[data-theme="dark"] body {
    background: #0F1117;
    color: #E8E9ED;
}

[data-theme="dark"] .bottom-nav {
    background: #1A1C24;
    border-top-color: #2A2D35;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .card,
[data-theme="dark"] .card-elevated,
[data-theme="dark"] .action-card,
[data-theme="dark"] .comparison-card,
[data-theme="dark"] .settings-item,
[data-theme="dark"] .company-card,
[data-theme="dark"] .authority-card {
    background: #1A1C24;
    border-color: #2A2D35;
}

[data-theme="dark"] .card-elevated:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .filter-chip {
    background: #1A1C24;
    border-color: #2A2D35;
    color: #9CA3AF;
}

[data-theme="dark"] .filter-chip.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
}

[data-theme="dark"] .data-table thead th {
    background: #1A1C24;
    border-bottom-color: #2A2D35;
}

[data-theme="dark"] .data-table tbody td {
    border-bottom-color: #1F2128;
}

[data-theme="dark"] .data-table tbody tr:hover {
    background: #1F2128;
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: #1A1C24;
    border-color: #2A2D35;
    color: #E8E9ED;
}

[data-theme="dark"] .price-change.positive {
    background: #064E3B;
    color: #34D399;
}

[data-theme="dark"] .price-change.negative {
    background: #7F1D1D;
    color: #F87171;
}

[data-theme="dark"] .price-change.neutral {
    background: #1F2128;
    color: #6B7280;
}

/* === Global Typography === */
body {
    font-variant-numeric: tabular-nums;
}

/* === Monospace for Financial Data === */
.font-mono,
.price-value,
.metric-value,
.stat-value,
[data-price],
.change-value {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

/* === 5-Tab Bottom Navigation === */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    max-width: 430px;
    width: 100%;
    background: white;
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 8px 4px env(safe-area-inset-bottom, 20px);
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.bottom-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
    padding: 4px 2px;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav .nav-item:hover {
    color: var(--accent-blue);
}

.bottom-nav .nav-item.active {
    color: var(--accent-blue);
}

.bottom-nav .nav-item:active {
    transform: scale(0.92);
    transition: transform 0.1s ease;
}

.bottom-nav .nav-icon {
    font-size: 20px;
    line-height: 1;
}

.bottom-nav .nav-label {
    font-size: 10px;
    font-weight: 600;
    text-align: center;
    line-height: 1.2;
    white-space: nowrap;
}

/* === Standardized Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    line-height: 1.4;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--accent-blue);
    color: white;
}

.btn-primary:hover {
    background: #2D6BC4;
    box-shadow: 0 4px 12px rgba(59, 125, 216, 0.3);
}

.btn-secondary {
    background: var(--surface);
    color: var(--dark-blue);
}

.btn-secondary:hover {
    background: #EAEAEF;
}

.btn-outline {
    background: transparent;
    color: var(--accent-blue);
    border: 1.5px solid var(--accent-blue);
}

.btn-outline:hover {
    background: var(--accent-blue-light);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #DC2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
    border-radius: var(--radius-lg);
}

.btn-block {
    width: 100%;
}

/* === Standardized Cards === */
.card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all 0.2s ease;
}

.card-elevated {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: all 0.2s ease;
}

.card-elevated:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.card-hero {
    background: linear-gradient(135deg, var(--accent-blue) 0%, var(--primary-blue) 100%);
    border-radius: var(--radius-xl);
    padding: 24px;
    color: white;
}

/* === Filter Chips === */
.filter-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.filter-chips::-webkit-scrollbar {
    display: none;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    color: var(--text-secondary);
    background: white;
    border: 1.5px solid var(--border);
    border-radius: 100px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.filter-chip:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.filter-chip.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
}

.filter-chip:active {
    transform: scale(0.95);
}

/* === Collapsible Filter Sections === */
.collapsible-section {
    margin-bottom: 12px;
}

.collapsible-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.collapsible-header .section-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.collapsible-header .chevron {
    font-size: 12px;
    color: var(--text-tertiary);
    transition: transform 0.3s ease;
}

.collapsible-header.collapsed .chevron {
    transform: rotate(-90deg);
}

.collapsible-body {
    overflow: hidden;
    max-height: 500px;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 1;
}

.collapsible-body.collapsed {
    max-height: 0;
    opacity: 0;
}

/* === Data Tables === */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

.data-table thead th {
    background: var(--surface);
    padding: 10px 16px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    text-align: left;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid var(--border);
}

.data-table thead th:first-child {
    border-radius: var(--radius-md) 0 0 0;
}

.data-table thead th:last-child {
    border-radius: 0 var(--radius-md) 0 0;
}

.data-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid #F3F4F6;
    vertical-align: middle;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background: #FAFBFC;
}

.data-table .text-right {
    text-align: right;
}

.data-table .text-center {
    text-align: center;
}

/* === Price Direction Indicators === */
.price-up {
    color: var(--success);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.price-up::before {
    content: '\f062'; /* fa-arrow-up */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 0.8em;
}

.price-down {
    color: var(--danger);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.price-down::before {
    content: '\f063'; /* fa-arrow-down */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 0.8em;
}

.price-neutral {
    color: var(--text-tertiary);
}

/* === Micro-Animations === */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-up {
    animation: fadeUp 0.4s ease-out forwards;
    opacity: 0;
}

.animate-fade-up:nth-child(1) { animation-delay: 0.0s; }
.animate-fade-up:nth-child(2) { animation-delay: 0.05s; }
.animate-fade-up:nth-child(3) { animation-delay: 0.1s; }
.animate-fade-up:nth-child(4) { animation-delay: 0.15s; }
.animate-fade-up:nth-child(5) { animation-delay: 0.2s; }
.animate-fade-up:nth-child(6) { animation-delay: 0.25s; }
.animate-fade-up:nth-child(7) { animation-delay: 0.3s; }
.animate-fade-up:nth-child(8) { animation-delay: 0.35s; }
.animate-fade-up:nth-child(9) { animation-delay: 0.4s; }

@keyframes numberPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.number-update {
    animation: numberPop 0.3s ease;
}

/* Button press feedback (global) */
button:active,
[role="button"]:active,
.action-card:active {
    transform: scale(0.97);
    transition: transform 0.1s ease;
}

/* === Skeleton Loading === */
@keyframes skeleton-shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton {
    background: linear-gradient(90deg, #E5E7EB 25%, #F3F4F6 37%, #E5E7EB 63%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 6px;
    display: inline-block;
}

.skeleton-text {
    height: 14px;
    width: 80%;
    margin-bottom: 6px;
}

.skeleton-text-sm {
    height: 10px;
    width: 50%;
}

.skeleton-price {
    height: 18px;
    width: 90px;
}

.skeleton-badge {
    height: 24px;
    width: 64px;
    border-radius: 6px;
}

.skeleton-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
}

.skeleton-row {
    display: grid;
    grid-template-columns: 50px 1fr 110px 80px;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid #F3F4F6;
    align-items: center;
}

/* === Empty State === */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
}

.empty-state-icon {
    font-size: 48px;
    color: var(--text-tertiary);
    margin-bottom: 16px;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border-radius: 50%;
}

.empty-state-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--dark-blue);
    margin-bottom: 8px;
}

.empty-state-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    max-width: 280px;
    line-height: 1.5;
}

.empty-state-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--accent-blue);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
    text-decoration: none;
}

.empty-state-btn:hover {
    background: var(--primary-blue);
}

/* === Standard Header === */
.page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: white;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-header .back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: var(--surface);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--dark-blue);
    font-size: 16px;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.page-header .back-btn:hover {
    background: var(--border);
}

.page-header .header-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--dark-blue);
}

.page-header .header-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.page-header .header-action {
    margin-left: auto;
}

/* Collapsible header on scroll */
.page-header.collapsible {
    transition: all 0.3s ease;
}

.page-header.collapsible.minimized {
    padding: 8px 20px;
}

.page-header.collapsible.minimized .header-subtitle {
    display: none;
}

/* === Gamification: Achievement Badges === */
.achievement-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.achievement-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: white;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    transition: box-shadow 0.2s;
}

.achievement-badge.unlocked {
    border-color: var(--accent-blue);
    box-shadow: 0 2px 8px rgba(56, 120, 190, 0.12);
}

.achievement-badge.locked {
    opacity: 0.5;
}

.achievement-badge .badge-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.achievement-badge.unlocked .badge-icon {
    background: var(--accent-blue);
    color: white;
}

.achievement-badge.locked .badge-icon {
    background: var(--surface);
    color: var(--text-tertiary);
}

.achievement-badge .badge-info {
    flex: 1;
    min-width: 0;
}

.achievement-badge .badge-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--dark-blue);
    line-height: 1.3;
}

.achievement-badge .badge-desc {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.3;
    margin-top: 2px;
}

.achievement-badge .badge-date {
    font-size: 10px;
    color: var(--accent-blue);
    margin-top: 3px;
}

/* Achievement Category Header */
.achievement-category {
    margin-bottom: 20px;
}

.achievement-category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 0 4px;
}

.achievement-category-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--dark-blue);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.achievement-category-count {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
}

/* Progress Bar */
.achievement-progress-bar {
    width: 100%;
    height: 8px;
    background: var(--surface);
    border-radius: 4px;
    overflow: hidden;
}

.achievement-progress-fill {
    height: 100%;
    background: var(--accent-blue);
    border-radius: 4px;
    transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Dashboard Progress Widget */
.progress-widget {
    background: white;
    border-radius: var(--radius-lg);
    padding: 16px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

.progress-widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.progress-widget-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--dark-blue);
}

.progress-widget-link {
    font-size: 13px;
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 600;
}

.progress-widget-stats {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}

.progress-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.progress-stat i {
    color: var(--accent-blue);
}

.progress-stat strong {
    color: var(--dark-blue);
    font-weight: 700;
}

.progress-recent-badges {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.progress-mini-badge {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--accent-blue);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.progress-mini-badge.empty {
    background: var(--surface);
    color: var(--text-tertiary);
}

/* Dark Mode Overrides */
[data-theme="dark"] .achievement-badge {
    background: #1A1C24;
    border-color: #2A2D35;
}

[data-theme="dark"] .achievement-badge.unlocked {
    border-color: var(--accent-blue);
}

[data-theme="dark"] .progress-widget {
    background: #1A1C24;
    border-color: #2A2D35;
}

[data-theme="dark"] .progress-mini-badge.empty {
    background: #2A2D35;
}
