/* ==========================================
   SEC Crypto ETF Tracker - Tech UI Redesign
   ========================================== */

:root {
    /* Color Palette */
    --bg-primary: #F5F5F4;
    /* Stone 50/100ish Beige */
    --bg-secondary: #E7E5E4;
    /* Stone 200 */
    --bg-tertiary: #D6D3D1;
    /* Stone 300 */
    --bg-terminal: #292524;
    /* Stone 800 */

    --text-primary: #1C1917;
    /* Stone 900 */
    --text-secondary: #44403C;
    /* Stone 700 */
    --text-muted: #78716C;
    /* Stone 500 */
    --text-on-dark: #FAFAF9;
    /* Stone 50 */

    --accent-emerald: #10B981;
    --accent-emerald-border: #059669;
    --accent-orange: #F59E0B;
    --accent-red: #EF4444;
    --accent-blue: #3B82F6;

    /* Brutalist Shadow */
    --hard-shadow: 4px 4px 0px 0px #1C1917;
    --hard-shadow-hover: 6px 6px 0px 0px #1C1917;

    /* Typography */
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --font-sans: 'Inter', system-ui, sans-serif;

    /* Spacing & Borders */
    --border-width: 2px;
    --radius-none: 0px;
    --spacing-sm: 0.75rem;
    --spacing-md: 1.25rem;
    --spacing-lg: 2rem;
}

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

body {
    font-family: var(--font-mono);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    padding: var(--spacing-lg);
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
}

/* ==========================================
   Brutalist Components
   ========================================== */

.brutalist-box {
    background: white;
    border: var(--border-width) solid var(--text-primary);
    box-shadow: var(--hard-shadow);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

/* ==========================================
   Header
   ========================================== */

.header {
    border-bottom: var(--border-width) solid var(--text-primary);
    padding-bottom: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.header-content {
    display: flex;
    justify-content: space-between;
    width: 100%;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: var(--accent-emerald);
    border: var(--border-width) solid var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 2px 2px 0px 0px var(--text-primary);
}

.logo-icon svg {
    width: 24px;
    height: 24px;
    color: white;
}

.logo-text h1 {
    font-size: 1.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: -0.02em;
}

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

.header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.header-top-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-info-block {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.lang-switch-container {
    margin-bottom: 4px;
}

.lang-btn {
    height: 28px;
    display: inline-flex;
    align-items: center;
    background: white;
    border: 1.5px solid var(--text-primary);
    padding: 0 10px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.1s;
}

.lang-btn:hover {
    background: var(--bg-secondary);
}

.lang-btn:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0px 0px var(--text-primary);
}

.header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.live-indicator {
    height: 28px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent-emerald);
    color: white;
    padding: 0 10px;
    border: 1.5px solid var(--text-primary);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
}

.last-updated {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 500;
    font-family: var(--font-mono);
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0.8;
}

/* ==========================================
   Stats Dashboard
   ========================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.stat-card {
    background: white;
    border: var(--border-width) solid var(--text-primary);
    padding: var(--spacing-md);
    box-shadow: var(--hard-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    /* Center horizontally */
    gap: var(--spacing-md);
    transition: transform 0.1s;
}

.stat-card:hover {
    transform: translate(-2px, -2px);
    box-shadow: var(--hard-shadow-hover);
}

.stat-icon {
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.stat-main {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.stat-value {
    font-size: 2.2rem;
    font-weight: 800;
    font-family: var(--font-mono);
    line-height: 1;
}

.stat-card.total .stat-value {
    color: var(--text-primary);
}

.stat-card.approved .stat-value {
    color: var(--accent-emerald);
}

.stat-card.pending .stat-value {
    color: var(--accent-blue);
}

.stat-card.denied .stat-value {
    color: var(--accent-red);
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 700;
    line-height: 1.2;
}

/* ==========================================
   Filters
   ========================================== */

.filters-container {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    background: var(--bg-secondary);
    border: var(--border-width) solid var(--text-primary);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.search-box {
    flex: 1;
    min-width: 300px;
    position: relative;
    margin-left: auto;
}

.search-box input {
    width: 100%;
    height: 44px;
    /* Unified height */
    padding: 0 16px 0 40px;
    background: white;
    border: var(--border-width) solid var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    outline: none;
    display: flex;
    align-items: center;
}

.search-box svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    color: var(--text-primary);
}

.filter-buttons {
    display: flex;
    gap: 8px;
}

.filter-btn {
    height: 44px;
    /* Unified height */
    padding: 0 16px;
    background: white;
    border: var(--border-width) solid var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.filter-btn.active[data-filter="all"] {
    background: var(--text-primary);
    color: white;
}

.filter-btn.active[data-filter="approved"] {
    background: var(--accent-emerald);
    color: white;
}

.filter-btn.active[data-filter="pending"] {
    background: var(--accent-blue);
    color: white;
}

.filter-btn.active[data-filter="denied"] {
    background: var(--accent-red);
    color: white;
}

.filter-btn:hover:not(.active) {
    background: var(--bg-tertiary);
}

.crypto-filter select {
    height: 44px;
    padding: 0 32px 0 16px;
    background: white;
    border: var(--border-width) solid var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

/* ==========================================
   Terminal Window (Timeline)
   ========================================== */

.timeline-section {
    margin-bottom: var(--spacing-lg);
}

.section-title {
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: var(--spacing-md);
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 12px;
}

.timeline-container {
    background: white;
    color: var(--text-primary);
    padding: var(--spacing-md);
    border: var(--border-width) solid var(--text-primary);
    box-shadow: var(--hard-shadow);
    display: flex;
    gap: var(--spacing-md);
    overflow-x: auto;
    font-size: 0.85rem;
}

.timeline-item {
    min-width: 250px;
    border-left: 2px solid var(--accent-emerald);
    padding-left: 12px;
    margin-bottom: 8px;
}

.timeline-date {
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.timeline-crypto {
    margin: 4px 0;
}

.timeline-crypto .symbol {
    color: var(--accent-emerald);
    font-weight: 700;
}

.timeline-crypto .name {
    color: var(--text-muted);
}

.timeline-issuer {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 2px;
}

.timeline-etf-name {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 2px;
}

.timeline-countdown {
    color: var(--accent-orange);
    font-weight: 700;
    margin-top: 4px;
}

/* ==========================================
   Application Cards
   ========================================== */

.applications-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: var(--spacing-md);
}

.application-card {
    background: white;
    border: var(--border-width) solid var(--text-primary);
    padding: var(--spacing-md);
    box-shadow: var(--hard-shadow);
    transition: transform 0.1s;
    display: flex;
    flex-direction: column;
}

.application-card:hover {
    transform: translate(-2px, -2px);
    box-shadow: var(--hard-shadow-hover);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--spacing-md);
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--text-muted);
}

.crypto-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.crypto-icon {
    width: 40px;
    height: 40px;
    background: var(--bg-secondary);
    border: 1px solid var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--text-primary);
    box-shadow: 2px 2px 0px 0px var(--text-primary);
}

.crypto-icon img {
    width: 32px;
    /* Slightly smaller to feel more 'floating' */
    height: 32px;
    object-fit: contain;
}

.crypto-details h3 {
    font-size: 1rem;
    font-weight: 700;
}

.ticker-highlight {
    display: inline-block;
    background: var(--text-primary);
    color: var(--accent-emerald);
    padding: 2px 8px;
    margin-left: 6px;
    font-size: 0.75rem;
    font-weight: 800;
    font-family: var(--font-mono);
    vertical-align: middle;
}

.crypto-symbol {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.card-trading-info {
    display: flex;
    gap: 12px;
    margin-bottom: var(--spacing-md);
    flex-wrap: wrap;
}

.trading-tag {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

.trading-tag strong {
    color: var(--text-muted);
    font-weight: 600;
}

.status-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 8px;
    border: 1px solid var(--text-primary);
    text-transform: uppercase;
}

.status-badge.approved {
    background: var(--accent-emerald);
    color: white;
}

.status-badge.pending {
    background: var(--accent-blue);
    color: white;
}

.status-badge.denied {
    background: var(--accent-red);
    color: white;
}

.status-badge.denied {
    background: var(--accent-red);
    color: white;
}

.card-body {
    margin-bottom: var(--spacing-md);
}

.etf-name {
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.issuer-name {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.card-meta {
    background: var(--bg-secondary);
    border: 1px solid var(--text-primary);
    padding: 8px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    font-size: 0.7rem;
}

.meta-item {
    display: flex;
    flex-direction: column;
}

.meta-label {
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.6rem;
}

.meta-value {
    font-weight: 600;
    word-break: break-word;
    white-space: normal;
}

.card-actions {
    margin-top: auto;
    padding-top: var(--spacing-md);
}

.action-btn {
    display: block;
    width: 100%;
    padding: 8px;
    background: var(--text-primary);
    color: var(--accent-emerald);
    text-align: center;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.8rem;
    border: var(--border-width) solid var(--text-primary);
    transition: all 0.1s;
}

.action-btn:hover {
    background: var(--accent-emerald);
    color: var(--text-primary);
}

.approval-odds {
    margin-top: 12px;
}

.odds-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--text-primary);
    margin: 4px 0;
}

.odds-fill {
    height: 100%;
}

.odds-value {
    font-size: 0.75rem;
    font-weight: 700;
}

/* ==========================================
   Sync Progress Bar (Injected via JS)
   ========================================== */

.sync-progress-container {
    background: transparent;
    color: var(--accent-emerald);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 2px;
    font-size: 0.6rem;
    height: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

.sync-progress-container.active {
    height: 24px;
    margin-top: 4px;
}

.sync-track {
    width: 60px;
    height: 2px;
    background: var(--bg-secondary);
    border-radius: 1px;
    overflow: hidden;
}

.sync-status-text {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-muted);
    font-weight: 500;
}

.sync-count {
    color: var(--text-muted);
    min-width: 30px;
    text-align: right;
}

.sync-fill {
    height: 100%;
    background: var(--accent-emerald);
    transition: width 0.3s ease;
}

.sync-icon-small {
    color: var(--accent-emerald);
    display: flex;
    align-items: center;
}

/* ==========================================
   Footer
   ========================================== */

.footer {
    margin-top: var(--spacing-lg);
    border-top: var(--border-width) solid var(--text-primary);
    padding: var(--spacing-md) 0;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--spacing-md);
}

/* ==========================================
   Animations
   ========================================== */

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.spin {
    animation: spin 2s linear infinite;
}

.pulse {
    width: 8px;
    height: 8px;
    background: white;
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 1);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(255, 255, 255, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
    }
}

/* Today's Approval Highlight */
@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 4px 4px 0px 0px var(--accent-emerald), 0 0 0 0 rgba(16, 185, 129, 0.6);
    }

    50% {
        box-shadow: 4px 4px 0px 0px var(--accent-emerald), 0 0 20px 4px rgba(16, 185, 129, 0.4);
    }
}

.application-card.today-approved {
    border-color: var(--accent-emerald);
    box-shadow: 4px 4px 0px 0px var(--accent-emerald);
    animation: pulse-glow 2s ease-in-out infinite;
    position: relative;
}

.status-badge.today-passed {
    background: linear-gradient(135deg, var(--accent-emerald) 0%, #059669 100%);
    color: white;
    font-weight: 800;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    body {
        padding: var(--spacing-md);
    }

    .header-content {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 1.5rem;
    }

    .logo-section {
        flex-direction: column;
        gap: 12px;
    }

    .header-right {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        padding-top: 1.25rem;
        border-top: 1px dashed var(--bg-tertiary);
    }

    .header-info-block {
        align-items: center;
        width: 100%;
    }

    .header-top-row {
        justify-content: center;
        width: 100%;
    }

    .last-updated {
        justify-content: center;
        width: 100%;
    }

    .sync-progress-container {
        justify-content: center;
        width: 100%;
    }

    .filters-container {
        flex-direction: column;
        gap: 12px;
    }

    .filter-buttons {
        justify-content: center;
        flex-wrap: wrap;
    }

    .search-box {
        margin-left: 0;
        width: 100%;
        min-width: 0;
    }
}

@media (max-width: 480px) {
    .logo-text h1 {
        font-size: 1.5rem;
    }

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

    .header-top-row {
        flex-wrap: wrap;
        gap: 8px;
    }
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 48px;
    height: 48px;
    background: var(--text-primary);
    color: var(--accent-emerald);
    border: var(--border-width) solid var(--text-primary);
    box-shadow: var(--hard-shadow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    background: var(--accent-emerald);
    color: var(--text-primary);
    transform: translateY(-3px);
    box-shadow: var(--hard-shadow-hover);
}

.back-to-top svg {
    width: 24px;
    height: 24px;
}

/* ==========================================
   Charts Section
   ========================================== */

.charts-section {
    margin-bottom: var(--spacing-lg);
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: var(--spacing-lg);
}

.chart-card {
    background: white;
    border: var(--border-width) solid var(--text-primary);
    padding: var(--spacing-md);
    box-shadow: var(--hard-shadow);
}

.chart-title {
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: var(--spacing-md);
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--text-muted);
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

.chart-container canvas {
    max-width: 100%;
    max-height: 100%;
}

@media (max-width: 768px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }

    .chart-container {
        height: 250px;
    }
}