/* VideoDesigner — Dark Theme */
:root {
    --bg: #0d0d12;
    --bg2: #141420;
    --bg3: #1a1a2e;
    --surface: #1e1e30;
    --border: #2a2a40;
    --text: #e4e4e7;
    --text2: #a1a1aa;
    --primary: #8b5cf6;
    --primary2: #7c3aed;
    --accent: #f59e0b;
    --danger: #ef4444;
    --success: #22c55e;
    --sidebar-w: 240px;
    --tools-w: 280px;
    --topbar-h: 48px;
    --timeline-h: 160px;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
}

/* ═══ TOP BAR ═══ */
#topbar {
    display: flex; align-items: center; justify-content: space-between;
    height: var(--topbar-h); padding: 0 12px;
    background: var(--bg2); border-bottom: 1px solid var(--border);
}
.top-left { display: flex; align-items: center; gap: 10px; }
.top-center { display: flex; align-items: center; gap: 8px; }
.top-right { display: flex; align-items: center; gap: 6px; }
.logo { font-weight: 700; font-size: 15px; color: var(--primary); white-space: nowrap; }

#comp-title {
    background: transparent; border: 1px solid transparent; color: var(--text);
    padding: 4px 8px; border-radius: 4px; font-size: 14px; width: 180px;
}
#comp-title:hover, #comp-title:focus { border-color: var(--border); background: var(--bg3); outline: none; }

#comp-platform {
    background: var(--bg3); color: var(--text); border: 1px solid var(--border);
    padding: 4px 8px; border-radius: 4px; font-size: 12px;
}

/* ═══ BUTTONS ═══ */
.btn {
    padding: 5px 12px; border-radius: 6px; border: none; cursor: pointer;
    font-size: 12px; font-weight: 500; display: inline-flex; align-items: center; gap: 4px;
    transition: all .15s;
}
.btn-save { background: var(--primary); color: #fff; }
.btn-save:hover { background: var(--primary2); }
.btn-secondary { background: var(--bg3); color: var(--text2); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface); color: var(--text); }
.btn-render { background: linear-gradient(135deg, #f59e0b, #ef4444); color: #fff; font-weight: 700; }
.btn-render:hover { filter: brightness(1.1); }
.btn-small { padding: 4px 8px; font-size: 11px; background: var(--bg3); color: var(--text2); border: 1px solid var(--border); border-radius: 4px; cursor: pointer; }
.btn-small:hover { background: var(--surface); color: var(--text); }
.btn-full { width: 100%; justify-content: center; margin-top: 4px; }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-icon { background: none; border: none; color: var(--text2); cursor: pointer; font-size: 16px; padding: 2px 6px; border-radius: 4px; }
.btn-icon:hover { background: var(--bg3); color: var(--text); }

/* ═══ LAYOUT ═══ */
#main {
    display: flex;
    height: calc(100vh - var(--topbar-h));
}

/* ═══ SIDEBAR ═══ */
#sidebar {
    width: var(--sidebar-w); min-width: var(--sidebar-w);
    background: var(--bg2); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; overflow-y: auto;
}
.sidebar-section { padding: 10px; border-bottom: 1px solid var(--border); }
.sidebar-section.flex-1 { flex: 1; overflow-y: auto; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.section-header h3 { font-size: 12px; color: var(--text2); text-transform: uppercase; letter-spacing: .5px; }

.item-list { display: flex; flex-direction: column; gap: 2px; }
.item {
    padding: 6px 8px; border-radius: 4px; cursor: pointer; font-size: 12px;
    display: flex; align-items: center; gap: 6px;
    transition: background .1s;
}
.item:hover { background: var(--bg3); }
.item.active { background: var(--primary); color: #fff; }
.item .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.item .count { margin-left: auto; font-size: 10px; color: var(--text2); }

/* ═══ CENTER ═══ */
#center { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

#canvas-area {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: #0a0a0f; position: relative; overflow: hidden;
}
#canvas-container {
    position: relative;
    box-shadow: 0 4px 24px rgba(0,0,0,.6);
    border: 1px solid var(--border);
}
#preview-canvas { display: block; }

#playback-controls {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 16px;
    background: var(--bg2); border-top: 1px solid var(--border);
    width: 100%;
}
#time-display { font-size: 12px; color: var(--text2); font-variant-numeric: tabular-nums; margin-left: 8px; }
#zoom-controls { margin-left: auto; display: flex; align-items: center; gap: 4px; }
#zoom-level { font-size: 11px; color: var(--text2); min-width: 30px; text-align: center; }

/* ═══ TIMELINE ═══ */
#timeline {
    height: var(--timeline-h); min-height: var(--timeline-h);
    background: var(--bg2); border-top: 1px solid var(--border);
}
#timeline-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 4px 12px; border-bottom: 1px solid var(--border);
    font-size: 12px; color: var(--text2);
}
#timeline-scroll {
    position: relative; height: calc(var(--timeline-h) - 30px);
    overflow-x: auto; overflow-y: hidden;
    padding: 8px 12px;
}
#timeline-playhead {
    position: absolute; top: 0; width: 2px; height: 100%;
    background: var(--accent); z-index: 10;
    pointer-events: none; left: 0;
}
#timeline-scenes {
    display: flex; gap: 4px; height: 60px; position: relative;
    width: max-content; min-width: 100%;
}
#timeline-audio {
    display: flex; gap: 4px; height: 40px; margin-top: 6px;
    width: max-content; min-width: 100%;
}

.timeline-scene {
    height: 60px; min-width: 60px; border-radius: 6px;
    border: 2px solid var(--border); cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    font-size: 10px; color: var(--text2); position: relative;
    transition: border-color .15s;
    flex-shrink: 0;
}
.timeline-scene.active { border-color: var(--primary); }
.timeline-scene:hover { border-color: var(--text2); }
.timeline-scene .scene-label { font-weight: 600; color: var(--text); }
.timeline-scene .scene-dur { font-size: 9px; }
.timeline-scene .scene-trans {
    position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
    font-size: 10px; background: var(--accent); color: #000;
    border-radius: 3px; padding: 1px 3px; font-weight: 700;
}

.timeline-audio-track {
    height: 40px; border-radius: 6px;
    background: linear-gradient(135deg, #22543d, #065f46);
    border: 1px solid #22c55e55;
    display: flex; align-items: center; padding: 0 10px;
    font-size: 11px; color: #86efac; cursor: pointer;
    min-width: 100px;
}
.timeline-audio-track.active { border-color: var(--success); }

/* ═══ TOOLS PANEL ═══ */
#tools {
    width: var(--tools-w); min-width: var(--tools-w);
    background: var(--bg2); border-left: 1px solid var(--border);
    display: flex; flex-direction: column; overflow-y: auto;
}
.tool-tabs {
    display: flex; border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.tool-tab {
    flex: 1; padding: 8px 4px; background: none; border: none;
    color: var(--text2); font-size: 11px; cursor: pointer;
    border-bottom: 2px solid transparent;
}
.tool-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; padding: 10px; overflow-y: auto; flex: 1; }
.tab-content.active { display: block; }

.tool-group { margin-bottom: 12px; }
.tool-group > label { display: block; font-size: 11px; color: var(--text2); margin-bottom: 4px; }
.row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.mini { font-size: 10px; color: var(--text2); min-width: 14px; }

input[type="number"], input[type="text"], select, textarea {
    background: var(--bg3); color: var(--text); border: 1px solid var(--border);
    padding: 4px 6px; border-radius: 4px; font-size: 12px; width: 100%;
}
input[type="number"] { width: 60px; }
input[type="color"] { width: 36px; height: 26px; border: 1px solid var(--border); border-radius: 4px; cursor: pointer; padding: 1px; }
input[type="range"] { width: 100%; accent-color: var(--primary); }
textarea { resize: vertical; font-family: inherit; }

.color-presets {
    display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px;
}
.color-preset {
    width: 22px; height: 22px; border-radius: 4px; border: 1px solid var(--border);
    cursor: pointer; transition: transform .1s;
}
.color-preset:hover { transform: scale(1.2); }

.shapes-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-bottom: 8px; }
.shapes-grid button {
    height: 36px; background: var(--bg3); border: 1px solid var(--border);
    color: var(--text); border-radius: 4px; cursor: pointer; font-size: 16px;
}
.shapes-grid button:hover { background: var(--surface); border-color: var(--primary); }

/* Layers / Objects list */
.layers-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.layer-item {
    padding: 5px 8px; border-radius: 4px; cursor: pointer; font-size: 11px;
    display: flex; align-items: center; gap: 6px;
    background: var(--bg3); border: 1px solid transparent;
}
.layer-item:hover { border-color: var(--border); }
.layer-item.active { border-color: var(--primary); background: var(--surface); }
.layer-item .type-icon { font-size: 12px; }
.layer-item .layer-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Asset gallery */
.asset-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.asset-thumb {
    aspect-ratio: 1; border-radius: 4px; overflow: hidden; cursor: pointer;
    border: 1px solid var(--border); position: relative;
    background: var(--bg3);
}
.asset-thumb img { width: 100%; height: 100%; object-fit: cover; }
.asset-thumb video { width: 100%; height: 100%; object-fit: cover; }
.asset-thumb .asset-badge {
    position: absolute; bottom: 2px; right: 2px;
    background: rgba(0,0,0,.7); font-size: 9px; padding: 1px 4px; border-radius: 3px;
}
.asset-thumb .delete-btn {
    position: absolute; top: 2px; right: 2px; display: none;
    background: var(--danger); color: #fff; border: none; border-radius: 50%;
    width: 16px; height: 16px; font-size: 10px; cursor: pointer;
    line-height: 16px; text-align: center;
}
.asset-thumb:hover .delete-btn { display: block; }

/* ═══ MODAL ═══ */
#modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.6);
    z-index: 100; display: flex; align-items: center; justify-content: center;
}
.modal {
    background: var(--bg2); border: 1px solid var(--border); border-radius: 8px;
    width: 380px; max-height: 80vh; overflow-y: auto;
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 14px; }
#modal-body { padding: 16px; }
#modal-body label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 4px; margin-top: 10px; }
#modal-body input, #modal-body textarea { width: 100%; margin-bottom: 4px; }
#modal-body .btn { margin-top: 12px; width: 100%; justify-content: center; }

/* ═══ RENDER OVERLAY ═══ */
#render-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.8);
    z-index: 200; display: flex; align-items: center; justify-content: center;
}
.render-dialog {
    background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
    padding: 30px 40px; text-align: center; min-width: 350px;
}
.render-dialog h3 { margin-bottom: 16px; }
.progress-bar {
    width: 100%; height: 10px; background: var(--bg3); border-radius: 5px;
    overflow: hidden; margin-bottom: 10px;
}
.progress-fill {
    height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent));
    width: 0%; transition: width .3s;
    border-radius: 5px;
}
#render-status { font-size: 13px; color: var(--text2); }

/* ═══ TOAST ═══ */
#toast-container { position: fixed; top: 60px; right: 16px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
    padding: 10px 16px; border-radius: 6px; font-size: 13px;
    background: var(--surface); border: 1px solid var(--border);
    animation: slideIn .2s ease;
    max-width: 300px;
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.info { border-color: var(--primary); }

@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Responsive */
@media (max-width: 900px) {
    #sidebar { display: none; }
    #tools { width: 220px; min-width: 220px; }
}
