/* style.css */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&family=JetBrains+Mono:wght@400;700&display=swap');

:root {
    --bg-main: #0b0e14;
    --bg-sidebar: #11141b;
    --bg-card: #161b22;
    --accent-primary: #3b82f6;
    --accent-gold: #f2a900;
    --border-soft: rgba(255, 255, 255, 0.06);
    --text-main: #e6edf3;
    --text-muted: #7d8590;

    /* Mobile-specific tokens */
    --sidebar-width: 220px;
    --hamburger-size: 44px;
    --topbar-height: 56px;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
}

/* ─── SIDEBAR ────────────────────────────────────────────────────────────────── */

.sidebar {
    background-color: var(--bg-sidebar) !important;
    border-right: 1px solid var(--border-soft);
}

.btn-side {
    width: 100%; padding: 10px 14px; margin-bottom: 4px;
    border-radius: 8px; font-size: 11px; font-weight: 600;
    color: var(--text-muted); transition: all 0.2s ease;
    display: flex; align-items: center; gap: 10px;
}

.btn-side:hover {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-primary);
}

.btn-side.active {
    background: rgba(59, 130, 246, 0.15);
    color: white;
    box-shadow: inset 3px 0 0 var(--accent-primary);
}

/* ─── CARDS ──────────────────────────────────────────────────────────────────── */

.bg-card-modern {
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    transition: border-color 0.3s ease;
}

.bg-card-modern:hover {
    border-color: rgba(59, 130, 246, 0.4);
}

.font-data { font-family: 'JetBrains Mono', monospace; }

/* ─── TOOLTIP ────────────────────────────────────────────────────────────────── */

#custom-tooltip {
    backdrop-filter: blur(10px);
    background: rgba(11, 14, 20, 0.9) !important;
    border: 1px solid var(--border-soft) !important;
    border-radius: 10px !important;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5) !important;
}

/* ─── SCROLLBAR ──────────────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-thumb { background: #30363d; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-primary); }

/* ─── LOGO ───────────────────────────────────────────────────────────────────── */

.logo-link {
    text-decoration: none;
    display: inline-block;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.logo-link:hover {
    opacity: 0.8;
    transform: translateY(-1px);
}

/* ══════════════════════════════════════════════════════════════════════════════
   MOBILE — Hamburger Button
   Injected by mobile.js when is-mobile class is present on <html>
══════════════════════════════════════════════════════════════════════════════ */

#sidebar-toggle {
    display: none; /* Hidden on desktop */
}

.is-mobile #sidebar-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;

    position: fixed;
    top: calc((var(--topbar-height) - var(--hamburger-size)) / 2);
    left: 12px;
    z-index: 1100;

    width: var(--hamburger-size);
    height: var(--hamburger-size);
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    cursor: pointer;
    padding: 0;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.is-mobile #sidebar-toggle:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.4);
}

.ham-line {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text-muted);
    border-radius: 2px;
    transition: transform 0.25s ease, opacity 0.25s ease, background 0.2s ease;
    transform-origin: center;
}

/* Animate to X when open */
#sidebar-toggle.is-open .ham-line:nth-child(1) { transform: translateY(7px) rotate(45deg); background: var(--accent-primary); }
#sidebar-toggle.is-open .ham-line:nth-child(2) { opacity: 0; transform: scaleX(0); }
#sidebar-toggle.is-open .ham-line:nth-child(3) { transform: translateY(-7px) rotate(-45deg); background: var(--accent-primary); }

/* ─── MOBILE — Overlay (dim background when sidebar is open) ─────────────────── */

#sidebar-overlay {
    display: none;
}

.is-mobile #sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.is-mobile #sidebar-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

/* ══════════════════════════════════════════════════════════════════════════════
   MOBILE — Sidebar Slide-in
══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {

    /* ── Sidebar: slide off-screen, animate in on toggle ── */
    .sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        height: 100dvh !important;
        width: var(--sidebar-width) !important;
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
        overflow-x: hidden;
    }

    .sidebar.sidebar-open {
        transform: translateX(0);
    }

    /* ── Main area: full width, space for hamburger ── */
    main {
        margin-left: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        padding: 8px !important;
        padding-top: calc(var(--topbar-height) + 4px) !important;
        overflow-x: hidden !important;
    }

    /* ══════════════════════════════════════════════════
       THE MAIN FIX: Header row + stat boxes
       These IDs are generated by sidebar-component.js.
       Total hardcoded min-width was ~960px — fixed below.
    ══════════════════════════════════════════════════ */

    /* Stack title and stats vertically instead of side-by-side */
    #market-analysis-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
        padding: 0 !important;
        margin-bottom: 10px !important;
    }

    /* Stats row: wrap into a 2-column grid of flexible boxes */
    #stats-container {
        flex-wrap: wrap !important;
        width: 100% !important;
        gap: 6px !important;
        justify-content: flex-start !important;
    }

    /* BTC price box: ~half width */
    #btc-price-box {
        width: auto !important;
        flex: 1 1 calc(50% - 6px) !important;
        min-width: 120px !important;
        height: auto !important;
        min-height: 60px !important;
        padding: 8px !important;
    }

    /* High / Low boxes: each ~quarter width, side by side */
    #btc-high-box,
    #btc-low-box {
        width: auto !important;
        flex: 1 1 calc(25% - 6px) !important;
        min-width: 80px !important;
        height: auto !important;
        min-height: 60px !important;
        padding: 8px !important;
    }

    /* Performance box: full width row */
    #performance-box {
        min-width: 0 !important;
        width: 100% !important;
        flex: 1 1 100% !important;
        height: auto !important;
        min-height: 60px !important;
        padding: 8px !important;
    }

    /* Cycle box: full width, stack its two columns vertically */
    #cycle-box {
        min-width: 0 !important;
        width: 100% !important;
        flex: 1 1 100% !important;
        flex-direction: column !important;
        height: auto !important;
        gap: 8px !important;
        padding: 8px !important;
    }

    /* Cycle box inner divider becomes a horizontal line */
    #cycle-box > div:first-child {
        border-right: none !important;
        border-bottom: 1px solid #30363d !important;
        padding-right: 0 !important;
        padding-bottom: 8px !important;
        width: 100% !important;
    }

    /* Halving timer: keep 4 columns but tighter */
    #halving-timer {
        gap: 4px !important;
    }

    /* ── Chart ── */
    #tradingview_chart {
        height: 55vw !important;
        min-height: 260px !important;
        max-height: 420px !important;
        width: 100% !important;
    }

    /* ── Tooltips: pin to bottom center on mobile ── */
    #custom-tooltip {
        position: fixed !important;
        bottom: 16px !important;
        top: auto !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: calc(100vw - 32px) !important;
        max-width: 360px !important;
    }

    /* ── Tap targets ── */
    .btn-side {
        padding: 13px 14px;
        font-size: 12px;
    }

    /* ── Whale table: hide hash column ── */
    .whale-table th:nth-child(4),
    .whale-table td:nth-child(4) {
        display: none;
    }

    /* ── Misc ── */
    .bg-card-modern { padding: 10px 12px !important; border-radius: 10px; }
    .bg-card-modern:hover { border-color: var(--border-soft); }
    ::-webkit-scrollbar { width: 3px; }
}

/* ─── Very small screens (≤380px) ───────────────────────────────────────────── */
@media (max-width: 380px) {

    /* BTC price box: full width on tiny screens */
    #btc-price-box,
    #btc-high-box,
    #btc-low-box {
        flex: 1 1 calc(33% - 6px) !important;
        min-width: 0 !important;
    }

    #tradingview_chart {
        height: 70vw !important;
        min-height: 240px !important;
    }
}
