/* ─── Dashboard Layout ────────────────────────────────────────────────────── */

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: white;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-left h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.header-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

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

.credit-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
}
.credit-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(243, 156, 18, 0.4);
}
.credit-badge i { font-size: 0.9rem; }

.user-email {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ─── Navigation Tabs ────────────────────────────────────────────────────── */

.nav-tabs {
    display: flex;
    gap: 0;
    background: white;
    border-bottom: 2px solid var(--border);
    padding: 0 24px;
}

.nav-tab {
    padding: 14px 24px;
    background: none;
    border: none;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-tab:hover { color: var(--text); }
.nav-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ─── Main Content ───────────────────────────────────────────────────────── */

.dashboard-main {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px;
}

.tab-content { display: none; }
.tab-content.active { display: block; }
.tab-content.hidden { display: none; }

/* ─── Section Card ───────────────────────────────────────────────────────── */

.section-card {
    background: white;
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow);
}

.section-card h2 {
    font-size: 1.4rem;
    margin-bottom: 4px;
}

.section-desc {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* ─── Form Elements ──────────────────────────────────────────────────────── */

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.btn-full { width: 100%; }

.btn-primary.loading .btn-text,
.btn-danger.loading .btn-text { visibility: hidden; }
.btn-primary.loading .btn-spinner,
.btn-danger.loading .btn-spinner { display: block; }
.btn-primary .btn-spinner,
.btn-danger .btn-spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    position: absolute;
    left: 50%;
    top: 50%;
    margin-left: -10px;
    margin-top: -10px;
}

.btn-primary { position: relative; }
.btn-danger {
    position: relative;
    background: transparent;
    color: var(--error);
    border: 2px solid var(--error);
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}
.btn-danger:hover { background: var(--error); color: white; }

/* ─── Upload Zones ───────────────────────────────────────────────────────── */

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 28px;
    text-align: center;
    margin-bottom: 16px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--primary);
    background: rgba(124, 58, 237, 0.03);
}

.upload-zone.has-file {
    border-color: var(--success);
    border-style: solid;
    cursor: default;
}

.upload-icon {
    font-size: 2rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.upload-label {
    font-weight: 500;
    color: var(--text);
}

.upload-link {
    color: var(--primary);
    text-decoration: underline;
    cursor: pointer;
}

.upload-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.upload-selected {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    color: var(--success);
    font-weight: 500;
}

.upload-selected.hidden { display: none; }
.upload-zone.has-file .upload-content { display: none; }
.upload-zone.has-file .upload-selected { display: flex; }

.remove-file-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0 4px;
}

.remove-file-btn:hover { color: var(--error); }

/* ─── Progress Bar ───────────────────────────────────────────────────────── */

.progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    margin-top: 12px;
    overflow: hidden;
    position: relative;
}

.progress-bar.hidden { display: none; }

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    position: absolute;
    right: 0;
    top: -20px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
}

/* ─── Sessions List ──────────────────────────────────────────────────────── */

.sessions-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.sessions-header h2 {
    font-size: 1.4rem;
}

.sessions-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.session-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.session-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.session-info h3 {
    font-size: 1rem;
    margin-bottom: 4px;
}

.session-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.created { background: var(--border); color: var(--text-secondary); }
.status-badge.analyzing { background: #fff3cd; color: #856404; }
.status-badge.analyzed { background: #d1ecf1; color: #0c5460; }
.status-badge.clipping { background: #fff3cd; color: #856404; }
.status-badge.clipped { background: #d4edda; color: #155724; }
.status-badge.drafts_ready { background: #d4edda; color: #155724; }
.status-badge.failed { background: #f8d7da; color: #721c24; }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 3rem;
    color: var(--border);
    margin-bottom: 16px;
}

.empty-state h3 {
    color: var(--text);
    margin-bottom: 8px;
}

/* ─── Session Detail ─────────────────────────────────────────────────────── */

.back-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 20px;
    font-size: 0.95rem;
    padding: 0;
}

.back-btn:hover { color: var(--primary-dark); }

.detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.detail-header h2 {
    font-size: 1.5rem;
}

/* ─── Step Cards ─────────────────────────────────────────────────────────── */

.step-card {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

.step-card.hidden { display: none; }

.step-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.step-toggle {
    cursor: pointer;
    user-select: none;
}

.step-toggle .toggle-icon {
    margin-left: auto;
    font-size: 0.85rem;
    color: var(--muted);
    transition: transform 0.25s ease;
}

.step-card.collapsed .toggle-icon {
    transform: rotate(180deg);
}

.step-card.collapsed .step-body {
    display: none;
}

.step-card.collapsed .step-header {
    margin-bottom: 0;
}

.step-number {
    width: 28px;
    height: 28px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
}

.step-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

/* ─── Highlights ─────────────────────────────────────────────────────────── */

.highlights-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.highlight-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    position: relative;
}

.highlight-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.highlight-score {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary);
}

.highlight-remove {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    padding: 2px 6px;
}

.highlight-remove:hover { color: var(--error); }

.highlight-title-input {
    width: 100%;
    font-size: 0.95rem;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 6px 8px;
    margin-bottom: 8px;
    transition: var(--transition);
}

.highlight-title-input:focus {
    border-color: var(--primary);
    outline: none;
    background: rgba(124, 58, 237, 0.03);
}

.highlight-times {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.highlight-time-input {
    width: 90px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    text-align: center;
    font-family: monospace;
}

.highlight-time-input:focus {
    border-color: var(--primary);
    outline: none;
}

.highlight-transcript {
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.5;
    max-height: 60px;
    overflow-y: auto;
    padding: 6px 8px;
    background: var(--bg);
    border-radius: 6px;
}

.highlight-transcript i {
    margin-right: 4px;
}

.highlight-category {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--border);
    color: var(--text-secondary);
    margin-left: 8px;
}

.highlights-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: flex-end;
}

/* ─── Clip Count Selector ───────────────────────────────────────────────── */

.clip-count-selector {
    margin-bottom: 20px;
}

.clip-count-label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 10px;
    color: var(--text);
}

.clip-count-chips {
    display: flex;
    gap: 8px;
}

.clip-count-chip {
    width: 36px;
    height: 36px;
    border: 2px solid var(--border);
    border-radius: 50%;
    background: white;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.clip-count-chip:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.clip-count-chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* ─── Subtitle Options ──────────────────────────────────────────────────── */

.subtitle-options {
    margin: 20px 0;
    padding: 16px 0;
    border-top: 1px solid var(--border);
}

.subtitle-label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 10px;
    color: var(--text);
}

.subtitle-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.subtitle-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 2px solid var(--border);
    border-radius: 20px;
    background: white;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.subtitle-chip:hover:not(.dimmed) {
    border-color: var(--primary);
    color: var(--primary);
}

.subtitle-chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.subtitle-chip.dimmed {
    opacity: 0.4;
    cursor: pointer;
}

.subtitle-chip.dimmed:hover {
    opacity: 0.7;
}

.platform-selector {
    margin-bottom: 20px;
}

/* ─── Clips ──────────────────────────────────────────────────────────────── */

.status-msg {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.status-msg.hidden { display: none; }
.status-msg.info { background: #d1ecf1; color: #0c5460; }
.status-msg.success { background: #d4edda; color: #155724; }
.status-msg.error { background: #f8d7da; color: #721c24; }

.clips-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.clip-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.clip-info h4 {
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.clip-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

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

.clip-download {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    color: white;
    background: var(--primary);
    transition: var(--transition);
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.clip-download:disabled {
    opacity: 0.7;
    cursor: wait;
}

.clip-download:hover { background: var(--primary-dark); }
.clip-download.secondary { background: var(--accent); }
.clip-download.secondary:hover { background: #1a252f; }
.clip-download.no-sub { background: #6c757d; }
.clip-download.no-sub:hover { background: #5a6268; }

.translation-error {
    width: 100%;
    margin-top: 8px;
    padding: 8px 12px;
    background: #fff3cd;
    color: #856404;
    border-radius: 6px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ─── Drafts ─────────────────────────────────────────────────────────────── */

.drafts-content {
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.drafts-content.hidden { display: none; }

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

.drafts-header-bar h4 {
    font-size: 0.9rem;
}

.copy-all-btn {
    background: none;
    border: 1px solid var(--border);
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
}

.copy-all-btn:hover { border-color: var(--primary); color: var(--primary); }

.drafts-body {
    padding: 16px;
    white-space: pre-wrap;
    font-size: 0.9rem;
    line-height: 1.7;
    max-height: 500px;
    overflow-y: auto;
}

/* ─── Draft Cards ───────────────────────────────────────────────────────── */

.draft-clip {
    padding: 16px;
}

.draft-clip + .draft-clip {
    border-top: 2px solid var(--border);
}

.draft-clip-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}

.draft-clip-title .toggle-icon {
    font-size: 0.8rem;
    color: var(--muted);
    transition: transform 0.25s ease;
}

.draft-clip.collapsed .draft-clip-title .toggle-icon {
    transform: rotate(180deg);
}

.draft-clip.collapsed .draft-clip-body {
    display: none;
}

.draft-clip.collapsed .draft-clip-title {
    margin-bottom: 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

/* Draft tabs */
.draft-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
    margin-bottom: 0;
}

.draft-tab {
    padding: 8px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.15s, border-color 0.15s;
}

.draft-tab:hover {
    color: var(--text);
}

.draft-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.draft-tab i {
    font-size: 0.9rem;
}

.draft-panel {
    display: none;
}

.draft-panel.active {
    display: block;
}

.draft-panel-toolbar {
    display: flex;
    justify-content: flex-end;
    padding: 10px 0 4px;
}

.draft-platform-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
}

.draft-platform-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.draft-platform-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 6px;
}

.draft-platform-name i {
    font-size: 1rem;
    color: var(--primary);
}

.draft-platform-body {
    padding: 12px 14px;
    font-size: 0.88rem;
    line-height: 1.6;
    color: var(--text);
}

.draft-copy-btn {
    background: none;
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
    white-space: nowrap;
}

.draft-copy-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* ─── Danger Zone ────────────────────────────────────────────────────────── */

.danger-zone {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    text-align: right;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 12px 16px;
    }

    .header-right { width: 100%; justify-content: space-between; }

    .nav-tabs { padding: 0 16px; overflow-x: auto; }
    .nav-tab { padding: 12px 16px; white-space: nowrap; font-size: 0.85rem; }

    .dashboard-main { padding: 16px; }

    .section-card { padding: 24px 16px; }

    .session-card { flex-direction: column; align-items: flex-start; gap: 8px; }

    .highlights-actions { flex-direction: column; width: 100%; }
    .highlights-actions .btn-primary,
    .highlights-actions .btn-secondary { width: 100%; text-align: center; }

    .clip-card { flex-direction: column; align-items: flex-start; gap: 12px; }
    .clip-actions { width: 100%; }
    .clip-download { flex: 1; justify-content: center; }
}

@media (max-width: 480px) {
    .header-left h1 { font-size: 1.3rem; }
    .upload-zone { padding: 20px 12px; }
    .detail-header { flex-direction: column; align-items: flex-start; }
}
