/* Video Pipeline Studio — Dark Theme */
:root {
    --bg-primary: #0a0a0f;
    --bg-card: #12121a;
    --bg-input: #1a1a28;
    --bg-hover: #1e1e2e;
    --text-primary: #e8e8f0;
    --text-secondary: #8888a0;
    --text-dim: #55556a;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --border: #2a2a3a;
    --radius: 12px;
    --radius-sm: 8px;
}

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

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

.app {
    max-width: 960px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0 32px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

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

.logo-icon {
    font-size: 32px;
}

.logo h1 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    font-weight: 600;
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 20px var(--accent-glow);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-accent {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
}

.btn-ghost:hover {
    background: var(--bg-input);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

.btn-large {
    padding: 14px 32px;
    font-size: 16px;
    width: 100%;
}

.btn-download {
    background: linear-gradient(135deg, #1a1a28, #1e2a38);
    border-color: var(--accent);
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
}

.card h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.card h3 {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin: 12px 0 8px;
}

/* Upload Zone */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.05);
}

.upload-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
}

.upload-hint {
    color: var(--text-dim);
    font-size: 13px;
    margin-top: 4px;
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
    margin: 8px 0;
}

.progress-bar.large {
    height: 10px;
    border-radius: 5px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    border-radius: inherit;
    transition: width 0.5s ease;
    width: 0;
}

/* File List */
.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    margin: 6px 0;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.file-item:hover {
    background: var(--bg-hover);
}

.file-item.selected {
    border: 1px solid var(--accent);
    background: rgba(99, 102, 241, 0.1);
}

.file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-size {
    color: var(--text-secondary);
    font-size: 12px;
    margin-left: 12px;
    white-space: nowrap;
}

.file-actions {
    display: flex;
    gap: 4px;
    margin-left: 8px;
}

/* Video Player */
.video-container {
    position: relative;
    width: 100%;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #000;
}

.video-container video {
    width: 100%;
    display: block;
    max-height: 400px;
}

.trim-controls {
    margin-top: 12px;
}

.trim-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.trim-row label {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.trim-row input[type="number"] {
    width: 70px;
    padding: 4px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
}

/* Options Grid */
.options-grid {
    display: grid;
    gap: 8px;
}

.option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s;
}

.option:hover {
    background: var(--bg-hover);
}

.option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

.option-info {
    flex: 1;
}

.option-title {
    display: block;
    font-size: 14px;
    font-weight: 500;
}

.option-desc {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
}

.option-param {
    font-size: 12px;
    color: var(--text-secondary);
}

.param-input {
    width: 50px;
    padding: 2px 6px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 12px;
}

.run-section {
    margin-top: 20px;
}

/* Pipeline Stages */
.pipeline-stages {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.stage-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    background: var(--bg-input);
    color: var(--text-dim);
    border: 1px solid var(--border);
    transition: all 0.3s;
}

.stage-badge.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    animation: pulse 1.5s infinite;
}

.stage-badge.done {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
    border-color: var(--success);
}

.stage-badge.error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
    border-color: var(--error);
}

.progress-text {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 var(--accent-glow);
    }

    50% {
        box-shadow: 0 0 12px 4px var(--accent-glow);
    }
}

/* Results Grid */
.results-grid {
    display: grid;
    gap: 8px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
}

.result-label {
    font-size: 14px;
    font-weight: 500;
}

.result-value {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 640px) {
    .app {
        padding: 12px;
    }

    header {
        flex-direction: column;
        gap: 12px;
    }

    .trim-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .output-toolbar {
        flex-direction: column;
        gap: 8px;
    }

    .toolbar-right {
        width: 100%;
    }

    .toolbar-right .btn {
        flex: 1;
    }

    .yt-modal {
        width: 95vw;
        max-height: 90vh;
    }

    .yt-field-row {
        flex-direction: column;
    }
}

/* ─── YouTube Upload Toolbar ──────────────────────────── */
.output-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    border: 1px solid var(--border);
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toolbar-right {
    display: flex;
    gap: 8px;
}

.select-all-label {
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.select-all-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

.selected-count {
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
}

.output-check {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
    margin-right: 8px;
}

/* YouTube Buttons */
.btn-yt {
    background: linear-gradient(135deg, #c4302b, #e53e3e);
    border-color: #c4302b;
    color: white;
    font-weight: 600;
}

.btn-yt:hover {
    background: linear-gradient(135deg, #e53e3e, #f56565);
    box-shadow: 0 0 16px rgba(229, 62, 62, 0.4);
    border-color: #e53e3e;
}

.btn-yt:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
}

.yt-icon {
    font-weight: 700;
}

.btn-yt-publish {
    background: linear-gradient(135deg, #16a34a, #22c55e);
    border-color: #16a34a;
    color: white;
    font-weight: 600;
}

.btn-yt-publish:hover {
    background: linear-gradient(135deg, #22c55e, #4ade80);
    box-shadow: 0 0 16px rgba(34, 197, 94, 0.4);
    border-color: #22c55e;
}

.btn-yt-publish:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
}

/* ─── YouTube Upload Modal ────────────────────────────── */
.yt-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.yt-modal-overlay[hidden] {
    display: none !important;
}

.yt-modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.25s ease-out;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(20px) scale(0.97);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.yt-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 12px;
    border-bottom: 1px solid var(--border);
}

.yt-modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.yt-modal-body {
    padding: 20px 24px;
}

.yt-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 24px 20px;
    border-top: 1px solid var(--border);
}

.yt-modal-footer .btn-large {
    width: auto;
    padding: 12px 28px;
    font-size: 14px;
}

/* Modal Fields */
.yt-field {
    margin-bottom: 16px;
}

.yt-field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.field-hint {
    font-weight: 400;
    color: var(--text-dim);
}

.yt-field input[type="text"],
.yt-field textarea,
.yt-field select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.2s;
    resize: vertical;
}

.yt-field input:focus,
.yt-field textarea:focus,
.yt-field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.yt-field-row {
    display: flex;
    gap: 12px;
}

.yt-field-row .yt-field {
    flex: 1;
}

/* Files Preview in Modal */
.yt-preview-label {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 6px;
    font-weight: 500;
}

.yt-preview-file {
    font-size: 13px;
    padding: 6px 10px;
    background: var(--bg-input);
    border-radius: 4px;
    margin: 4px 0;
    color: var(--text-secondary);
}

.yt-thumb-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.yt-thumb-status {
    font-size: 12px;
    color: var(--text-dim);
}

.yt-thumb-preview {
    margin-top: 8px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.yt-thumb-preview img {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    display: block;
}

.btn-accent {
    background: linear-gradient(135deg, #00b894, #00cec9);
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-accent:hover {
    filter: brightness(1.15);
}

.btn-accent:disabled {
    opacity: 0.5;
    cursor: wait;
}

.yt-upload-status {
    font-size: 13px;
    padding: 8px 10px;
    border-radius: 4px;
    margin: 4px 0;
}

.yt-upload-status a {
    color: var(--success);
}