/* 
 * CRITICAL LAYOUT ENFORCEMENT
 * Destroys all theme-injected glows, overlays, and scroll interference.
 */

/* Hide unwanted overlays and stuck loading states */
#preact-border-shadow-host,
#app-loading,
.loading-bar,
#blazor-error-ui [data-nosnippet] {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Force viewport reset on every possible wrapper level */
html,
body,
.page,
main,
article,
.content {
    margin: 0 !important;
    padding: 0 !important;
    height: 100vh !important;
    width: 100vw !important;
    overflow: hidden !important;
    background-color: #000 !important;
    background-image: none !important;
    box-shadow: none !important;
    filter: none !important;
}

/* 
 * DASHBOARD GRID SYSTEM 
 */
.dashboard-container {
    display: flex !important;
    flex-direction: column !important;
    height: 100vh !important;
    width: 100vw !important;
    background-color: #000 !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 100 !important;
}

/* Header */
.dashboard-header {
    height: 60px !important;
    flex: 0 0 60px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 0 20px !important;
    background: #111 !important;
    border-bottom: 1px solid #333 !important;
    box-sizing: border-box !important;
    z-index: 110 !important;
}

/* Layout Splitting: 50/50 vertical split */
.dashboard-top {
    display: flex !important;
    flex-direction: row !important;
    flex: 1 1 50% !important;
    /* Take exactly half of remaining */
    min-height: 0 !important;
    border-bottom: 1px solid #222 !important;
}

.dashboard-bottom {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 50% !important;
    /* Take other half */
    min-height: 0 !important;
    background: #000 !important;
    overflow: hidden !important;
}

/* Quadrants: 50/50 horizontal split */
.map-wrapper,
.timeline-wrapper {
    flex: 1 1 50% !important;
    width: 50% !important;
    height: 100% !important;
    position: relative !important;
    overflow: hidden !important;
}

.map-wrapper {
    border-right: 1px solid #222 !important;
}

/* Canvas elements must fill their wrappers */
#mapViz,
#timelineChart {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: block !important;
}

/* Live Feed component inside bottom half */
.dashboard-bottom .card {
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    background: #000 !important;
    border: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
}

.dashboard-bottom .card-body {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    padding: 0 !important;
}

/* Branding */
.brand {
    font-weight: 900;
    font-size: 1.2rem;
    letter-spacing: 2px;
    color: #fff;
}

.stats {
    display: flex;
    gap: 20px;
}

.stat-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.stat-item .label {
    font-size: 0.6rem;
    color: #888;
    text-transform: uppercase;
}

.stat-item .value {
    font-family: monospace;
    font-size: 1.1rem;
    color: #0ff;
}

/* GitHub Link */
.github-link {
    font-weight: 900;
    font-size: 1.2rem;
    letter-spacing: 2px;
    color: #fff;
    text-decoration: none;
    transition: color 0.2s ease;
}

.github-link:hover {
    color: #ff9900;
}

/* Kill any other layout attempts */
.left-panel,
.bottom-panel,
.dashboard-overlay {
    display: contents !important;
}

/* Timeline Controls */
.timeline-controls {
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    z-index: 120 !important;
    display: flex !important;
    gap: 5px !important;
}

.timeline-controls button {
    background: #222 !important;
    border: 1px solid #444 !important;
    color: #888 !important;
    font-family: monospace !important;
    font-size: 0.7rem !important;
    padding: 2px 8px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    border-radius: 2px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
}

.timeline-controls button:hover {
    background: #333 !important;
    color: #fff !important;
    border-color: #ff9900 !important;
}

.timeline-controls button.active {
    background: #ff9900 !important;
    border-color: #ff9900 !important;
    color: #000 !important;
    font-weight: bold !important;
    box-shadow: 0 0 15px rgba(255, 153, 0, 0.4) !important;
}

/* Custom Legend */
.custom-legend {
    position: absolute !important;
    top: 10px !important;
    left: 10px !important;
    right: 150px !important;
    /* Avoid overlap with controls */
    z-index: 120 !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    pointer-events: none !important;
    /* Allow clicks to pass through container */
}

.legend-pill {
    pointer-events: auto !important;
    display: flex !important;
    align-items: center !important;
    background: #222 !important;
    /* Solid background to prevent bleed-through */
    border: 1px solid #444 !important;
    border-radius: 20px !important;
    padding: 2px 6px 2px 8px !important;
    cursor: pointer !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    user-select: none !important;
}

.legend-pill:hover {
    border-color: var(--hover-color, #ff9900) !important;
    background: #333 !important;
    /* Solid background on hover */
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5) !important;
}

.legend-indicator {
    width: 10px !important;
    /* Slightly larger color dots */
    height: 10px !important;
    border-radius: 50% !important;
    margin-right: 8px !important;
}

.legend-label {
    font-size: 0.7rem !important;
    color: #eee !important;
    font-weight: 500 !important;
    margin-right: 8px !important;
    letter-spacing: 0.3px !important;
}

.legend-count {
    color: #0ff !important;
    font-family: monospace !important;
    font-size: 0.7rem !important;
    opacity: 0.8 !important;
    letter-spacing: 0.5px !important;
}

/* Legend States */
.legend-pill.selective {
    border-color: #ff9900 !important;
    background: rgba(255, 153, 0, 0.15) !important;
    box-shadow: 0 0 10px rgba(255, 153, 0, 0.2) !important;
}

.legend-pill.selective .legend-label {
    color: #ff9900 !important;
    font-weight: 700 !important;
}

.legend-pill.filtered {
    border-color: #ff4444 !important;
    opacity: 0.6 !important;
    text-decoration: line-through !important;
}

.legend-pill.dimmed {
    opacity: 0.3 !important;
    filter: grayscale(0.8) !important;
    transform: scale(0.95) !important;
}

.legend-pill.dimmed:hover {
    opacity: 0.5 !important;
    filter: grayscale(0.4) !important;
}

/* 
 * MOBILE RESPONSIVENESS (Max-Width: 768px)
 * Stacks layout vertically and enables scrolling
 */
@media screen and (max-width: 768px) {

    /* 1. Reset Global Scroll & Size Locks */
    html,
    body,
    .page,
    main,
    article,
    .content {
        height: auto !important;
        width: 100% !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        position: relative !important;
        /* Release absolute lock if present */
    }

    /* 2. Dashboard Container Unlock */
    .dashboard-container {
        height: auto !important;
        min-height: 100vh !important;
        overflow-y: visible !important;
        position: relative !important;
        display: block !important;
        /* Switch from flex column to block for simpler flow */
    }

    /* 3. Header */
    .dashboard-header {
        position: sticky !important;
        top: 0 !important;
        width: 100% !important;
        /* Keep existing flex props */
    }

    /* 4. Top Section (Map + Timeline) -> Stack Vertically */
    .dashboard-top {
        display: flex !important;
        flex-direction: column !important;
        flex: none !important;
        /* Stop trying to be 50% */
        height: auto !important;
        border-bottom: none !important;
    }

    /* 5. Wrappers (Map & Timeline) */
    .map-wrapper,
    .timeline-wrapper {
        flex: none !important;
        width: 100% !important;
        height: 350px !important;
        /* Fixed height for visuals */
        border-right: none !important;
        border-bottom: 1px solid #222 !important;
        position: relative !important;
        display: block !important;
    }

    /* 6. Timeline Controls - Reposition for mobile if needed */
    .timeline-controls {
        top: 5px !important;
        right: 5px !important;
    }

    /* 7. Bottom Section (Live Feed) -> Natural Height */
    .dashboard-bottom {
        flex: none !important;
        height: 600px !important;
        /* Give it substantial space or let it grow */
        display: block !important;
        overflow: visible !important;
        /* Let inner content determine scroll or height */
    }

    /* Make Live Feed Card fill the container */
    .dashboard-bottom .card {
        height: 100% !important;
        min-height: 500px !important;
    }
}

/* ============================================
   PAYLOAD INSPECTOR MODAL
   ============================================ */

.payload-inspector {
    background: #0d0d0d !important;
    border: 1px solid #333 !important;
    color: #eee !important;
    font-family: 'Consolas', 'Monaco', monospace !important;
}

.payload-inspector-header {
    background: #111 !important;
    border-bottom: 1px solid #333 !important;
    padding: 12px 20px !important;
}

.payload-inspector-header .modal-title {
    color: #ff9900 !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    letter-spacing: 1px !important;
}

.inspector-icon {
    margin-right: 8px;
}

/* Metadata Bar */
.payload-inspector-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 12px 20px;
    background: #151515;
    border-bottom: 1px solid #222;
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.meta-label {
    font-size: 0.65rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.meta-value {
    font-size: 0.85rem;
    color: #ddd;
}

.protocol-badge {
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: bold;
    font-size: 0.75rem;
}

.protocol-badge.tcp {
    background: rgba(0, 255, 255, 0.15);
    color: #0ff;
    border: 1px solid #0ff;
}

.protocol-badge.udp {
    background: rgba(255, 153, 0, 0.15);
    color: #ff9900;
    border: 1px solid #ff9900;
}

.classifier-name {
    color: #0ff !important;
}

.intent-badge {
    padding: 2px 8px;
    border-radius: 3px;
    font-weight: bold;
    font-size: 0.7rem;
    text-transform: uppercase;
}

.intent-exploit {
    background: #ff4444;
    color: #fff;
}

.intent-recon {
    background: #ffbb33;
    color: #000;
}

.intent-benign {
    background: #00C851;
    color: #fff;
}

.intent-unknown {
    background: #666;
    color: #fff;
}

/* Tabs */
.payload-inspector-tabs {
    display: flex;
    gap: 8px;
    padding: 10px 20px;
    background: #0a0a0a;
    border-bottom: 1px solid #222;
    align-items: center;
}

.tab-btn {
    background: #1a1a1a;
    border: 1px solid #333;
    color: #888;
    padding: 6px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.tab-btn:hover:not(:disabled) {
    background: #222;
    color: #fff;
    border-color: #ff9900;
}

.tab-btn.active {
    background: #ff9900;
    color: #000;
    font-weight: bold;
    border-color: #ff9900;
}

.tab-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.tab-actions {
    margin-left: auto;
    display: flex;
    gap: 6px;
}

.action-btn {
    background: #1a1a1a;
    border: 1px solid #333;
    color: #888;
    padding: 4px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s ease;
}

.action-btn:hover {
    background: #222;
    color: #0ff;
    border-color: #0ff;
}

/* Body */
.payload-inspector-body {
    background: #0d0d0d !important;
    padding: 16px 20px !important;
    max-height: 60vh;
    overflow-y: auto;
}

/* Parsed View */
.parsed-view {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.parsed-table {
    width: 100%;
    border-collapse: collapse;
}

.parsed-table tr {
    border-bottom: 1px solid #222;
}

.parsed-table tr:hover {
    background: #151515;
}

.parsed-label {
    color: #888;
    font-size: 0.8rem;
    padding: 8px 12px 8px 0;
    width: 140px;
    vertical-align: top;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.parsed-value {
    color: #0ff;
    font-size: 0.85rem;
    padding: 8px 0;
    word-break: break-all;
}

.parsed-body-section {
    margin-top: 12px;
}

.parsed-body-label {
    font-size: 0.75rem;
    color: #666;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.parsed-body {
    background: #111;
    border: 1px solid #222;
    border-radius: 4px;
    padding: 12px;
    color: #8f8;
    font-size: 0.8rem;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
}

/* Hex View */
.hex-view,
.ascii-view {
    background: #0a0a0a;
    border: 1px solid #222;
    border-radius: 4px;
    padding: 12px;
}

.hex-dump {
    color: #0ff;
    font-size: 0.8rem;
    line-height: 1.6;
    white-space: pre;
    overflow-x: auto;
    margin: 0;
}

.ascii-dump {
    color: #8f8;
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
    margin: 0;
}

/* Stats Bar */
.payload-stats {
    display: flex;
    gap: 20px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #222;
}

.payload-stats .stat {
    font-size: 0.75rem;
    color: #666;
}

.payload-stats .stat::before {
    content: "• ";
    color: #444;
}

/* ============================================ */
/* Attack Explainer Panel                       */
/* ============================================ */

.attack-explainer {
    margin-top: 12px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 1px solid #2d4a7c;
    border-radius: 8px;
    overflow: hidden;
}

.explainer-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    background: rgba(255, 153, 0, 0.1);
    border-bottom: 1px solid rgba(255, 153, 0, 0.2);
    transition: background 0.2s ease;
}

.explainer-header:hover {
    background: rgba(255, 153, 0, 0.15);
}

.explainer-icon {
    font-size: 1.2rem;
}

.explainer-title {
    flex: 1;
    font-size: 0.95rem;
    font-weight: 600;
    color: #ff9900;
}

.explainer-toggle {
    color: #ff9900;
    font-size: 0.8rem;
    opacity: 0.7;
}

.explainer-content {
    padding: 16px;
}

.explainer-section {
    margin-bottom: 16px;
}

.explainer-section:last-child {
    margin-bottom: 0;
}

.explainer-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.explainer-text {
    font-size: 0.9rem;
    color: #ddd;
    line-height: 1.6;
}

.explainer-text.tech-note {
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 0.85rem;
    color: #aaa;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px 12px;
    border-radius: 4px;
    border-left: 3px solid #ff9900;
}

.explainer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.explainer-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: rgba(0, 136, 255, 0.15);
    border: 1px solid rgba(0, 136, 255, 0.3);
    border-radius: 4px;
    color: #4da6ff;
    font-size: 0.8rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

.explainer-link:hover {
    background: rgba(0, 136, 255, 0.25);
    border-color: rgba(0, 136, 255, 0.5);
    color: #6bb8ff;
}