/* VideoScope – LevelScope theme */
:root {
    --font-family-instrument: Arial, Helvetica, 'Segoe UI', sans-serif;
    --font-family-primary: var(--font-family-instrument);
    --font-size-xs: 9px;
    --font-size-sm: 10px;
    --font-size-base: 11px;
    --font-size-md: 12px;
    --font-size-lg: 14px;
    --color-bg-primary: #101214;
    --color-bg-secondary: #16181a;
    --color-bg-header: #16181a;
    --color-bg-panel: #1a1e22;
    --color-bg-instrument: #101214;
    --color-text-primary: #e8eaed;
    --color-text-secondary: #a8adb3;
    --color-text-tertiary: #787f88;
    --color-border-primary: #000;
    --color-border-accent: #000;
    --color-accent-blue: #00aaff;
    --color-accent-green: #64FF00;
    --color-accent-yellow: #fef304;
    --color-accent-red: #ff4444;
    --controls-width: 260px;
}

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

html, body { height: 100%; }

body {
    font-family: var(--font-family-primary);
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    min-height: 100vh;
    opacity: 0;
    transition: opacity 0.15s ease;
}

body.loaded { opacity: 1; }

/* Header */
.header-bar {
    background: var(--color-bg-header);
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid var(--color-border-primary);
    position: relative;
    z-index: 11000;
}

.header-left, .header-center, .header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.header-center { flex: 1; justify-content: center; }

.logo { display: flex; align-items: center; gap: 8px; }

.logo-link {
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 16px;
    padding: 2px 6px;
    border-radius: 3px;
}

.logo-link:hover { color: var(--color-text-primary); background: rgba(255,255,255,0.06); }

.logo-text {
    font-weight: 600;
    font-size: 16px;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.header-separator {
    width: 1px;
    height: 22px;
    background: var(--color-border-primary);
    flex-shrink: 0;
}

.header-group { display: flex; align-items: center; gap: 6px; }

.header-label {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    white-space: nowrap;
}

.header-info {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    white-space: nowrap;
}

.header-info-value { color: var(--color-text-primary); }

.file-label {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-select, .header-file-input {
    font-size: var(--font-size-sm);
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid var(--color-border-accent);
    background: var(--color-bg-instrument);
    color: var(--color-text-primary);
}

.header-file-input { max-width: 120px; }

.header-btn {
    font-size: var(--font-size-sm);
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid var(--color-border-accent);
    background: var(--color-bg-instrument);
    color: var(--color-text-primary);
    cursor: pointer;
}

.header-btn:hover:not(:disabled) { background: var(--color-bg-secondary); }
.header-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.header-icon-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--color-border-accent);
    background: var(--color-bg-instrument);
    color: var(--color-text-secondary);
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
}

.header-icon-btn:hover { color: var(--color-text-primary); background: var(--color-bg-secondary); }

/* Layout: controls + main */
.main-area {
    margin-left: var(--controls-width);
    height: calc(100vh - 52px);
}

.controls-panel {
    position: fixed;
    top: 52px;
    left: 0;
    width: var(--controls-width);
    height: calc(100vh - 52px);
    background: var(--color-bg-secondary);
    border-right: 1px solid var(--color-border-primary);
    overflow-y: auto;
    padding: 12px;
    z-index: 100;
}

.controls-title {
    font-size: var(--font-size-md);
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--color-text-primary);
}

.control-group {
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.control-check {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--font-size-sm);
    color: var(--color-text-primary);
    margin-bottom: 6px;
    cursor: pointer;
}

.control-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 4px 0;
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    flex-wrap: wrap;
}

.control-row select, .control-number {
    font-size: var(--font-size-xs);
    padding: 2px 4px;
    border-radius: 3px;
    border: 1px solid var(--color-border-accent);
    background: var(--color-bg-instrument);
    color: var(--color-text-primary);
    flex: 1;
    min-width: 0;
}

.control-number { width: 48px; flex: none; }

.control-row input[type="range"] { flex: 1; min-width: 60px; }

.control-value {
    font-size: var(--font-size-xs);
    color: var(--color-text-primary);
    min-width: 12px;
}

/* Resizable grid */
.resizable-grid {
    position: relative;
    height: 100%;
    width: 100%;
    overflow: hidden;
    background: var(--color-bg-primary);
}

.resizable-panel {
    position: absolute;
    background: var(--color-bg-panel);
    overflow: hidden;
    min-width: 100px;
    min-height: 80px;
    border: 1px solid var(--color-border-primary);
    border-radius: 4px;
    z-index: 1;
}

.resizable-panel.panel-hidden { display: none !important; }

.resizable-panel:hover {
    border-color: var(--color-border-accent);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}

.resizable-panel.resizing,
.resizable-panel.dragging {
    border-color: var(--color-border-accent);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    z-index: 9999;
}

.resizable-panel.fullscreen {
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 10000 !important;
}

/* Initial panel positions */
.resizable-panel[data-panel="preview"]       { top: 0; left: 0; width: 42%; height: 48%; }
.resizable-panel[data-panel="clipChecker"]   { top: 0; left: 42%; width: 22%; height: 24%; }
.resizable-panel[data-panel="vectorscope"]   { top: 0; left: 64%; width: 18%; height: 34%; }
.resizable-panel[data-panel="histogram"]     { top: 0; left: 82%; width: 18%; height: 34%; }
.resizable-panel[data-panel="waveform"]      { top: 48%; left: 0; width: 42%; height: 26%; }
.resizable-panel[data-panel="falseColor"]    { top: 24%; left: 42%; width: 22%; height: 30%; }
.resizable-panel[data-panel="audioSpectrum"] { top: 74%; left: 0; width: 28%; height: 26%; }
.resizable-panel[data-panel="audioPhase"]    { top: 74%; left: 28%; width: 28%; height: 26%; }
.resizable-panel[data-panel="loudness"]      { top: 34%; left: 64%; width: 36%; height: 66%; }

.panel-drag-handle {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 28px;
    background: rgba(0, 0, 0, 0.3);
    cursor: move;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    z-index: 50;
    border-bottom: 1px solid var(--color-border-primary);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.resizable-panel:hover .panel-drag-handle { opacity: 1; }

.drag-icon {
    position: absolute;
    left: 8px;
    width: 14px;
    height: 14px;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23ccc"><path d="M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2zm-2-8c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm0-6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"/></svg>') center/contain no-repeat;
}

.panel-content {
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    background: var(--color-bg-panel);
    overflow: hidden;
}

.scope-canvas-wrap {
    flex: 1;
    min-height: 0;
    background: var(--color-bg-instrument);
}

.scope-canvas-wrap canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Resize handles */
.resize-handle {
    position: absolute;
    background: transparent;
    z-index: 100;
}

.resize-handle:hover { background: rgba(255, 255, 255, 0.06); }

.resize-handle.left  { top: 0; left: -2px; width: 10px; height: 100%; cursor: col-resize; }
.resize-handle.right { top: 0; right: -2px; width: 10px; height: 100%; cursor: col-resize; }
.resize-handle.top   { top: -2px; left: 0; width: 100%; height: 10px; cursor: row-resize; }
.resize-handle.bottom{ bottom: -2px; left: 0; width: 100%; height: 10px; cursor: row-resize; }

.resize-handle.corner {
    bottom: -2px; right: -2px;
    width: 12px; height: 12px;
    cursor: nw-resize;
    background: var(--color-border-accent);
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.resizable-panel:hover .resize-handle.corner { opacity: 0.7; }
.resize-handle.corner:hover { opacity: 1; background: rgba(255,255,255,0.22); }

@media (max-width: 900px) {
    :root { --controls-width: 220px; }
    .file-label { display: none; }
}

@media (max-width: 700px) {
    .controls-panel {
        position: relative;
        width: 100%;
        height: auto;
        max-height: 200px;
        top: 0;
    }
    .main-area {
        margin-left: 0;
        height: calc(100vh - 52px - 200px);
    }
}
