/* ============================================================
   I. BASE THEMES & VARIABLES
   ============================================================ */
:root {
    --bg-main: #0A1128; 
    --bg-panel: #112240; 
    --bg-card: #1C2E4A;
    --text-main: #E2E8F0; 
    --text-muted: #94A3B8;
    --text-heading: #FFFFFF;
    --border-color: #1e3a8a;
    --accent-gold: #F59E0B;
    --accent-green: #10B981;
    --accent-blue: #38BDF8;
    --border-radius: 6px;
    --shadow: 0 10px 30px -15px rgba(0,0,0,0.5);
    
    --grad-pm-card: linear-gradient(135deg, #1e3a8a 0%, #0A1128 100%);
    --grad-arch-card: linear-gradient(135deg, #112240 0%, #0A1128 100%);
    --download-bg: rgba(10, 17, 40, 0.95);
}

body.light-mode {
    --bg-main: #F8FAFC; 
    --bg-panel: #FFFFFF; 
    --bg-card: #F1F5F9;
    --text-main: #1E293B; 
    --text-muted: #475569; 
    --text-heading: #0F172A;
    --border-color: #CBD5E1;
    --accent-gold: #B45309; 
    --accent-green: #059669;
    --accent-blue: #0284C7;
    --shadow: 0 10px 25px -5px rgba(0,0,0,0.1);

    --grad-pm-card: linear-gradient(135deg, #FFFFFF 0%, #F1F5F9 100%);
    --grad-arch-card: linear-gradient(135deg, #F8FAFC 0%, #E2E8F0 100%);
    --download-bg: rgba(255, 255, 255, 0.95);
}

/* ============================================================
   II. GLOBAL & LAYOUT STYLES
   ============================================================ */
body { 
    font-family: system-ui, -apple-system, sans-serif; 
    background: var(--bg-main); color: var(--text-main); 
    margin: 0; padding: 0; min-height: 100vh;
    display: flex; flex-direction: column; align-items: center;
    transition: background-color 0.3s, color 0.3s;
}

/* Fluid Asset Scaling */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* LOGO SCALING: Fixes the 'huge' issue in reports and landing */
.logo-container img {
    height: 100px; 
    width: auto;
    object-fit: contain;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.2));
}

.dashboard-header .sb-logo {
    height: 45px; 
    width: auto;
    object-fit: contain;
    margin: 0;
    padding: 5px 0;
    filter: drop-shadow(0 0 5px rgba(56, 189, 248, 0.1));
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-main); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

#theme-toggle {
    position: absolute; top: 20px; right: 20px;
    padding: 10px 15px; border-radius: 20px; border: 1px solid var(--border-color);
    background: var(--bg-panel); color: var(--text-main);
    cursor: pointer; font-weight: 500; font-size: 0.9rem;
    box-shadow: var(--shadow); z-index: 100; transition: 0.3s;
}
#theme-toggle:hover { filter: brightness(1.1); }

/* ============================================================
   III. SYSTEM STATUS BAR (TACTICAL OVERLAY)
   ============================================================ */
.system-status-bar {
    display: flex; gap: 25px;
    font-family: 'Consolas', monospace;
    font-size: 0.75rem;
    letter-spacing: 2px;
    padding: 10px 25px;
    border-radius: 20px;
    margin-bottom: 30px;
    backdrop-filter: blur(4px);
    overflow: visible;
    border: 1px solid rgba(56, 189, 248, 0.4);
    background: rgba(10, 17, 40, 0.9);
    color: var(--accent-blue);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.1);
    flex-wrap: wrap; 
    justify-content: center;
}

body.light-mode .system-status-bar {
    background: #FFFFFF;
    border: 1px solid var(--accent-blue);
    color: var(--text-main);
    box-shadow: 0 2px 15px rgba(2, 132, 199, 0.1);
}

.blink-led {
    margin-right: 8px;
    color: var(--accent-green);
    text-shadow: 0 0 10px var(--accent-green), 0 0 20px rgba(16, 185, 129, 0.5);
    display: inline-block;
    animation: hardware-pulse 1.2s infinite;
}

#agent-count { color: var(--accent-blue); font-weight: bold; }

@keyframes hardware-pulse {
    0%, 45% { opacity: 1; filter: brightness(1.2); }
    50%, 95% { opacity: 0.15; filter: brightness(0.6); }
    100% { opacity: 1; }
}

/* ============================================================
   IV. LANDING PAGE & SEARCH
   ============================================================ */
#landing-page {
    display: flex; flex-direction: column; align-items: center;
    width: 100%; padding: 60px 20px; box-sizing: border-box;
}

.hero-text { text-align: center; max-width: 800px; margin-bottom: 40px; }
.hero-text h2 { color: var(--text-heading); font-size: 2.5rem; margin-bottom: 15px; font-weight: 700; letter-spacing: -0.5px;}
.hero-text p { color: var(--text-muted); font-size: 1.15rem; line-height: 1.6;}

.search-container { 
    text-align: center; background: var(--bg-panel); padding: 40px;
    border-radius: var(--border-radius); border: 1px solid var(--border-color);
    box-shadow: var(--shadow); width: 100%; max-width: 700px; margin-bottom: 60px;
}

.example-link { margin-top: 15px; font-size: 0.9rem; color: var(--text-muted); cursor: pointer; }
.highlight { color: var(--accent-gold); text-decoration: underline; }

input { 
    padding: 16px 20px; font-size: 1.2rem; width: 60%; max-width: 350px;
    background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--border-radius);
    color: var(--text-main); outline: none; text-transform: uppercase;
}

.search-container button { 
    padding: 17px 35px; font-size: 1.1rem; background: var(--accent-gold); 
    color: #FFFFFF; border: none; border-radius: var(--border-radius); font-weight: bold;
    cursor: pointer; margin-left: 10px; transition: 0.2s; box-shadow: 0 4px 15px rgba(245, 158, 11, 0.2);
}

/* ============================================================
   V. AGENT GRID & ARCHITECTURE
   ============================================================ */
.section-container { width: 100%; max-width: 1200px; margin-bottom: 60px; text-align: center; }
.agent-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.agent-card {
    background: var(--bg-panel); border: 1px solid var(--border-color); padding: 25px 20px; 
    border-radius: var(--border-radius); text-align: left; transition: transform 0.3s ease; box-shadow: var(--shadow);
}
.agent-card:hover { transform: translateY(-5px); border-color: var(--accent-blue); }

/* ============================================================
   VI. DASHBOARD & CONSOLE (MISSION-CRITICAL)
   ============================================================ */
#dashboard {
    display: none; flex-direction: column; gap: 20px;
    width: 100%; max-width: 1400px; padding: 20px 20px 100px; box-sizing: border-box;
}

.top-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 20px; width: 100%;
}

.panel { 
    background: #0D162D; border-radius: var(--border-radius); border: 1px solid var(--border-color); 
    padding: 20px; display: flex; flex-direction: column; min-height: 350px;
    box-shadow: inset 0 0 15px rgba(56, 189, 248, 0.05), var(--shadow);
}

body.light-mode .panel { background: var(--bg-panel); }

.panel-title {
    font-family: 'Consolas', monospace; text-transform: uppercase; letter-spacing: 1.5px;
    color: var(--accent-blue); font-size: 0.85rem; border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px; margin-bottom: 15px;
}

.log-content {
    color: #A5F3FC; text-shadow: 0 0 5px rgba(165, 243, 252, 0.2);
}

body.light-mode .log-content { color: var(--text-main); text-shadow: none; }

/* ============================================================
   VII. REPORTS & CONVERSION
   ============================================================ */
#report-wrapper { position: relative; overflow: hidden; }

/* BLURRED PREVIEW: Integrated for conversion reports */
.blurred-content {
    filter: blur(8px);
    pointer-events: none;
    user-select: none;
    opacity: 0.6;
    mask-image: linear-gradient(to bottom, black 0%, transparent 90%);
}

.pm-card {
    background: var(--grad-pm-card); border: 1px solid var(--border-color); 
    border-left: 6px solid var(--accent-gold); border-radius: var(--border-radius); padding: 30px;
}

.download-bar {
    position: fixed; bottom: 0; left: 0; width: 100%; background: var(--download-bg); 
    backdrop-filter: blur(10px); border-top: 2px solid var(--accent-gold);
    padding: 15px 0; display: flex; justify-content: center; align-items: center; gap: 20px;
    z-index: 1000; box-shadow: 0 -5px 20px rgba(0,0,0,0.5);
}

.pay-btn {
    padding: 12px 24px; font-size: 1rem; background: var(--accent-gold); 
    color: #FFFFFF; border: none; border-radius: var(--border-radius); font-weight: bold;
    cursor: pointer; box-shadow: 0 0 20px rgba(245, 158, 11, 0.4); transition: all 0.3s ease;
}

/* ============================================================
   VIII. RESPONSIVE UTILITIES
   ============================================================ */
@media (max-width: 1000px) {
    .agent-grid { grid-template-columns: 1fr 1fr; }
    .top-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .hero-text h2 { font-size: 1.8rem; }
    .search-container input { width: 100%; margin-bottom: 10px; }
    .search-container button { width: 100%; margin-left: 0; }
    .agent-grid { grid-template-columns: 1fr; }
    .system-status-bar { gap: 10px; }
    .logo-container img { height: 80px; }
    .dashboard-header .sb-logo { height: 35px; }
}

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

.header-right {
    display: flex;
    align-items: center;
}

.tactical-btn {
    background: transparent;
    border: 1px solid var(--accent-blue);
    color: var(--accent-blue);
    padding: 8px 15px;
    font-family: 'Consolas', monospace;
    font-size: 0.8rem;
    letter-spacing: 1px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: 0.3s;
}

.tactical-btn:hover {
    background: rgba(56, 189, 248, 0.1);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

/* Ensure the header logo doesn't look like a static image */
.header-left:hover .sb-logo {
    filter: drop-shadow(0 0 8px var(--accent-blue));
    transform: scale(1.02);
}

/* ============================================================
   IX. INSTITUTIONAL PDF EXPORT (PRINT)
   ============================================================ */
@media print {
    /* Hide non-essential UI */
    #theme-toggle, .tactical-btn, .download-bar, .search-container {
        display: none !important;
    }

    body {
        background: white !important;
        color: #0A1128 !important;
    }

    #dashboard {
        display: flex !important;
        width: 100% !important;
        max-width: none !important;
        padding: 0 !important;
    }

    .panel {
        break-inside: avoid;
        border: 1px solid #1e3a8a !important;
        background: #f8fafc !important;
        margin-bottom: 20px;
    }

    .blurred-content {
        filter: none !important;
        opacity: 1 !important;
        mask-image: none !important;
    }

    .pm-card {
        border-left: 10px solid #F59E0B !important;
        background: #f1f5f9 !important;
        page-break-before: always;
    }
}

/* ============================================================
   X. FOOTER & DISCLOSURE STYLES
   ============================================================ */
.system-footer {
    width: 100%;
    background: #050A18;
    border-top: 1px solid var(--border-color);
    padding: 60px 20px 20px;
    margin-top: 80px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

body.light-mode .system-footer {
    background: #F1F5F9;
    border-top: 1px solid #CBD5E1;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
}

.footer-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 40px;
}

.sb-logo-footer { height: 35px; margin-bottom: 10px; }

.footer-links a {
    color: var(--accent-blue);
    text-decoration: none;
    margin-left: 20px;
}

.disclaimer-box {
    border-left: 3px solid var(--border-color);
    padding-left: 20px;
    margin-bottom: 40px;
    line-height: 1.6;
    font-family: 'Consolas', monospace;
    font-size: 0.75rem;
}

.footer-bottom {
    text-align: center;
    border-top: 1px solid rgba(56, 189, 248, 0.1);
    padding-top: 20px;
    letter-spacing: 1px;
}

/* Pricing & Protocol Grid */
.pricing-card {
    background: var(--bg-panel);
    border: 1px solid var(--accent-gold);
    padding: 40px;
    border-radius: var(--border-radius);
    max-width: 400px;
    margin: 20px auto;
}

.price {
    font-size: 2.5rem;
    color: var(--text-heading);
    margin: 20px 0;
    font-weight: bold;
}

.price span { font-size: 1rem; color: var(--text-muted); }

.pricing-features {
    list-style: none;
    padding: 0;
    text-align: left;
    margin-bottom: 0;
}

.pricing-features li::before {
    content: "✓";
    color: var(--accent-green);
    margin-right: 10px;
}

.protocol-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    margin-top: 40px;
}

.step-num {
    font-family: 'Consolas', monospace;
    color: var(--accent-blue);
    font-size: 1.5rem;
    font-weight: bold;
    display: block;
    margin-bottom: 10px;
}

/* ============================================================
   XI. LIVE AUDIT TRAIL CONSTRAINTS (FIX FOR SCROLLING)
   ============================================================ */
.msg-pane {
    height: 450px; /* Constrains the panel to a fixed monitor height */
    display: flex;
    flex-direction: column;
}

#log-scroll-container {
    flex: 1; /* Fills remaining space in the panel */
    overflow-y: auto; /* Enables vertical scrolling */
    padding-right: 5px;
}

.log-row {
    font-family: 'Consolas', monospace;
    font-size: 0.8rem;
    border-bottom: 1px solid rgba(56, 189, 248, 0.1);
}

.log-time {
    width: 85px;
    color: var(--text-muted);
    padding: 4px 0;
}

.log-content {
    word-wrap: break-word;
    padding: 4px 0 4px 10px;
}

/* ============================================================
   XII. TACTICAL MODAL OVERLAY (TERMS & CONDITIONS)
   ============================================================ */
#terms-modal {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    padding: 30px;
    border-radius: var(--border-radius);
    color: var(--text-main);
}

body.light-mode #terms-modal {
    background: #FFFFFF;
}

#terms-modal h4 {
    color: var(--accent-blue);
    margin-top: 20px;
    margin-bottom: 8px;
    text-transform: uppercase;
    font-size: 0.9rem;
}

#modal-overlay {
    backdrop-filter: blur(5px);
    transition: opacity 0.3s ease;
}

/* ============================================================
   XIII. PRINT ENHANCEMENTS (PDF FIDELITY)
   ============================================================ */
@media print {
    /* Hide the footer and all landing sections during export */
    .system-footer, #landing-extensions, #landing-page, #modal-overlay, #terms-modal {
        display: none !important;
    }
    
    #dashboard {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .panel {
        box-shadow: none !important;
        page-break-inside: avoid;
    }
}

/* ============================================================
   XII. TACTICAL MODAL OVERLAY (TERMS & CONDITIONS)
   ============================================================ */
#modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8); /* Darker backdrop for focus */
    backdrop-filter: blur(4px); /* Tactical frosted glass effect */
    z-index: 1999;
    transition: opacity 0.3s ease;
}

#terms-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2000;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    background: var(--bg-panel); /* Matches industrial panel theme */
    color: var(--text-main);
    border: 2px solid var(--border-color); /* High-integrity border */
    border-radius: var(--border-radius);
    padding: 30px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.9);
}

body.light-mode #terms-modal {
    background: #FFFFFF;
    border: 2px solid var(--accent-blue);
}

#terms-modal h4 {
    color: var(--accent-blue);
    margin-top: 20px;
    margin-bottom: 8px;
    text-transform: uppercase;
    font-family: 'Consolas', monospace;
    font-size: 0.9rem;
}

/* Scrollbar polish for the modal content */
#terms-modal::-webkit-scrollbar { width: 6px; }
#terms-modal::-webkit-scrollbar-thumb { background: var(--accent-blue); }