:root {
    --bg-dark: #0f172a;
    --panel-bg: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #38bdf8;
    --flash-color: rgba(255, 255, 255, 0.8);
    --border-color: #334155;
    --danger: #ef4444;
    --success: #10b981;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background-color: var(--panel-bg);
    border-bottom: 1px solid var(--border-color);
}

header h1 {
    font-size: 1.5rem;
    color: var(--accent);
}

#mission-select {
    background: var(--accent);
    color: #0f172a;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
    width: 100%;
}

#mission-select:hover {
    background: #7dd3fc;
}

#mission-select option {
    background: var(--panel-bg);
    color: var(--text-main);
    padding: 0.5rem;
}

#mission-select {
    background: var(--accent);
    color: #0f172a;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    width: 100%;
    margin-bottom: 0.5rem;
}

#mission-select:hover {
    background: #7dd3fc;
}

.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    padding: 1rem;
    gap: 1rem;
}

/* Video Container */
.video-container {
    position: relative;
    background-color: #000;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.band-videos-container {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    background-color: var(--panel-bg);
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    min-height: 100px;
}

.band-video-wrapper {
    position: relative;
    flex: 0 0 auto;
    width: 120px;
    background-color: #000;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.band-video-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.band-video-label {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: rgba(0,0,0,0.6);
    color: var(--text-main);
    font-size: 0.7rem;
    text-align: center;
    padding: 2px 0;
    text-transform: uppercase;
}

.video-placeholder {
    width: 100%;
    height: 100%;
    /* Simulate moving ground with a background pattern */
    background-image: radial-gradient(#334155 1px, transparent 1px), radial-gradient(#334155 1px, transparent 1px);
    background-position: 0 0, 25px 25px;
    background-size: 50px 50px;
    animation: scrollBg 20s linear infinite;
}

@keyframes scrollBg {
    from { background-position: 0 0, 25px 25px; }
    to { background-position: 0 500px, 25px 525px; }
}

.video-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    border: 0px solid var(--flash-color);
    transition: border-width 0.1s ease-out, background-color 0.1s ease-out;
}

.video-overlay.flash {
    border-width: 10px;
    background-color: rgba(255,255,255,0.2);
}

.crosshair {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    pointer-events: none;
}
.crosshair::before, .crosshair::after {
    content: '';
    position: absolute;
    background: rgba(255, 255, 255, 0.5);
}
.crosshair::before { top: 50%; left: -10px; right: -10px; height: 2px; margin-top: -1px; }
.crosshair::after { left: 50%; top: -10px; bottom: -10px; width: 2px; margin-left: -1px; }

/* Right Panel */
.right-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 350px;
}

.panel-section {
    background-color: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0; /* Critical for flex children to allow inner scrolling */
}

.panel-section h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Image Wrapper with Bounding Boxes */
.image-wrapper {
    position: relative;
    width: 100%;
    flex: 1;
    background-color: #000;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-wrapper img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

#bounding-boxes {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
}

.bounding-box {
    position: absolute;
    border: 2px solid var(--danger);
    background-color: rgba(239, 68, 68, 0.2);
    box-sizing: border-box;
}

/* Log Windows */
.log-window {
    flex: 1;
    background-color: #0f172a;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.5rem;
    overflow-y: auto;
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--success);
    white-space: pre-wrap; /* allow JSON formatting to wrap nicely */
    min-height: 0; /* Ensures scrollbar appears correctly inside flexbox */
}

.log-entry { margin-bottom: 0.5rem; border-bottom: 1px solid #1e293b; padding-bottom: 0.2rem; }
.log-entry.prompt { color: var(--accent); }
.log-entry.response { color: #fef08a; }

/* Bottom Panel */
.bottom-panel {
    display: flex;
    padding: 0 1rem 1rem 1rem;
    height: auto;
}

.data-section {
    flex: 1;
    background-color: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

.data-section h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.classification-bars {
    display: flex;
    flex-direction: row;
    width: 100%;
    gap: 1rem;
    background-color: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 1rem;
}

.class-bar-container { flex: 1; display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; }
.class-bar-label { display: flex; justify-content: space-between; }
.class-bar-track { width: 100%; height: 8px; background-color: #334155; border-radius: 4px; overflow: hidden; }
.class-bar-fill { height: 100%; background-color: var(--accent); width: 0%; transition: width 0.3s ease-out; }

.json-window {
    flex: 1;
    background-color: #0f172a;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.5rem;
    overflow-y: auto;
    font-family: monospace;
    font-size: 0.85rem;
    color: #e2e8f0;
    white-space: pre-wrap;
}
