/* --- BROADCAST COMMAND V3 --- */

:root {
    --p-blue: #00f3ff;
    --p-orange: #ff7b00;
}

/* GLOBAL RESET & HEIGHT FIXES */
html, body {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden; /* Prevent double scrollbars */
    background: #000;
    font-family: 'Inter', sans-serif;
}

/* WRAPPER FIX FOR RESPONSIVE SCALING */
.nav-bar-wrapper {
    display: flex;
    flex-wrap: wrap; 
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    min-height: 70px;
    height: auto !important;
    position: relative; 
    z-index: 999; 
    margin-top: 35px; /* CLEARS THE TOP TICKER BAR */
    background: rgba(0, 0, 0, 0.85); 
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

/* FLEX SPACER TO PUSH ELEMENTS APART */
.nav-spacer { flex: 1; min-width: 10px; }

/* INDUSTRY SELECTOR RESPONSIVENESS */
.industry-selector-box { flex-shrink: 0; max-width: 100%; z-index: 1000; }

.industry-select {
    background: #000;
    color: var(--p-blue);
    border: 1px solid var(--p-blue);
    padding: 8px 12px;
    font-family: 'JetBrains Mono';
    font-size: 11px;
    text-transform: uppercase;
    outline: none;
    cursor: pointer;
    border-radius: 4px;
}

/* --- BACK BUTTON STYLING --- */
.back-to-engine-btn {
    background: #000; 
    border: 1px solid #ff7b00; 
    color: #ff7b00;
    height: 36px;
    padding: 0 20px;
    margin-right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: 'Chakra Petch';
    font-weight: 800;
    cursor: pointer;
    transition: 0.3s;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 1px;
    white-space: nowrap; 
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.back-to-engine-btn:hover {
    background: #ff7b00;
    color: #000;
    box-shadow: 0 0 20px rgba(255,123,0,0.6);
}

/* --- BROADCAST LAYOUT --- */
/* Fixed-Fluid-Fixed Layout with Independent Scrolling */
.broadcast-layout { 
    position: absolute; /* Lock layout */
    top: 105px; /* Clear Header + Ticker */
    /* DYNAMIC BOTTOM: Fits the flexible nav height */
    bottom: calc(80px + env(safe-area-inset-bottom));
    left: 0; 
    right: 0;
    display: grid; 
    grid-template-columns: 300px 1fr 300px; 
    overflow: hidden; 
    min-height: 0; 
    z-index: 1; /* Ensure this is behind the NAV */
}

/* Columns */
.br-col-side { 
    display: flex; 
    flex-direction: column; 
    background: rgba(0,0,0,0.2); 
    border-right: 1px solid rgba(255,255,255,0.05); 
    overflow-y: auto; /* Enable Scroll */
    min-height: 0;
}

.br-col-main { 
    position: relative; 
    display: flex; 
    flex-direction: column; 
    background: radial-gradient(circle at center, #111 0%, #000 100%); 
    overflow: hidden; /* Main col doesn't scroll, children do */
    min-height: 0;
}

/* ENGINE WINDOW POCKET - Now Integrated */
.engine-window-pocket {
    margin: 15px;
    height: 200px;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(0, 243, 255, 0.2) !important;
    background: #050505 !important;
    box-shadow: inset 0 0 40px rgba(0,0,0,1);
    flex-shrink: 0; 
    display: flex;
    flex-direction: column;
}

.window-frame-glare {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(135deg, rgba(255,255,255,0.05) 0%, transparent 40%, transparent 60%, rgba(255,255,255,0.02) 100%);
    z-index: 5;
}

.window-label {
    position: absolute;
    top: 10px;
    left: 15px;
    font-family: 'Share Tech Mono';
    font-size: 10px;
    color: var(--p-blue);
    z-index: 10;
    text-transform: uppercase;
    letter-spacing: 2px;
    background: rgba(0,0,0,0.8);
    padding: 2px 8px;
    border-radius: 2px;
}

.window-terminal-view {
    padding: 40px 15px 15px 15px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 11px;
    mask-image: linear-gradient(to bottom, transparent, black 40px);
}

.window-terminal-view::-webkit-scrollbar { width: 3px; }
.window-terminal-view::-webkit-scrollbar-thumb { background: var(--p-blue); }

/* COMPOSER SECTION */
.composer-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; 
    padding: 0 15px 15px 15px;
}

.br-card {
    padding: 15px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.3);
}

.br-label {
    font-size: 9px;
    color: var(--p-orange);
    font-weight: 700;
    margin-bottom: 5px;
    display: block;
    font-family: 'JetBrains Mono';
}

.br-list {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.full-list { max-height: none; flex: 1; }

.br-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: rgba(255,255,255,0.05);
    font-size: 11px;
    font-family: 'JetBrains Mono';
}
.br-item:hover { background: rgba(255,255,255,0.1); }

.br-input, .br-textarea {
    width: 100%;
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    font-family: 'JetBrains Mono';
    padding: 10px;
    font-size: 12px;
    margin-bottom: 10px;
    outline: none;
}
.br-input:focus, .br-textarea:focus { border-color: var(--p-blue); }

.main-composer {
    flex: 1;
    resize: none;
    font-size: 14px;
    line-height: 1.5;
}

.br-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid #444;
    color: #ccc;
    padding: 8px 12px;
    font-family: 'Chakra Petch';
    font-weight: 600;
    font-size: 10px;
    cursor: pointer;
    text-transform: uppercase;
    transition: 0.3s;
    width: 100%;
}
.br-btn:hover { border-color: #fff; color: #fff; background: rgba(255,255,255,0.1); }
.active-mode { background: var(--p-blue); color: #00d0dd; border-color: var(--p-blue); }
.active-mode:hover { background: #00d0dd; }

.polish-btn { border-color: var(--p-blue); color: var(--p-blue); }
.polish-btn:hover { background: var(--p-blue); color: #000; }

.schedule-trigger-btn { border-color: var(--p-orange); color: var(--p-orange); }
.schedule-trigger-btn:hover { background: var(--p-orange); color: #000; }

.chip-group { display: flex; gap: 5px; margin-bottom: 10px; }
.chip-btn {
    background: rgba(0,0,0,0.6);
    border: 1px dashed #666;
    color: #888;
    padding: 4px 8px;
    font-size: 10px;
    font-family: 'JetBrains Mono';
    cursor: pointer;
}
.chip-btn:hover { color: #fff; border-color: #fff; }

.char-counter {
    text-align: right;
    font-size: 10px;
    color: #666;
    font-family: 'Share Tech Mono';
    margin-bottom: 10px;
}

/* MEDIA BUTTONS FIXED */
.media-grid-fixed { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 5px; }
.media-btn { background: rgba(255,255,255,0.05); border: 1px solid rgba(0,243,255,0.2); color: #fff; padding: 12px 5px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 5px; border-radius: 4px; transition: 0.3s; }
.media-btn i { color: var(--p-blue); font-size: 14px; }
.media-btn span { font-size: 8px; font-family: 'JetBrains Mono'; opacity: 0.7; }
.media-btn:hover { background: var(--p-blue); color: #000; }
.media-btn:hover i { color: #000; }

.file-hidden { display: none; }
.media-status { font-size: 9px; color: #666; margin-top: 10px; font-family: 'Share Tech Mono'; text-align: center; border-top: 1px dashed #333; padding-top: 5px; }

/* OVERLAY */
.overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8); backdrop-filter: blur(5px);
    z-index: 20000;
    display: none;
    align-items: center; justify-content: center;
}

.overlay-box { width: 340px; background: #0a0a0a; border: 1px solid var(--p-blue); position: relative; padding: 25px; box-shadow: 0 0 50px rgba(0,243,255,0.1); border-radius: 4px; }
.overlay-header { font-family: 'Chakra Petch'; font-weight: 900; color: var(--p-blue); font-size: 20px; text-transform: uppercase; letter-spacing: 2px; border-bottom: 1px solid #333; padding-bottom: 10px; margin-bottom: 15px; text-align: center; }

.gate-divider { margin: 25px 0; display: flex; align-items: center; color: #444; font-size: 10px; font-family: 'Share Tech Mono'; }
.gate-divider::before, .gate-divider::after { content: ''; flex: 1; border-bottom: 1px solid #222; margin: 0 10px; }

.massive-fire-btn { width: 100%; padding: 20px; background: var(--p-orange); color: #000; border: none; font-family: 'Chakra Petch'; font-weight: 900; font-size: 18px; cursor: pointer; box-shadow: 0 0 30px rgba(255,123,0,0.3); }

.transmission-gate {
    margin-top: 15px;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 15px;
}

.test-box { display: flex; gap: 5px; }
.test-input { flex: 1; background: rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.1); color: #fff; padding: 5px; font-size: 10px; font-family: 'JetBrains Mono'; }

/* CUSTOM CHECKBOX */
.follow-up-wrap { margin: 15px 0; }
.switch-label { display: flex; align-items: center; gap: 10px; font-size: 10px; color: #888; cursor: pointer; font-family: 'JetBrains Mono'; }
.custom-check { width: 14px; height: 14px; border: 1px solid var(--p-blue); display: inline-block; position: relative; }
input[type="checkbox"]:checked + .custom-check::after { content: '✓'; position: absolute; top: -2px; left: 1px; color: var(--p-blue); font-size: 12px; }
input[type="checkbox"] { display: none; }

@media (max-width: 900px) {
    .broadcast-layout { 
        display: flex; 
        flex-direction: column; 
        overflow-y: auto; 
        /* RESET POSITIONING FOR MOBILE */
        position: static; 
        padding-bottom: 100px; /* Clear Nav */
    }
    .br-col-side { width: 100%; height: auto; border: none; border-bottom: 1px solid #333; overflow-y: visible; }
    .engine-window-pocket { height: 150px; margin: 10px; }
    
    .nav-bar-wrapper { padding: 10px; justify-content: center; margin-top: 45px; }
    .back-to-engine-btn { width: 100%; margin-bottom: 10px; margin-right: 0; }
    .industry-selector-box { width: 100%; margin-bottom: 10px; }
    .industry-select { width: 100%; }
}

/* --- NAVIGATION (5-COLUMN LAYOUT) --- */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; width: 100%; height: 90px;
    background: rgba(0,0,0,0.98); backdrop-filter: blur(15px);
    border-top: 1px solid rgba(255,255,255,0.1);
    display: grid; 
    /* 5 Columns: Button | Button | Search | Button | Button */
    /* !IMPORTANT ADDED TO OVERRIDE ANY GHOST STYLES */
    grid-template-columns: 1fr 1fr 80px 1fr 1fr !important;
    align-items: center; justify-items: center;
    z-index: 9999; padding-bottom: env(safe-area-inset-bottom);
}

.nav-group {
    width: 100%; height: 100%; display: flex; 
    align-items: center; justify-content: center; position: relative;
}

.nav-trigger {
    background: none; border: none; color: #666; font-size: 20px;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    cursor: pointer; transition: 0.3s; width: 100%;
}

.nav-trigger:hover, .nav-trigger.active {
    color: var(--p-orange); text-shadow: 0 0 15px rgba(255, 123, 0, 0.4);
}

.nav-label {
    font-size: 9px; font-weight: 800; font-family: 'Chakra Petch'; 
    text-transform: uppercase; letter-spacing: 0.5px;
}

/* CENTER SEARCH BUTTON */
.center-btn-wrapper {
    position: relative; width: 60px; height: 60px; 
    display: flex; align-items: center; justify-content: center;
    top: -15px; /* Floats slightly above */
}

.center-master-btn {
    width: 50px; height: 50px; border-radius: 50%;
    background: var(--p-orange); border: 3px solid #000; color: #000;
    font-size: 20px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; box-shadow: 0 0 20px rgba(255, 123, 0, 0.4);
    transition: 0.3s;
}

.center-master-btn:hover { transform: scale(1.05); box-shadow: 0 0 30px rgba(255, 123, 0, 0.6); }

/* POP-UP STACKS */
.nav-stack {
    position: absolute; bottom: 85px; left: 50%; transform: translateX(-50%) translateY(20px);
    width: 160px; background: rgba(10, 10, 10, 0.95);
    border: 1px solid rgba(255,255,255,0.1); border-radius: 8px;
    display: flex; flex-direction: column; opacity: 0; pointer-events: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 -10px 30px rgba(0,0,0,0.8); z-index: 10000; padding: 5px 0;
}

.nav-stack.active { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); border-color: var(--p-orange); }

.nav-stack a {
    text-decoration: none; color: #ccc; font-family: 'JetBrains Mono';
    font-size: 10px; padding: 12px 15px; text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.05); transition: 0.2s;
    text-transform: uppercase; letter-spacing: 1px; display: block;
}
.nav-stack a:hover { background: rgba(255, 123, 0, 0.1); color: #fff; }
.nav-stack a:last-child { border-bottom: none; }
.nav-stack a.active-link { color: var(--p-orange); font-weight: 800; }

/* SEARCH OVERLAY */
.search-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.95); backdrop-filter: blur(10px);
    z-index: 20000; display: none; flex-direction: column; align-items: center; justify-content: center;
}
.search-overlay.active { display: flex; animation: fadeIn 0.2s; }

.search-box {
    display: flex; border-bottom: 2px solid var(--p-orange); width: 80%; max-width: 600px; margin-top: 20px;
}
.search-box input {
    flex: 1; background: none; border: none; color: #fff; font-family: 'Chakra Petch';
    font-size: 24px; padding: 10px; outline: none; text-transform: uppercase;
}
.search-box button { background: none; border: none; color: var(--p-orange); font-size: 24px; cursor: pointer; }
.close-search-btn {
    background: none; border: 1px solid #333; color: #666; 
    width: 40px; height: 40px; border-radius: 50%; font-size: 20px;
    cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center;
    margin-bottom: 10px;
}
.close-search-btn:hover { border-color: #fff; color: #fff; transform: scale(1.1); }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

/* --- MOBILE & RESPONSIVE FIXES --- */
@media screen and (max-width: 768px) {
    /* Adjust Navigation Grid for Mobile */
    /* !IMPORTANT ADDED HERE TOO */
    .bottom-nav { grid-template-columns: 1fr 1fr 60px 1fr 1fr !important; }
    .nav-label { font-size: 8px; }
    
    /* Fix HOME Stack (Left Edge) */
    #stack-home {
        left: 5px; transform: translateY(20px); 
        border-radius: 12px 12px 12px 0;
    }
    #stack-home.active { transform: translateY(0); }

    /* Fix CRM Stack (Right Edge) */
    #stack-crm {
        left: auto; right: 5px; transform: translateY(20px); 
        border-radius: 12px 12px 0 12px;
    }
    #stack-crm.active { transform: translateY(0); }
    
    /* COMMS Stack (keep reasonably centered but safe) */
    #stack-comms { width: 140px; }

    .center-master-btn { width: 45px; height: 45px; font-size: 18px; }
}