:root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e5e7eb;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-600: #1d4ed8;
    --ring: rgba(37, 99, 235, 0.35);
}

/* Base */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
    color: var(--text);
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    line-height: 1.5;
}

/* Navigation */
.nav-links {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    margin-bottom: 24px;
    gap: 8px;
}
.nav-links a {
    display: inline-block;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background-color .2s ease, color .2s ease;
}
.nav-links a:hover {
    background: #eff6ff;
    color: var(--primary-600);
}

/* Containers */
.container,
.form-container {
    background-color: var(--surface);
    padding: 28px;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 10px 25px rgba(2,6,23,0.06), 0 2px 8px rgba(2,6,23,0.04);
}
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.form-container h1 { margin: 0 0 6px 0; font-size: 28px; letter-spacing: -0.01em; }
.form-container h3 { margin: 0 0 18px 0; color: var(--muted); font-weight: 500; }

/* Forms */
.form-group { margin-bottom: 18px; }
label { display: block; margin-bottom: 8px; font-weight: 600; }
input[type="file"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    transition: box-shadow .2s ease, border-color .2s ease;
}
input[type="file"]:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }
textarea,
select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    background: #fff;
    transition: box-shadow .2s ease, border-color .2s ease;
}
textarea {
    resize: vertical;
    min-height: 80px;
}
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--ring);
}
.help-text { margin-top: 8px; color: var(--muted); font-size: 13px; }
.checkbox-group { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.checkbox-group input[type="checkbox"] { accent-color: var(--primary); width: 16px; height: 16px; }

.advanced-toggle {
    background-color: #f1f5f9;
    color: var(--text);
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    margin: 6px 0 16px 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background-color .2s ease, border-color .2s ease, color .2s ease;
}
.advanced-toggle::after { content: '▾'; display: inline-block; transform: translateY(-1px) rotate(0deg); transition: transform .2s ease; }
.advanced-toggle.active::after { transform: translateY(-1px) rotate(-180deg); }
.advanced-toggle:hover { background-color: #e2e8f0; }
.advanced-toggle.active { color: var(--primary-600); border-color: #bfdbfe; background: #eff6ff; }
.advanced-options { display: none; padding: 16px; background-color: #f8fafc; border-radius: 12px; border: 1px dashed #cbd5e1; margin-bottom: 16px; }
.advanced-options.show { display: block; }

button[type="submit"],
.btn-primary {
    background-color: var(--primary);
    color: white;
    padding: 12px 18px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: transform .06s ease, background-color .2s ease, box-shadow .2s ease;
    box-shadow: 0 6px 14px rgba(37,99,235,0.25);
}
button[type="submit"]:hover, .btn-primary:hover { background-color: var(--primary-600); }
button[type="submit"]:active, .btn-primary:active { transform: translateY(1px); box-shadow: 0 4px 10px rgba(37,99,235,0.25); }
button[disabled] { opacity: .6; cursor: not-allowed; }

.btn-secondary { padding: 8px 12px; border: 1px solid var(--border); background-color: #fff; color: #334155; cursor: pointer; border-radius: 8px; }
.btn-secondary:hover { background-color: #eef2f7; color: var(--primary-600); border-color: #cbd5f5; }
.btn-secondary:active { transform: translateY(1px); box-shadow: 0 2px 6px rgba(15,23,42,0.12); }
.btn-secondary:disabled { opacity: .6; cursor: not-allowed; }

/* Accessible hidden */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Drag & drop */
.file-drop { border: 2px dashed #cbd5e1; background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%); border-radius: 12px; padding: 28px; text-align: center; color: var(--muted); cursor: pointer; transition: background-color .2s ease, border-color .2s ease, color .2s ease; user-select: none; }
.file-drop:hover { background: #eef2f7; }
.file-drop.dragover { background: #eff6ff; border-color: #93c5fd; color: var(--primary-600); }
.file-name { margin-top: 10px; color: var(--muted); font-size: 13px; }
.upload-progress { margin-top: 16px; }
.progress { width: 100%; height: 10px; background: #e5e7eb; border-radius: 9999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: var(--primary); transition: width .15s ease; }
.progress-text { margin-top: 8px; font-size: 13px; color: var(--muted); }

/* Tables (jobs) */
.jobs-table { width: 100%; border-collapse: collapse; }
.jobs-table th, .jobs-table td { padding: 12px; text-align: left; border-bottom: 1px solid var(--border); }
.jobs-table th { background-color: #f8fafc; font-weight: 700; color: #334155; }
.jobs-table tr:hover { background-color: #f8fafc; }
.file-name-cell { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-name-cell { max-width: 310px; word-wrap: break-word; word-break: break-word; }

/* Pagination */
.pagination { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 20px; }
.pagination button { padding: 8px 12px; border: 1px solid var(--border); background-color: #fff; color: #334155; cursor: pointer; border-radius: 8px; }
.pagination button:hover:not(:disabled) { background-color: #f1f5f9; }
.pagination button:disabled { opacity: 0.5; cursor: not-allowed; }
.pagination .current-page { padding: 8px 12px; background-color: var(--primary); color: white; border-radius: 8px; }
.pagination-info { margin: 0 20px; color: #64748b; }

/* Status badges */
.status-badge { display: inline-block; padding: 4px 8px; border-radius: 6px; font-size: 0.8em; font-weight: 700; text-transform: capitalize; }
.status-starting { background-color: #e3f2fd; color: #1d4ed8; }
.status-generating-transcript { background-color: #e8f5e9; color: #166534; }
.status-generating-segments { background-color: #f3e8ff; color: #6b21a8; }
.status-cropping-segments { background-color: #fff7ed; color: #c2410c; }
.status-cropping-full-video { background-color: #ecfeff; color: #155e75; }
.status-adding-captions { background-color: #fdf2f8; color: #9d174d; }
.status-completed { background-color: #e8f5e9; color: #166534; }
.status-failed { background-color: #fee2e2; color: #b91c1c; }
/* legacy */
.status-pending { background-color: #fff7ed; color: #b45309; }
.status-processing { background-color: #dbeafe; color: #1d4ed8; }

/* Video detail */
.video-header { margin-bottom: 24px; text-align: center; }
.video-title { font-size: 1.8em; font-weight: 800; margin-bottom: 8px; color: #0f172a; }
.video-type { display: inline-block; padding: 6px 12px; background-color: #e3f2fd; color: #1d4ed8; border-radius: 20px; font-size: 0.9em; font-weight: 600; }
.video-container { width: 50%; max-width: 450px; margin: 0 auto; background-color: #000; border-radius: 8px; overflow: hidden; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.video-player { width: 100%; height: auto; display: block; }
.video-info { margin-top: 30px; padding: 20px; background-color: #f8fafc; border-radius: 12px; border: 1px solid var(--border); }
.video-info h3 { margin-top: 0; color: #0f172a; }
.video-description { background-color: #e2e8f0; padding: 12px; border-radius: 8px; margin: 10px 0; line-height: 1.6; }
.video-caption { background-color: #eff6ff; padding: 12px; border-radius: 8px; margin: 10px 0; line-height: 1.6; border-left: 4px solid var(--primary); font-style: italic; }
.video-transcript { background-color: #f8fafc; padding: 12px; border-radius: 8px; margin: 10px 0; font-family: monospace; white-space: pre-wrap; line-height: 1.5; max-height: 200px; overflow-y: auto; border: 1px solid var(--border); }
.video-transcript-editor {
    width: 100%;
    min-height: 220px;
    margin-top: 14px;
}
.video-url { word-break: break-all; background-color: #f1f5f9; padding: 10px; border-radius: 8px; font-family: monospace; font-size: 0.9em; color: #334155; }
.video-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 15px; }
.video-links .video-link { display: inline-block; padding: 8px 12px; border: 1px solid var(--border); background: #ffffff; color: var(--primary); border-radius: 10px; font-weight: 600; text-decoration: none; transition: background-color .2s ease, color .2s ease, border-color .2s ease, transform .06s ease; }
.video-links .video-link:hover { background: #eff6ff; color: var(--primary-600); border-color: #bfdbfe; }
.video-links .video-link:active { transform: translateY(1px); }
.video-links span.video-link { background: #f1f5f9; color: #64748b; border: 1px dashed #cbd5e1; cursor: default; }

/* Collapsible sections (job detail) */
.collapsible-section { margin: 15px 0; }
.collapsible-header { background-color: #f1f5f9; padding: 10px; border-radius: 8px; cursor: pointer; user-select: none; display: flex; justify-content: space-between; align-items: center; }
.collapsible-header:hover { background-color: #e2e8f0; }
.collapsible-content { display: none; margin-top: 10px; }
.collapsible-content.expanded { display: block; }
.toggle-icon { font-weight: bold; font-size: 1.2em; }

/* Utility */
.card { background-color: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 16px; box-shadow: 0 2px 8px rgba(2,6,23,0.06); }
.loading { text-align: center; padding: 40px; color: #64748b; }
.error { text-align: center; padding: 40px; color: #b91c1c; background-color: #fee2e2; border-radius: 8px; }
.job-link { color: var(--primary); text-decoration: none; font-weight: 600; }
.job-link:hover { text-decoration: underline; color: var(--primary-600); }
.code-block { background-color: #f8fafc; padding: 12px; border: 1px solid var(--border); border-radius: 8px; font-family: monospace; white-space: pre-wrap; line-height: 1.5; max-height: 400px; overflow-y: auto; }

/* Lists */
.video-list { display: grid; gap: 20px; }
.video-item { background-color: #fff; padding: 20px; border-radius: 12px; border: 1px solid var(--border); box-shadow: 0 1px 3px rgba(0,0,0,0.06); }

/* Status page specific */
.status-container { background-color: var(--surface); padding: 28px; border-radius: 16px; border: 1px solid var(--border); box-shadow: 0 10px 25px rgba(2,6,23,0.06), 0 2px 8px rgba(2,6,23,0.04); }
.status-item { margin-bottom: 15px; padding: 12px; background-color: #fff; border: 1px solid var(--border); border-radius: 12px; }

/* App header */
.app-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.app-header .title { display: flex; align-items: center; gap: 10px; font-weight: 800; color: var(--text); letter-spacing: -0.01em; }
.app-header .title .brand { color: var(--primary); text-decoration: none; padding: 6px 10px; border-radius: 8px; }
.app-header .title .brand:hover { background: #eff6ff; color: var(--primary-600); }
.app-header .links { display: flex; gap: 8px; }
.app-header .links a { color: var(--primary); text-decoration: none; font-weight: 600; padding: 6px 10px; border-radius: 8px; }
.app-header .links a:hover { background: #eff6ff; color: var(--primary-600); }


/* RTL utilities */
.rtl { direction: rtl; unicode-bidi: plaintext; }
.rtl .video-title,
.rtl .video-description,
.rtl .video-caption,
.rtl .video-transcript,
.rtl .code-block,
.rtl p,
.rtl h1,
.rtl h2,
.rtl h3,
.rtl h4,
.rtl h5,
.rtl h6 { text-align: right; }

