/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, sans-serif; background: #f8fafc; color: #0f172a; font-size: 14px; }
a { color: inherit; text-decoration: none; }

/* ===== LAYOUT ===== */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px;
    background: #1e293b;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.sidebar-header { padding: 20px 16px; border-bottom: 1px solid #334155; }
.logo { font-size: 15px; font-weight: 700; color: #f8fafc; }
.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-link {
    display: block;
    padding: 10px 16px;
    color: #94a3b8;
    font-size: 14px;
    transition: background 0.15s, color 0.15s;
}
.nav-link:hover, .nav-link.active { background: #334155; color: #f8fafc; }
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid #334155;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.username { font-size: 13px; color: #94a3b8; flex: 1; }
.badge { background: #3b82f6; color: #fff; padding: 2px 6px; border-radius: 4px; font-size: 11px; }
.btn-logout { background: none; border: 1px solid #475569; color: #94a3b8; padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.btn-logout:hover { background: #334155; color: #f8fafc; }

.content { flex: 1; padding: 28px 32px; overflow-y: auto; }

/* ===== LOGIN ===== */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-box { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 40px; width: 360px; box-shadow: 0 4px 24px rgba(0,0,0,0.07); }
.login-box h1 { font-size: 22px; margin-bottom: 28px; text-align: center; }

/* ===== FORMS ===== */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group label { font-size: 13px; font-weight: 600; color: #475569; }
.form-group input, .form-group select, select, input[type="text"], input[type="password"] {
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    color: #0f172a;
    outline: none;
    transition: border-color 0.15s;
}
.form-group input:focus, select:focus, input[type="text"]:focus { border-color: #38bdf8; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: #38bdf8; color: #fff; }
.btn-secondary { background: #f1f5f9; color: #334155; border-color: #cbd5e1; }
.btn-danger { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.btn-block { width: 100%; justify-content: center; padding: 12px; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ===== ALERTS ===== */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    gap: 16px;
}
.page-header h2 { font-size: 22px; margin-top: 4px; }
.header-actions { display: flex; gap: 10px; align-items: center; }
.back-link { color: #64748b; font-size: 13px; font-weight: 600; }

/* ===== TABLE ===== */
.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; border: 1px solid #e2e8f0; }
.table th { padding: 12px 14px; text-align: left; font-size: 12px; font-weight: 700; color: #64748b; background: #f8fafc; border-bottom: 1px solid #e2e8f0; text-transform: uppercase; letter-spacing: 0.04em; }
.table td { padding: 12px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f8fafc; }
.text-muted { color: #94a3b8; }
.thumbnail { width: 80px; height: 45px; object-fit: cover; border-radius: 4px; }

/* ===== STATUS BADGES ===== */
.status-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid;
}
.status-pending    { background: #fef9c3; color: #854d0e; border-color: #fde047; }
.status-downloading { background: #e0f2fe; color: #0369a1; border-color: #7dd3fc; }
.status-downloaded { background: #dcfce7; color: #166534; border-color: #86efac; }
.status-compressing { background: #fef9c3; color: #854d0e; border-color: #fde047; }
.status-error      { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.status-draft      { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
.status-cut_done   { background: #dcfce7; color: #166534; border-color: #86efac; }
.status-transcribed { background: #e0e7ff; color: #3730a3; border-color: #a5b4fc; }
.status-translated { background: #dcfce7; color: #166534; border-color: #86efac; }
.status-transcribing { background: #fdf4ff; color: #c026d3; border-color: #f0abfc; }
.status-translating { background: #fefce8; color: #854d0e; border-color: #fde047; }
.status-cutting    { background: #fef9c3; color: #854d0e; border-color: #fde047; }
.status-sending    { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }

/* ===== PAGINATION ===== */
.pagination { display: flex; gap: 6px; margin-top: 16px; }
.page-link { padding: 6px 12px; border: 1px solid #e2e8f0; border-radius: 6px; font-size: 13px; }
.page-link.active { background: #38bdf8; color: #fff; border-color: #38bdf8; }

/* ===== EMPTY STATE ===== */
.empty-state { padding: 48px; text-align: center; color: #94a3b8; }

/* ===== MODAL ===== */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
.modal-box {
    position: relative;
    background: #fff;
    border-radius: 12px;
    padding: 28px;
    width: 480px;
    max-width: 95vw;
    z-index: 1;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-box h3 { margin-bottom: 20px; font-size: 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.modal-close { position: absolute; top: -36px; right: 0; background: none; border: none; color: #fff; font-size: 28px; cursor: pointer; }
.modal-close-inline { background: none; border: none; font-size: 24px; cursor: pointer; color: #64748b; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid #e2e8f0; }
.modal-header h3 { margin: 0; }
.modal-video-box { background: #000; max-width: 900px; width: 80vw; padding: 20px; }
.modal-transcript-box { max-width: 600px; width: 95vw; max-height: 80vh; overflow-y: auto; }

/* ===== CLIPS EDITOR ===== */
.editor-layout { display: flex; gap: 28px; flex: 1; }
.player-section { flex: 5; display: flex; flex-direction: column; gap: 14px; }
.player-wrapper { width: 100%; aspect-ratio: 16/9; background: #000; border-radius: 12px; overflow: hidden; }
.player-wrapper > div, #yt-player { width: 100%; height: 100%; }
.controls-panel { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.control-buttons-row { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.current-time-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.current-time-display { font-family: monospace; font-size: 20px; font-weight: 800; color: #0f172a; letter-spacing: 2px; }
.btn-preview-range { padding: 8px 16px; background: #fef9c3; color: #854d0e; border: 1px solid #fde047; border-radius: 8px; cursor: pointer; font-weight: 700; font-size: 13px; }
.btn-preview-range:hover { background: #fde047; }

/* Timeline */
.timeline-wrap { padding: 4px 0 2px; }
.timeline-bar { position: relative; height: 10px; background: #e2e8f0; border-radius: 10px; cursor: pointer; overflow: visible; }
.timeline-progress { position: absolute; left: 0; top: 0; height: 100%; background: #38bdf8; border-radius: 10px; pointer-events: none; }
.timeline-cursor { position: absolute; top: -4px; width: 3px; height: 18px; background: #0f172a; border-radius: 2px; transform: translateX(-50%); pointer-events: none; transition: left 0.1s; }
.timeline-clip-mark { position: absolute; top: -3px; height: 16px; border-radius: 3px; opacity: 0.75; cursor: pointer; min-width: 4px; }
.timeline-labels { display: flex; justify-content: space-between; font-size: 10px; color: #94a3b8; margin-top: 3px; font-family: monospace; }

/* Hotkeys hint */
.hotkeys-hint { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; padding: 10px 16px; font-size: 11px; color: #64748b; display: flex; flex-wrap: wrap; gap: 10px; }
.hotkey { display: flex; align-items: center; gap: 5px; }
.hotkey kbd { background: #e2e8f0; border-radius: 4px; padding: 2px 6px; font-family: monospace; font-size: 11px; font-weight: 700; color: #334155; }
.btn-ctrl {
    padding: 9px 14px;
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
}
.btn-micro { padding: 9px 10px; background: #e2e8f0; font-size: 12px; }
.btn-play { background: #38bdf8; color: #fff; border: none; min-width: 90px; justify-content: center; }

.sidebar-section { flex: 3; display: flex; flex-direction: column; gap: 18px; min-width: 380px; }
.card { background: #fff; padding: 22px; border-radius: 12px; border: 1px solid #e2e8f0; }
.card-clips { flex: 1; display: flex; flex-direction: column; }
.card-title { font-size: 16px; font-weight: 700; margin-bottom: 16px; }

.time-row { display: flex; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.time-block {
    flex: 1;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #f8fafc;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}
.time-block label { font-size: 12px; font-weight: 600; color: #475569; }
.time-input-wrapper { display: flex; gap: 6px; }
.time-input { flex: 1; min-width: 0; padding: 8px; border: 1px solid #cbd5e1; border-radius: 6px; font-family: monospace; font-size: 15px; font-weight: 700; text-align: center; }
.adjust-btns { display: flex; flex-direction: column; gap: 3px; }
.btn-adj { padding: 0 8px; font-size: 11px; font-weight: 700; background: #e2e8f0; border: none; border-radius: 4px; cursor: pointer; color: #475569; flex: 1; }
.btn-fetch-time { padding: 7px; background: #e0f2fe; color: #0284c7; border: 1px dashed #7dd3fc; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 600; width: 100%; margin-top: 4px; }
.lang-row { display: flex; gap: 12px; }
.btn-add-clip { width: 100%; padding: 13px; background: #f1f5f9; color: #0f172a; border: 1px dashed #94a3b8; border-radius: 8px; cursor: pointer; font-weight: 700; font-size: 14px; margin-top: 8px; }

.clips-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; max-height: 420px; padding-right: 4px; }
.empty-text { color: #94a3b8; text-align: center; padding: 32px 0; }
.clip-item {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-left: 4px solid #38bdf8;
    border-radius: 10px;
    padding: 14px;
    position: relative;
}
.clip-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.clip-header strong { font-family: monospace; font-size: 13px; cursor: pointer; }
.clip-header strong:hover { color: #0284c7; }
.clip-duration { font-size: 11px; color: #94a3b8; font-family: monospace; margin-left: 8px; }
.clip-preview-link { cursor: pointer; color: #0284c7; text-decoration: underline; }
.btn-remove { background: none; border: none; color: #ef4444; cursor: pointer; font-size: 16px; font-weight: 700; padding: 0; }
.clip-meta { display: flex; gap: 12px; font-size: 12px; color: #64748b; margin-bottom: 8px; }
.clip-status { margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.status-cutting, .status-transcribing, .status-translating, .status-sending, .status-pending {
    animation: pulse 1.2s ease-in-out infinite;
}
.clip-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-cut { background: #e0f2fe; color: #0284c7; border-color: #7dd3fc; }
.btn-transcribe { background: #fdf4ff; color: #c026d3; border-color: #f0abfc; }
.btn-view { background: #eff6ff; color: #2563eb; border-color: #bfdbfe; }
.btn-translate { background: #f0fdf4; color: #16a34a; border-color: #bbf7d0; }
.btn-process { width: 100%; padding: 14px; background: #38bdf8; color: #fff; border: none; border-radius: 10px; cursor: pointer; font-weight: 700; font-size: 15px; margin-top: 14px; }

/* Transcript */
.transcript-srt-links { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.transcript-content { display: flex; flex-direction: column; gap: 12px; }
.transcript-segment { padding: 10px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; }
.transcript-time { font-size: 11px; font-weight: 700; color: #0284c7; cursor: pointer; margin-bottom: 6px; text-decoration: underline; }
.transcript-orig { font-size: 13px; color: #334155; line-height: 1.5; border-left: 3px solid #cbd5e1; padding-left: 8px; margin-bottom: 6px; }
.transcript-translated { font-size: 13px; color: #0f172a; line-height: 1.5; border-left: 3px solid #38bdf8; padding-left: 8px; background: #f0f9ff; padding: 6px 8px; border-radius: 0 4px 4px 0; }

/* HTMX */
.htmx-indicator { display: none; animation: spin 1s linear infinite; }
.htmx-request .htmx-indicator { display: inline-block; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Actions column */
.actions { display: flex; gap: 6px; }
