/* Lock the screen to prevent mobile bounce and dragging */
html, body {
    overscroll-behavior: none; /* Stops the pull-to-refresh bounce */
    overflow-x: hidden; /* Stops any side-to-side wiggling */
    width: 100vw;
    position: relative;
}

/* Modern iOS Dark Theme Palette */
:root {
    --bg-base: #000000;
    --bg-panel: #1c1c1e;
    --bg-card: #2c2c2e;
    --text-main: #ffffff;
    --text-secondary: #8e8e93;
    --gold: #d4af37;
    --ios-red: #ff453a;
    --ios-green: #32d74b;
    --ios-red-dark: #5c1b1b;
    --ios-green-dark: #1b4d25;
    --mode-blue: #0a84ff;
    
    /* Dynamic Button Variables */
    --btn-bg: rgba(44, 44, 46, 0.65); /* Default Fallback */
    --btn-text: #ffffff;
}

/* Base Layout & Typography */
body { 
    margin: 0; padding: 0; 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; 
    -webkit-font-smoothing: antialiased;
    background-color: var(--bg-base); color: var(--text-main); 
    display: flex; height: 100vh; flex-direction: column; 
}

/* App Wrapper to hold charts and sidebar under the banner */
#app-container {
    display: flex; flex-direction: row; flex: 1; min-height: 0; width: 100%;
}

/* Sidebar & Chart Responsiveness */
#chart-container { flex: 3; height: 100%; border-right: 1px solid #333; display: flex; flex-direction: column; }
.chart-top { flex: 1; width: 100%; position: relative; min-height: 0; }
.chart-bottom { height: 280px; width: 100%; border-top: 1px solid #333; background-color: var(--bg-base); display: flex; flex-direction: column; }

#side-panel { flex: 1; padding: 24px; display: flex; flex-direction: column; background-color: var(--bg-panel); overflow-y: auto; position: relative; }

@media (max-width: 1024px) {
    #app-container { flex-direction: column; height: auto; }
    #chart-container { height: 85vh; width: 100%; border-right: none; border-bottom: 1px solid #333; }
    #side-panel { width: auto; height: auto; padding: 20px; }
    .chart-bottom { height: 250px; }
}

/* Live Viewers Sidebar Badge */
#live-viewers-badge {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--bg-card);
    border: 1px solid #333;
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 10;
}

.live-dot {
    width: 8px;
    height: 8px;
    background-color: var(--ios-green);
    border-radius: 50%;
    animation: pulseDot 2s infinite ease-in-out;
}

/* Branding and Headers */
h2 { margin-top: 15px; color: var(--gold); border-bottom: 1px solid #38383a; padding-bottom: 12px; text-align: center; margin-bottom: 15px; font-weight: 600; }
.panel-description { font-size: 13px; color: var(--text-secondary); text-align: center; margin-bottom: 8px; line-height: 1.5; padding: 0 10px; }
.branding-text { font-size: 14px; color: var(--gold); text-align: center; margin-bottom: 24px; font-style: italic; font-weight: 600; }
.news-header { color: var(--text-main); font-size: 13px; font-weight: 600; padding: 8px 15px; border-bottom: 1px solid #333; background: var(--bg-panel); text-transform: uppercase; letter-spacing: 0.5px; }

/* =========================================
   APPLE HIG BUTTON OVERHAUL (GLASS & DEPTH)
   ========================================= */

.top-buttons { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 12px; 
    margin-bottom: 24px; 
}

.ios-btn { 
    width: 100%; 
    box-sizing: border-box; 
    background-color: var(--btn-bg); /* LISTENS TO ADMIN PANEL NOW */
    backdrop-filter: blur(15px); /* Frosted Glass */
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.08); /* Shiny top rim */
    padding: 14px 12px; /* Thicker tap target */
    border-radius: 14px; /* Apple Squircle */
    color: var(--btn-text); 
    cursor: pointer; 
    font-size: 14px; 
    font-weight: 600; 
    letter-spacing: -0.01em;
    transition: all 0.25s cubic-bezier(0.25, 0.1, 0.25, 1); /* Physical spring feel */
    box-shadow: 0 4px 12px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.05); /* Environmental depth */
}

/* The satisfying tactile press animation */
.ios-btn:active {
    transform: scale(0.96);
    box-shadow: 0 2px 6px rgba(0,0,0,0.1), inset 0 1px 0 rgba(255,255,255,0.02);
}

#info-btn { color: var(--gold); }
#sound-btn.sound-on { color: var(--ios-green); background-color: rgba(50, 215, 75, 0.15); border-color: rgba(50, 215, 75, 0.3); }

#mode-btn { border: 1px solid rgba(255, 255, 255, 0.1); }
#mode-btn.mode-scalp { color: var(--mode-blue); background-color: rgba(10, 132, 255, 0.15); border-color: rgba(10, 132, 255, 0.4); }

/* Asset Toggle Bounce Physics */
.asset-toggle button {
    transition: all 0.25s cubic-bezier(0.25, 0.1, 0.25, 1) !important;
}
.asset-toggle button:active {
    transform: scale(0.96);
}

/* Tooltip Styling */
.tooltip-container { 
    position: relative; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    width: 100%; 
}
.tooltip-text { visibility: hidden; width: 220px; background-color: rgba(28, 28, 30, 0.95); color: #fff; text-align: center; border-radius: 12px; padding: 12px; position: absolute; z-index: 100; bottom: 130%; left: 50%; transform: translateX(-50%); opacity: 0; transition: opacity 0.3s, visibility 0.3s; font-size: 12px; font-weight: normal; border: 1px solid #444; box-shadow: 0 10px 30px rgba(0,0,0,0.5); pointer-events: none; }
.tooltip-text::after { content: ""; position: absolute; top: 100%; left: 50%; margin-left: -6px; border-width: 6px; border-style: solid; border-color: rgba(28, 28, 30, 0.95) transparent transparent transparent; }
.tooltip-container:hover .tooltip-text { visibility: visible; opacity: 1; }

/* Market Sessions Clocks (Upgraded 2x2 Grid with Live Analog Clocks) */
.sessions-container { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 12px; 
    margin-bottom: 24px; 
}

.session { 
    display: flex; 
    align-items: center; 
    gap: 12px; 
    background: var(--bg-card); 
    padding: 14px 16px; 
    border-radius: 14px; 
    font-size: 13px; 
    font-weight: 600; 
    color: var(--text-secondary); 
    transition: all 0.3s ease; 
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border: 1px solid #333;
}

.session.active { 
    color: var(--text-main); 
    border-color: rgba(50, 215, 75, 0.4);
    background: linear-gradient(145deg, var(--bg-card) 0%, rgba(50, 215, 75, 0.08) 100%);
}

/* The Live Analog Clock Faces */
.clock {
    width: 28px;
    height: 28px;
    border: 2px solid #444;
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
    background: var(--bg-base);
    transition: all 0.3s;
}

.session.active .clock {
    border-color: var(--ios-green);
    box-shadow: 0 0 10px rgba(50, 215, 75, 0.4);
}

.hand {
    position: absolute;
    bottom: 50%;
    left: 50%;
    transform-origin: bottom center;
    background: #8e8e93;
    border-radius: 4px;
    transition: transform 0.05s linear;
}

.session.active .hand {
    background: var(--text-main);
}

.hour-hand {
    width: 2px;
    height: 30%;
    margin-left: -1px; /* Perfectly centers the width */
}

.min-hand {
    width: 1.5px;
    height: 40%;
    margin-left: -0.75px; /* Perfectly centers the width */
}

/* The Gold center pin of the clock */
.clock::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 4px;
    background: var(--gold);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.session-info { 
    display: flex; 
    flex-direction: column; 
    line-height: 1.3; 
}

.session-time { 
    font-size: 11px; 
    font-weight: 500; 
    opacity: 0.8; 
    margin-top: 3px; 
    font-family: 'Courier New', Courier, monospace; 
    letter-spacing: 0.5px;
}

#live-price-display { text-align: center; font-size: 38px; color: var(--gold); font-weight: 700; margin-bottom: 30px; letter-spacing: 1px; }

/* Level Widgets & Granular Bells */
.level-box { 
    background: var(--bg-card); padding: 16px; margin-bottom: 12px; 
    border-radius: 14px; text-align: center; box-shadow: 0 4px 12px rgba(0,0,0,0.2); 
    transition: background-color 0.4s ease; 
}
.res { border-left: 5px solid var(--ios-red); }
.sup { border-left: 5px solid var(--ios-green); }
.level-header { display: flex; justify-content: center; align-items: center; position: relative; margin-bottom: 6px; }
.level-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.bell-btn { position: absolute; right: 0; cursor: pointer; font-size: 16px; opacity: 0.3; transition: all 0.2s; user-select: none; }
.bell-btn.active { opacity: 1; filter: drop-shadow(0 0 4px rgba(212, 175, 55, 0.5)); }
.price-text { font-size: 24px; font-weight: 700; }

/* Beginner Hints */
.beginner-hint { font-size: 11px; margin-top: 6px; font-style: italic; letter-spacing: 0.5px; opacity: 0.8; }
.res .beginner-hint { color: #ff8a84; }
.sup .beginner-hint { color: #7de88e; }

/* Secondary Actions */
#toggle-extreme-btn { 
    background-color: rgba(212, 175, 55, 0.15); 
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--gold); 
    border: 1px solid rgba(212, 175, 55, 0.3); 
    padding: 14px; 
    border-radius: 14px; 
    font-weight: 600; 
    font-size: 14px;
    cursor: pointer; 
    width: 100%; 
    margin-bottom: 20px; 
    transition: all 0.25s cubic-bezier(0.25, 0.1, 0.25, 1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
#toggle-extreme-btn:active {
    transform: scale(0.96);
    background-color: rgba(212, 175, 55, 0.25);
}

.section-header { color: var(--text-main); text-align: center; font-size: 14px; margin-top: 24px; border-bottom: 1px solid #333; padding-bottom: 10px; margin-bottom: 15px; }
#last-updated { font-size: 11px; color: var(--text-secondary); text-align: center; margin-top: 24px; padding-bottom: 40px; text-transform: uppercase; }
.error-text { color: var(--ios-red) !important; font-weight: bold; }

/* Animations */
@keyframes pulseRed { 0% { background-color: var(--bg-card); } 50% { background-color: var(--ios-red-dark); } 100% { background-color: var(--bg-card); } }
@keyframes pulseGreen { 0% { background-color: var(--bg-card); } 50% { background-color: var(--ios-green-dark); } 100% { background-color: var(--bg-card); } }
@keyframes pulseDot { 0% { box-shadow: 0 0 0 0 rgba(50, 215, 75, 0.7); } 70% { box-shadow: 0 0 0 8px rgba(50, 215, 75, 0); } 100% { box-shadow: 0 0 0 0 rgba(50, 215, 75, 0); } }

.alert-red { animation: pulseRed 2s infinite ease-in-out; }
.alert-green { animation: pulseGreen 2s infinite ease-in-out; }

/* Modal Frosted Glass Upgrade */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.6); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }

.modal-content { 
    background-color: rgba(28, 28, 30, 0.85) !important; 
    backdrop-filter: blur(25px) !important; 
    -webkit-backdrop-filter: blur(25px) !important;
    border-radius: 20px !important; 
    border: 1px solid rgba(255,255,255,0.15) !important; 
    box-shadow: 0 25px 50px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.1) !important; 
    color: var(--text-main); 
}
.close-btn { color: var(--text-secondary); float: right; font-size: 24px; cursor: pointer; font-weight: bold; transition: opacity 0.2s; }
.close-btn:active { opacity: 0.5; }

/* Maintenance Overlay Styling */
.maintenance-overlay {
    display: none; position: fixed; z-index: 99999; top: 0; left: 0; width: 100%; height: 100%;
    background-color: var(--bg-base); flex-direction: column; align-items: center; justify-content: center;
}
.maintenance-content { text-align: center; padding: 40px; }
.maintenance-icon { font-size: 80px; margin-bottom: 20px; animation: spin 4s linear infinite; }
@keyframes spin { 100% { transform: rotate(360deg); } }
.maintenance-content h1 { color: var(--gold); margin-bottom: 10px; font-size: 32px; }
.maintenance-content p { color: var(--text-secondary); font-size: 16px; max-width: 400px; line-height: 1.5; margin: 0 auto; }

/* Contact Form Styles */
.contact-form { display: flex; flex-direction: column; gap: 15px; margin-top: 15px; }
.contact-input { background: var(--bg-base); border: 1px solid #444; color: white; padding: 14px; border-radius: 12px; font-size: 14px; font-family: inherit; transition: border-color 0.3s; }
.contact-input:focus { outline: none; border-color: var(--gold); }
textarea.contact-input { resize: vertical; min-height: 100px; }

/* Submit Action Buttons */
.contact-submit, .acknowledge-btn { 
    background: var(--gold); 
    color: #000; 
    border: none; 
    padding: 14px 24px; 
    border-radius: 14px; 
    font-weight: 700; 
    font-size: 15px; 
    cursor: pointer; 
    transition: all 0.25s cubic-bezier(0.25, 0.1, 0.25, 1);
    box-shadow: 0 4px 14px rgba(212, 175, 55, 0.3);
    width: 100%;
}
.contact-submit:active, .acknowledge-btn:active { 
    transform: scale(0.96); 
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.15);
}
.contact-submit:disabled { opacity: 0.5; cursor: not-allowed; transform: scale(1); }
.contact-status { font-size: 14px; font-weight: 600; text-align: center; display: none; margin-top: 10px; }
.status-success { color: var(--ios-green); display: block; }
.status-error { color: var(--ios-red); display: block; }


/* =========================================
   MOBILE HAMBURGER MENU (Phones & Tablets)
   ========================================= */

/* Hide mobile elements on Desktop */
#mobile-top-bar, #mobile-close-btn, #menu-overlay {
    display: none;
}

@media (max-width: 768px) {
    /* The Top Navigation Bar */
    #mobile-top-bar {
        display: flex;
        justify-content: space-between;
        align-items: center;
        background: rgba(28, 28, 30, 0.85);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        padding: 12px 15px;
        border-bottom: 1px solid rgba(255,255,255,0.08);
        position: fixed;
        top: 0; left: 0; right: 0;
        z-index: 1000;
    }

    #mobile-top-bar .brand {
        color: var(--gold);
        font-weight: 700;
        font-size: 16px;
        letter-spacing: 0.5px;
    }

    .hamburger-btn {
        background: rgba(10, 132, 255, 0.15);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        color: var(--mode-blue);
        border: 1px solid rgba(10, 132, 255, 0.3);
        padding: 8px 14px;
        border-radius: 10px;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        transition: all 0.25s cubic-bezier(0.25, 0.1, 0.25, 1);
    }
    .hamburger-btn:active {
        transform: scale(0.92);
        background: rgba(10, 132, 255, 0.25);
    }

    /* Push the main app down so it doesn't hide under the top bar */
    #app-container {
        margin-top: 55px; 
        display: flex;
        flex-direction: column;
    }

    /* Force the Charts to look good on mobile */
    .chart-top {
        height: 50vh !important;
    }
    .chart-bottom {
        height: 450px !important;
        margin-top: 15px;
    }

    /* The Side Panel (Now a Slide-Out Drawer) */
    #side-panel {
        position: fixed;
        top: 0;
        right: -100%; 
        width: 85%;
        max-width: 380px;
        height: 100vh;
        z-index: 9999;
        /* Solid dark background so the chart does NOT bleed through */
        background-color: #121212 !important; 
        border-left: 1px solid #333;
        box-shadow: -10px 0 30px rgba(0,0,0,0.9);
        transition: right 0.3s cubic-bezier(0.4, 0.0, 0.2, 1); 
        padding: 20px;
        padding-top: 70px; 
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    #side-panel.open {
        right: 0;
    }

    /* Move the Viewer Badge to the Top-Left to avoid the Close button */
    #live-viewers-badge {
        position: absolute !important;
        top: 20px !important;
        left: 20px !important; 
        right: auto !important; 
        margin: 0 !important;
    }

    /* The Close 'X' Button inside the drawer */
    #mobile-close-btn {
        display: block;
        position: absolute;
        top: 15px;
        right: 15px;
        background: rgba(255, 255, 255, 0.1);
        border: none;
        color: #fff;
        font-size: 24px;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        cursor: pointer;
        line-height: 1;
        text-align: center;
        padding: 0;
        transition: transform 0.2s;
    }
    #mobile-close-btn:active {
        transform: scale(0.9);
        background: rgba(255, 255, 255, 0.2);
    }

    /* The Dark Overlay Background */
    #menu-overlay {
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        /* Darkened from 0.7 to 0.85 opacity with a stronger blur */
        background: rgba(0,0,0,0.85);
        backdrop-filter: blur(4px); 
        z-index: 9998;
        opacity: 0;
        pointer-events: none; 
        transition: opacity 0.3s ease;
    }

    #menu-overlay.open {
        display: block;
        opacity: 1;
        pointer-events: auto; 
    }
}

/* =========================================
   BUTTON ICON STANDARDIZATION
   ========================================= */

.ios-btn, .asset-toggle button {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
}

/* Primary Icons (Left) */
.btn-icon {
    position: absolute;
    left: 16px;
    font-size: 18px; /* Larger and easier to see */
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3)); /* Helps them pop off any background color */
}

/* Tooltip Icons (Right) */
.btn-info-icon {
    position: absolute;
    right: 14px;
    font-size: 11px;
    font-weight: bold;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 20px; 
    height: 20px;
    display: flex; 
    align-items: center; 
    justify-content: center;
    line-height: 1;
}

/* =========================================
   MOBILE MENU LAYERING & BOUNCE FIX
   ========================================= */

/* 1. Stop the rubber-band bounce effect on the main page */
body.menu-open, 
html.menu-open {
    overscroll-behavior-y: none !important;
}

/* 2. Force the side menu to sit ABOVE the mobile header */
#side-panel, 
.admin-sidebar, 
#sidebar {
    z-index: 999999 !important; /* Forces it to the absolute top layer */
    overscroll-behavior-y: contain !important; /* Traps the scrolling inside the menu */
}

/* 3. Ensure the mobile top bar stays underneath the menu */
#mobile-top-bar, 
.admin-header {
    z-index: 9000 !important; /* Lower than the sidebar's 999999 */
}

/* ==========================================
   SECURE NATIVE CHAT BUBBLE STYLES
   ========================================== */

.chat-msg-row { display: flex; flex-direction: column; align-items: flex-start; margin-bottom: 2px; }
.chat-msg-header { font-size: 10px; color: var(--gold); margin-left: 12px; margin-bottom: 2px; font-weight: bold; text-transform: uppercase; letter-spacing: 0.5px; }
.chat-msg-bubble { background: rgba(255, 255, 255, 0.08); padding: 8px 14px; border-radius: 18px; border-bottom-left-radius: 4px; color: #eee; width: fit-content; max-width: 85%; line-height: 1.4; font-size: 13px; border: 1px solid rgba(255,255,255,0.05); }

.chat-msg-row.self { align-items: flex-end; }
.chat-msg-row.self .chat-msg-header { display: none; }
.chat-msg-row.self .chat-msg-bubble { background: linear-gradient(135deg, #007aff 0%, #0056b3 100%); color: #fff; border-bottom-left-radius: 18px; border-bottom-right-radius: 4px; border: none; box-shadow: 0 4px 12px rgba(0, 122, 255, 0.2); }

#chat-messages-area::-webkit-scrollbar { width: 4px; }
#chat-messages-area::-webkit-scrollbar-track { background: transparent; }
#chat-messages-area::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }

#chat-module-container { border: 2px solid #ff453a !important; }