/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0a0a0a;
    --bg-card: #141414;
    --bg-card-hover: #1a1a1a;
    --bg-input: #1e1e1e;
    --border: #2a2a2a;
    --text: #e0e0e0;
    --text-muted: #888;
    --text-dim: #555;
    --accent: #4a9eff;
    --accent-hover: #3a8eef;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --highlight: #fbbf24;
    --radius: 8px;
    --radius-sm: 4px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ===== Navbar ===== */
.navbar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 12px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand a {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 1px;
}

.nav-links { display: flex; gap: 16px; }
.nav-link { color: var(--text-muted); font-size: 14px; }
.nav-link:hover { color: var(--text); }

.nav-search {
    margin-left: auto;
    position: relative;
    width: 300px;
}

.nav-search input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 13px;
}

.nav-search input:focus {
    outline: none;
    border-color: var(--accent);
}

.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 200;
}

.search-results-dropdown {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 4px;
    max-height: 400px;
    overflow-y: auto;
}

.search-result-item {
    display: block;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.search-result-item:hover { background: var(--bg-card-hover); }
.search-result-title { font-weight: 600; font-size: 13px; }
.search-result-type { font-size: 11px; color: var(--accent); text-transform: uppercase; }
.search-result-snippet { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.search-see-all { display: block; padding: 10px; text-align: center; font-size: 13px; }
.search-no-results { padding: 12px; color: var(--text-muted); font-size: 13px; text-align: center; }

/* ===== Container ===== */
.container { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* ===== Hero ===== */
.hero { text-align: center; padding: 40px 0 20px; }
.hero h1 { font-size: 28px; font-weight: 700; }
.hero-sub { color: var(--text-muted); margin-top: 8px; }

/* ===== Submit Form ===== */
.submit-section { margin: 24px 0; }

.submit-form .form-row {
    display: flex;
    gap: 8px;
}

.input-url { flex: 2; }
.input-tags { flex: 1; }

.submit-form input {
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
}

.submit-form input:focus { outline: none; border-color: var(--accent); }

.htmx-indicator { display: none; color: var(--text-muted); font-size: 13px; margin-left: 8px; }
.htmx-request .htmx-indicator { display: inline; }

/* ===== Buttons ===== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-input); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-card-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-small { padding: 6px 12px; font-size: 12px; }

/* ===== Alerts ===== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin: 12px 0;
    font-size: 14px;
}

.alert-success { background: rgba(34, 197, 94, 0.15); border: 1px solid rgba(34, 197, 94, 0.3); color: var(--success); }
.alert-error { background: rgba(239, 68, 68, 0.15); border: 1px solid rgba(239, 68, 68, 0.3); color: var(--danger); }

/* ===== Video Grid ===== */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.video-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.15s, transform 0.15s;
    color: var(--text);
    display: block;
}

.video-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.video-card-header {
    display: flex;
    justify-content: space-between;
    padding: 10px 14px 0;
}

.video-card-body { padding: 10px 14px 14px; }
.video-card-body h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.video-meta { font-size: 13px; color: var(--text-muted); }
.video-date { font-size: 12px; color: var(--text-dim); margin-top: 6px; }

/* ===== Status Badges ===== */
.status-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-queued { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
.status-downloading, .status-transcribing, .status-detecting_scenes, .status-analyzing, .status-indexing {
    background: rgba(74, 158, 255, 0.2); color: var(--accent);
}
.status-completed { background: rgba(34, 197, 94, 0.2); color: var(--success); }
.status-failed { background: rgba(239, 68, 68, 0.2); color: var(--danger); }

.duration-badge {
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== Tags ===== */
.tag-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tag {
    font-size: 11px;
    padding: 2px 8px;
    background: var(--bg-input);
    border-radius: 12px;
    color: var(--text-muted);
}

/* ===== Progress ===== */
.progress-section { margin: 20px 0; }

.progress-bar-container {
    background: var(--bg-input);
    border-radius: var(--radius);
    height: 24px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #6366f1);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    transition: width 0.5s ease;
    min-width: 30px;
}

.progress-small { height: 6px; }
.progress-small .progress-bar { font-size: 0; min-width: 4px; }
.progress-message { font-size: 13px; color: var(--text-muted); margin-top: 6px; }
.progress-text { font-size: 12px; color: var(--text-muted); }

/* ===== Queue ===== */
.queue-section, .recent-section { margin: 32px 0; }
.queue-section h2, .recent-section h2 { font-size: 18px; margin-bottom: 12px; }

.queue-list { display: flex; flex-direction: column; gap: 8px; }

.queue-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.queue-title { font-size: 14px; flex: 1; }

/* ===== Detail Page ===== */
.detail-header { margin-bottom: 24px; }
.detail-title { display: flex; align-items: center; gap: 12px; }
.detail-title h1 { font-size: 24px; }

.detail-meta {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    font-size: 14px;
    color: var(--text-muted);
}

.detail-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* ===== Video Player ===== */
.player-section { margin: 20px 0; }
.video-player {
    width: 100%;
    max-height: 500px;
    border-radius: var(--radius);
    background: #000;
}

/* ===== Notes ===== */
.notes-section { margin: 20px 0; }
.notes-section h2 { font-size: 16px; margin-bottom: 8px; }

.notes-input {
    width: 100%;
    min-height: 60px;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
}

.notes-input:focus { outline: none; border-color: var(--accent); }
.notes-small { min-height: 40px; }

/* ===== Transcript ===== */
.transcript-section { margin: 24px 0; }
.transcript-section h2 { font-size: 16px; margin-bottom: 8px; }

.transcript-list {
    max-height: 200px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px;
}

.transcript-segment {
    display: flex;
    gap: 12px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
}

.transcript-segment:hover { background: var(--bg-card-hover); }
.transcript-time { color: var(--accent); font-variant-numeric: tabular-nums; min-width: 50px; }

/* ===== Timeline ===== */
.timeline-section { margin: 24px 0; }
.timeline-section h2 { font-size: 16px; margin-bottom: 8px; }

.timeline {
    display: flex;
    height: 32px;
    gap: 2px;
    border-radius: var(--radius);
    overflow: hidden;
}

.timeline-shot {
    background: var(--bg-card);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s;
    min-width: 20px;
}

.timeline-shot:hover { background: var(--accent); }
.timeline-shot:nth-child(odd) { background: var(--bg-input); }
.timeline-label { font-size: 10px; font-weight: 600; }

/* ===== Shot Cards ===== */
.shots-section { margin: 24px 0; }
.shots-section h2 { font-size: 18px; margin-bottom: 16px; }

.shot-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    overflow: hidden;
}

.shot-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-input);
}

.shot-card-header h3 { font-size: 15px; font-weight: 700; }
.shot-timing { font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.shot-card-content {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 0;
}

.shot-keyframe {
    border-right: 1px solid var(--border);
    background: #000;
    display: flex;
    align-items: flex-start;
}

.shot-keyframe img {
    width: 100%;
    height: auto;
    display: block;
}

.shot-analysis { padding: 16px; }

.analysis-group {
    margin-bottom: 14px;
}

.analysis-group h4 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.analysis-fields { display: flex; flex-direction: column; gap: 3px; }

.field {
    display: flex;
    gap: 8px;
    font-size: 13px;
    line-height: 1.5;
}

.field-label {
    min-width: 90px;
    color: var(--text-muted);
    font-weight: 500;
}

.field-value { color: var(--text); }
.field-value.highlight { color: var(--highlight); }

.shot-transcript {
    font-style: italic;
    color: var(--text-muted);
    font-size: 13px;
}

/* ===== Library ===== */
.library-header { margin-bottom: 24px; }
.library-header h1 { font-size: 24px; margin-bottom: 12px; }

.filter-form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.input-search {
    flex: 1;
    min-width: 200px;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
}

.input-select {
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 24px;
    color: var(--text-dim);
    font-size: 12px;
    border-top: 1px solid var(--border);
    margin-top: 48px;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 24px;
    font-size: 14px;
}

/* ===== Error Page ===== */
.error-page {
    text-align: center;
    padding: 80px 20px;
}
.error-page h1 { font-size: 64px; color: var(--text-dim); }
.error-page p { color: var(--text-muted); margin: 12px 0 24px; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .navbar { flex-wrap: wrap; gap: 8px; }
    .nav-search { width: 100%; order: 3; }
    .submit-form .form-row { flex-direction: column; }
    .shot-card-content { grid-template-columns: 1fr; }
    .shot-keyframe { border-right: none; border-bottom: 1px solid var(--border); }
    .video-grid { grid-template-columns: 1fr; }
    .filter-form { flex-direction: column; }
}
