/* =========================================
   CORE CONFIGURATION & FLUID ROOT VARIABLES
   ========================================= */
:root {
    --bg-color: #000000;
    --text-color: #ffffff;
    --border-color: #1a1a1a;
    --accent-color: #888888;
    
    /* Fluid typography and spacing baselines across viewports */
    --base-font-size: clamp(11px, 0.35vw + 10px, 14px);
    --title-font-size: clamp(13px, 0.5vw + 12px, 18px);
    --toolbar-padding: clamp(8px, 1vw + 5px, 15px);
    --toolbar-gap: clamp(10px, 1vw + 5px, 20px);
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100dvh; 
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: 0;
    font-size: var(--base-font-size);
}

/* =========================================
   HEADER & NAVIGATION BRANDING
   ========================================= */
#brand-logo {
    height: 32px;
    width: auto;
    border-radius: 4px;
    margin-right: 2px;
    object-fit: contain;
    display: block;
    filter: none !important;
    background-color: transparent !important;
    color: initial !important;
    border: none !important;
}

/* =========================================
   TOOLBAR & INTERACTIVE BUTTONS
   ========================================= */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: var(--toolbar-padding);
    border-bottom: 1px solid var(--border-color);
    gap: var(--toolbar-gap);
    position: relative; 
    z-index: 1000;
    background-color: var(--bg-color);
}

.tool-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--accent-color);
    width: 32px;
    height: 32px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
    position: relative;
}

.tool-btn:hover {
    background: var(--border-color);
    color: var(--text-color);
}

.tool-btn.active {
    background: var(--text-color);
    color: var(--bg-color);
    border-color: var(--text-color);
}

/* =========================================
   CUSTOM DROPDOWN SUB-SYSTEM
   ========================================= */
.custom-dropdown {
    position: relative;
    cursor: pointer;
    user-select: none;
    width: max-content;
}

.dropdown-selected {
    border: 1px solid var(--border-color);
    padding: 5px 15px;
    background: var(--bg-color);
    white-space: nowrap;
    font-size: clamp(11px, 0.25vw + 10px, 13px);
}

.dropdown-options {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 100%;
    width: max-content;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    list-style: none;
    z-index: 2000;
    max-height: 300px;
    overflow-y: auto;
}

.dropdown-options::-webkit-scrollbar { width: 6px; }
.dropdown-options::-webkit-scrollbar-track { background: var(--bg-color); }
.dropdown-options::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
.dropdown-options::-webkit-scrollbar-thumb:hover { background: var(--accent-color); }

.custom-dropdown.active .dropdown-options { 
    display: block; 
}

.dropdown-options li {
    padding: 8px 15px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    font-size: clamp(11px, 0.25vw + 10px, 13px);
}

.dropdown-options li:hover { 
    background: var(--text-color); 
    color: var(--bg-color); 
}

.api-status { 
    font-size: clamp(10px, 0.2vw + 9px, 12px); 
    color: #00b894; 
    font-weight: bold;
}

/* =========================================
   CORE GRAPHICS / CANVAS UTILITIES
   ========================================= */
.chart-container {
    position: relative;
    flex: 1;
    width: 100%;
    min-height: 0;
    overflow: hidden;
}

canvas {
    display: block;
    position: absolute; 
    top: 0; left: 0;
    width: 100%; height: 100%;
}

.spinner-container {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-color);
    display: flex;
    justify-content: center; align-items: center;
    z-index: 50;
}

.spinner-container.hidden { display: none; }

.spinner {
    width: 35px; height: 35px;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--text-color);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* =========================================
   REAL-TIME NOTIFICATION FEEDS
   ========================================= */
.notification-trigger-wrapper { position: relative; margin-right: auto; }

.badge {
    position: absolute; top: -4px; right: -4px;
    background: #d63031;
    color: #ffffff;
    font-size: 9px; font-weight: bold;
    padding: 2px 5px; border-radius: 50%;
    border: 1px solid var(--bg-color);
}

.badge.hidden { display: none; }

.notif-widget {
    position: absolute; 
    top: 60px; 
    left: 15px;
    width: 320px; 
    max-height: 450px;
    background: rgba(10, 10, 10, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    display: flex; flex-direction: column;
    z-index: 3000;
    box-shadow: 0 10px 30px rgba(0,0,0,0.7);
    backdrop-filter: blur(10px);
}

#notification-widget {
    font-family: 'Courier New', monospace;
    border: 1px solid #333;
    background: #0a0a0a;
}

.notif-widget.hidden { display: none; }

.notif-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
}

.notif-header h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: #888888; }

#notif-clear-all {
    background: transparent; border: none; color: #666666;
    font-size: 10px; cursor: pointer;
}

#notif-clear-all:hover { color: var(--text-color); }

.notif-feed { overflow-y: auto; flex: 1; padding: 5px 0; }

.notif-empty-state { padding: 20px; text-align: center; color: #444444; font-size: 11px; }

.notif-item {
    padding: 10px 14px;
    border-bottom: 1px solid #1a1a1a;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.notif-meta {
    display: flex;
    justify-content: space-between;
    font-size: 8px;
    color: #666;
    letter-spacing: 0.5px;
}

.notif-source { font-weight: bold; text-transform: uppercase; }
.notif-time { color: #555555; }
.teleport-hint { font-size: 7px; color: #333; text-transform: uppercase; }
.notif-msg { font-size: 11px; color: #e0e0e0; }

.notif-item.high .notif-source { color: #d63031; }
.notif-item.medium .notif-source { color: #fdcb6e; }
.notif-item.low .notif-source { color: #00b894; }

@keyframes slideIn {
    from { transform: translateX(-10px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.notif-item.signal-gold {
    border-left: 3px solid #ffcc00;
    background: rgba(255, 204, 0, 0.05);
}

.notif-item.signal-gold .notif-source { color: #ffd700; font-weight: bold; }
.notif-item.signal-gold .notif-msg { color: #fffacd; }

/* =========================================
   MODAL BACKDROP & INTERFACE CONTENT
   ========================================= */
#bnw-modal-backdrop {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

#bnw-modal {
    position: fixed;
    top: 10%; 
    left: 5%;
    width: 90%;
    height: 80%; 
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    transform: translateY(-120%);
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 20px 50px rgba(0,0,0,0.8);
}

#bnw-modal-backdrop.active { opacity: 1; pointer-events: all; }
#bnw-modal.active { transform: translateY(0); }

.bnw-modal-header {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
    font-size: clamp(9px, 0.2vw + 8px, 11px);
    color: var(--accent-color);
    background: rgba(10, 10, 10, 0.9);
    line-height: 1.4;
    text-transform: uppercase;
}

.bnw-modal-logo {
    height: clamp(36px, 2vw + 24px, 48px);
    width: auto;
    display: block;
    margin: 0 auto 10px auto;
    object-fit: contain;
    border-radius: 4px;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.1));
}

.bnw-modal-content {
    flex: 1;
    overflow-y: auto;
    padding: clamp(12px, 2vw + 10px, 24px);
    font-size: clamp(11px, 0.35vw + 10px, 13px);
    color: #d0d0d0;
    line-height: 1.6;
}

.bnw-modal-content::-webkit-scrollbar { width: 4px; }
.bnw-modal-content::-webkit-scrollbar-track { background: transparent; }
.bnw-modal-content::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }

.bnw-modal-footer {
    padding: 15px;
    border-top: 1px solid var(--border-color);
    background: linear-gradient(to top, var(--bg-color) 80%, transparent);
    display: flex; justify-content: center; align-items: center;
}

.sleek-close-btn {
    background: var(--border-color);
    color: var(--accent-color);
    border: none;
    padding: 12px 0;
    border-radius: 20px;
    font-size: 10px; font-weight: bold; letter-spacing: 1px;
    cursor: pointer;
    width: 60%; max-width: 250px;
    transition: all 0.2s ease;
}

.sleek-close-btn:hover, .sleek-close-btn:active {
    background: var(--text-color);
    color: var(--bg-color);
}

/* =========================================
   PREMIUM PORTAL GATEWAY (PAYWALL)
   ========================================= */
#paywall-backdrop {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.96);
    z-index: 99998;
    backdrop-filter: blur(8px);
}

#paywall-modal {
    display: none;
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 92%; max-width: 420px;
    background: #000000;
    border: 1px solid #1a1a1a;
    border-radius: 6px;
    z-index: 99999;
    font-family: monospace;
    color: #ffffff;
    padding: 22px;
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.03);
    flex-direction: column;
    gap: 15px;
}

.paywall-title {
    font-size: var(--title-font-size);
    letter-spacing: 1.5px;
    text-align: center;
    border-bottom: 1px solid #1a1a1a;
    padding-bottom: 10px;
    color: #ffffff;
    font-weight: bold;
}

.plan-card {
    background: #050505;
    border: 1px solid #1a1a1a;
    padding: 12px 16px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    justify-content: space-between; align-items: center;
    transition: all 0.2s ease;
}

.plan-card:hover {
    border-color: #555555;
    background: #0a0a0a;
}

.plan-name { font-size: 12px; font-weight: bold; color: #ffffff; }
.plan-meta { font-size: 10px; color: #888888; }
.plan-price { font-size: 13px; font-weight: bold; color: #ffffff; }

.bnw-premium-badge {
    background: #ffffff !important;
    color: #000000 !important;
    font-family: monospace; font-weight: bold; font-size: 10px;
    padding: 2px 6px; border-radius: 0px; letter-spacing: 0.5px;
    display: inline-block; white-space: nowrap;
}

.circle-timer-svg { transform: rotate(-90deg); }
.circle-timer-bg { fill: none; stroke: #111111; stroke-width: 4; }
.circle-timer-progress { fill: none; stroke: #ffffff; stroke-width: 4; transition: stroke-dashoffset 1s linear; }

.paywall-input {
    background: #000000;
    border: 1px solid #222222;
    color: #ffffff;
    font-family: monospace; font-size: 12px;
    padding: 8px; text-align: center; width: 100%; outline: none;
    text-transform: lowercase;
}

.paywall-input:focus { border-color: #555555; }

/* =========================================
   PWA INSTALL INTERFACE BANNER
   ========================================= */
#pwa-install-banner {
    position: fixed;
    bottom: 20px; left: 50%;
    transform: translateX(-50%);
    width: 90%; max-width: 400px;
    background: rgba(10, 10, 10, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    z-index: 100000;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    backdrop-filter: blur(10px);
    display: flex; flex-direction: column; gap: 12px;
}

#pwa-install-banner.hidden { display: none; }
.pwa-banner-content { display: flex; align-items: center; gap: 12px; }
.pwa-logo { width: 40px; height: 40px; border-radius: 8px; }
.pwa-text h4 { font-size: 13px; color: var(--text-color); margin-bottom: 4px; }
.pwa-text p { font-size: 10px; color: var(--accent-color); line-height: 1.3; }
.pwa-actions { display: flex; gap: 10px; }

.pwa-btn-primary {
    flex: 1; background: var(--text-color); color: var(--bg-color);
    border: none; padding: 8px; border-radius: 4px; font-weight: bold; font-size: 11px; cursor: pointer;
}

.pwa-btn-secondary {
    flex: 1; background: transparent; color: var(--accent-color);
    border: 1px solid var(--border-color); padding: 8px; border-radius: 4px; font-size: 11px; cursor: pointer;
}

#pwa-ios-instructions {
    background: #1a1a1a;
    padding: 10px;
    border-radius: 4px;
    font-size: 10px;
    color: #ffcc00;
    text-align: center;
}

/* =========================================
   BREAKPOINT OVERRIDES (MEDIA QUERIES)
   ========================================= */

/* Mobile Displays */
@media (max-width: 600px) {
    .toolbar {
        padding: 8px 10px;
        gap: 10px;
    }

    .notif-widget {
        width: calc(100% - 20px);
        left: 10px;
        right: 10px;
        top: 55px;
        max-height: 70dvh;
    }

    #bnw-modal {
        width: 96%;
        height: 90%;
        left: 2%;
        top: 5%;
    }

    .sleek-close-btn {
        width: 80%;
    }
}

/* Tablet Layouts */
@media (min-width: 601px) and (max-width: 1024px) {
    #bnw-modal {
        width: 80%;
        height: 75%;
        left: 10%;
        top: 12.5%;
    }
}

/* Desktop Setups */
@media (min-width: 1025px) {
    #bnw-modal {
        width: 60%;
        max-width: 800px;
        height: 70%;
        left: 50%;
        top: 15%;
        transform: translate(-50%, -150%);
        transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    }

    #bnw-modal.active {
        transform: translate(-50%, 0);
    }
}

/* 4K Ultra-HD Displays */
@media (min-width: 2560px) {
    :root {
        --base-font-size: 20px;
        --title-font-size: 28px;
        --toolbar-padding: 24px;
        --toolbar-gap: 30px;
    }

    #brand-logo {
        height: 48px;
    }

    .tool-btn {
        width: 48px;
        height: 48px;
        font-size: 22px;
    }

    .notif-widget {
        width: 450px;
        max-height: 650px;
        top: 90px;
    }

    #bnw-modal {
        max-width: 1400px;
        height: 65%;
    }
}
