/* ============================================
   Content Factory — Design System
   Notion/Stripe inspired, light theme
   ============================================ */

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

:root {
    --bg: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --bg-hover: #f9fafb;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --text: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-light: #eef2ff;
    --accent-subtle: rgba(99,102,241,0.08);
    --success: #10b981;
    --success-light: #ecfdf5;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --info: #3b82f6;
    --info-light: #eff6ff;
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 12px 24px rgba(0,0,0,0.12);
    --sidebar-width: 260px;
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-secondary);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

/* === LAYOUT === */
.layout { display: flex; min-height: 100vh; }
.content { flex: 1; margin-left: var(--sidebar-width); padding: 32px; max-width: 1200px; }

/* === SIDEBAR === */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.25s ease;
}
.sidebar.collapsed { transform: translateX(-100%); pointer-events: none; }
.content { transition: margin-left 0.25s ease; }
.sidebar-collapsed .content { margin-left: 0; max-width: none; }

.sidebar-header { padding: 20px 20px 16px; border-bottom: 1px solid var(--border-light); position: relative; }

/* Sidebar collapse/expand buttons */
.sidebar-collapse-btn {
    position: absolute; top: 22px; right: 12px;
    width: 28px; height: 28px; border-radius: 6px;
    background: transparent; border: none; color: var(--text-muted);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.sidebar-collapse-btn:hover { background: var(--bg-tertiary); color: var(--text); }

/* Expand zone — invisible wide hover area at left edge */
.sidebar-expand-zone {
    position: fixed; top: 0; left: 0; width: 24px; height: 100%;
    z-index: 90; cursor: pointer;
}
/* Thin visible strip indicator */
.sidebar-expand-strip {
    position: absolute; top: 50%; left: 0; transform: translateY(-50%);
    width: 4px; height: 48px; border-radius: 0 3px 3px 0;
    background: var(--border); opacity: 0.35;
    transition: all 0.2s ease;
}
.sidebar-expand-zone:hover .sidebar-expand-strip { opacity: 0; }
/* Button that appears on hover */
.sidebar-expand-btn-inner {
    position: absolute; top: 50%; left: 0; transform: translateY(-50%);
    width: 32px; height: 32px; border-radius: 0 var(--radius) var(--radius) 0;
    background: var(--bg); border: 1px solid var(--border); border-left: none;
    color: var(--text-secondary); display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-sm); opacity: 0; transition: all 0.2s ease;
}
.sidebar-expand-zone:hover .sidebar-expand-btn-inner { opacity: 1; color: var(--accent); }
.sidebar-header .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.sidebar-header .brand-icon {
    width: 32px; height: 32px; background: var(--accent); border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center; color: #fff;
}
.sidebar-header h2 { font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: -0.3px; }

.role-badge {
    display: inline-flex; align-items: center; padding: 2px 10px;
    border-radius: var(--radius-sm); font-size: 11px; font-weight: 600;
}
.role-superadmin { background: var(--accent-light); color: var(--accent); }
.role-admin_helper { background: var(--warning-light); color: #b45309; }
.role-curator { background: var(--info-light); color: #1d4ed8; }
.role-employee { background: var(--success-light); color: #047857; }

.nav-menu { list-style: none; flex: 1; padding: 12px 8px; }
.nav-section {
    padding: 16px 12px 6px; font-size: 11px; text-transform: uppercase;
    color: var(--text-muted); letter-spacing: 0.8px; font-weight: 600;
}
.nav-link {
    display: flex; align-items: center; gap: 10px; padding: 8px 12px;
    color: var(--text-secondary); text-decoration: none; border-radius: var(--radius);
    font-size: 13.5px; font-weight: 500; transition: all 0.15s ease; margin-bottom: 2px;
}
.nav-link:hover { background: var(--bg-tertiary); color: var(--text); }
.nav-link.active { background: var(--accent-light); color: var(--accent); }
.nav-link i { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.7; }
.nav-link.active i, .nav-link:hover i { opacity: 1; }

.sidebar-footer {
    padding: 16px; border-top: 1px solid var(--border-light);
    display: flex; align-items: center; gap: 10px;
}
.avatar {
    width: 32px; height: 32px; border-radius: 50%; background: var(--accent-light);
    color: var(--accent); display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.sidebar-footer .user-info { flex: 1; min-width: 0; }
.sidebar-footer .username { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer .user-role { font-size: 11px; color: var(--text-muted); }
.btn-logout {
    color: var(--text-muted); font-size: 13px; text-decoration: none;
    display: flex; align-items: center; padding: 4px; border-radius: var(--radius-sm); transition: all 0.15s;
}
.btn-logout:hover { color: var(--danger); background: var(--danger-light); }

/* === PAGE HEADER === */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.page-header h1 { font-size: 22px; font-weight: 700; color: var(--text); letter-spacing: -0.4px; }
.page-header .subtitle { font-size: 14px; color: var(--text-secondary); margin-top: 2px; }

/* === CARDS === */
.card {
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 16px; margin-bottom: 10px;
}
.card h3 { font-size: 15px; font-weight: 600; margin-bottom: 8px; color: var(--text); }

/* Stat cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 20px; display: flex; align-items: flex-start; gap: 16px; transition: all 0.2s;
}
.stat-card:hover { box-shadow: var(--shadow-sm); }
.stat-card .stat-icon {
    width: 40px; height: 40px; border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon.accent { background: var(--accent-light); color: var(--accent); }
.stat-icon.success { background: var(--success-light); color: var(--success); }
.stat-icon.warning { background: var(--warning-light); color: var(--warning); }
.stat-icon.info { background: var(--info-light); color: var(--info); }
.stat-icon.danger { background: var(--danger-light); color: var(--danger); }
.stat-card .stat-content { flex: 1; }
.stat-card .number { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1.1; }
.stat-card .label { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* === BUTTONS === */
.btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px;
    border: 1px solid transparent; border-radius: var(--radius); cursor: pointer;
    font-size: 13px; font-weight: 600; text-decoration: none; transition: all 0.15s ease;
    font-family: inherit; line-height: 1.4; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; box-shadow: var(--shadow-sm); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #059669; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-warning:hover { background: #d97706; color: #fff; }
.btn-outline { background: var(--bg); border: 1px solid var(--border); color: var(--text-secondary); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.btn-ghost { background: transparent; border: 1px solid transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-tertiary); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 8px 16px; font-size: 13px; }
.btn-icon { padding: 6px; width: 32px; height: 32px; justify-content: center; }

/* === TABLES === */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; }
th { font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.4px; border-bottom: 1px solid var(--border); background: var(--bg-secondary); }
td { border-bottom: 1px solid var(--border-light); font-size: 13.5px; }
tr:hover td { background: var(--bg-hover); }
tr:last-child td { border-bottom: none; }

/* === FORMS === */
.form-label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.form-group { margin-bottom: 10px; }
.form-group label { display: block; margin-bottom: 4px; font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.form-group input[type="text"], .form-group input[type="password"], .form-group input[type="number"],
.form-group input[type="email"], .form-group input[type="url"] {
    width: 100%; padding: 8px 12px; background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); font-size: 14px; font-family: inherit; transition: all 0.15s ease;
}
.form-group select {
    width: 100%; padding: 8px 36px 8px 12px; background-color: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); font-size: 14px; font-family: inherit; transition: all 0.15s ease;
    appearance: none; -webkit-appearance: none; -moz-appearance: none; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center; background-size: 14px;
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-subtle); }

/* === GLOBAL INPUT STYLING === */
input[type="text"], input[type="password"], input[type="number"],
input[type="email"], input[type="url"] {
    padding: 8px 12px;
    background: var(--bg, #fff);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input[type="text"]:focus, input[type="password"]:focus, input[type="number"]:focus,
input[type="email"]:focus, input[type="url"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle, rgba(99,102,241,0.08));
}
input[type="text"]:disabled, input[type="number"]:disabled {
    background: var(--bg-tertiary, #f3f4f6);
    color: var(--text-muted, #9ca3af);
    cursor: not-allowed;
}
textarea {
    padding: 8px 12px;
    background: var(--bg, #fff);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle, rgba(99,102,241,0.08));
}

/* === GLOBAL SELECT STYLING === */
select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding: 8px 36px 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background-color: var(--bg, #fff);
    color: var(--text, #111);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px;
    line-height: 1.4;
}
select:hover {
    border-color: var(--text-muted, #9ca3af);
}
select:focus {
    outline: none;
    border-color: var(--accent, #6366f1);
    box-shadow: 0 0 0 3px var(--accent-subtle, rgba(99,102,241,0.08));
}
select:disabled {
    background-color: var(--bg-tertiary, #f3f4f6);
    color: var(--text-muted, #9ca3af);
    cursor: not-allowed;
}

/* === Custom Dropdown (cf-dropdown) === */
.cf-dropdown { position: relative; }
.cf-dropdown-btn {
    display: flex; align-items: center; justify-content: space-between; width: 100%;
    padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg); color: var(--text); font-size: 14px; font-family: inherit;
    cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s;
}
.cf-dropdown-btn:hover { border-color: var(--text-muted); }
.cf-dropdown-btn.open { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-subtle); }
.cf-dropdown-btn svg { width: 14px; height: 14px; color: var(--text-muted); transition: transform 0.2s; flex-shrink: 0; }
.cf-dropdown-btn.open svg { transform: rotate(180deg); }
.cf-dropdown-list {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 50;
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1); padding: 4px; overflow: hidden;
    max-height: 260px; overflow-y: auto;
}
.cf-dropdown-item {
    padding: 8px 12px; font-size: 14px; color: var(--text); border-radius: 6px;
    cursor: pointer; transition: background 0.1s;
}
.cf-dropdown-item:hover { background: var(--bg-secondary); }
.cf-dropdown-item.active { background: var(--accent-light); color: var(--accent); font-weight: 500; }
select option {
    padding: 8px 12px;
    background: var(--bg, #fff);
    color: var(--text, #111);
}
select option:checked {
    background: var(--accent-light, #eef2ff);
    color: var(--accent, #6366f1);
}
.form-group input:disabled { background: var(--bg-tertiary); color: var(--text-muted); cursor: not-allowed; }
.form-group textarea {
    width: 100%; padding: 10px 14px; background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); font-size: 14px; font-family: inherit; resize: vertical; transition: all 0.15s ease;
}
.form-group textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-subtle); }
.textarea-styled {
    width: 100%; padding: 10px 14px; background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); font-size: 14px; font-family: inherit; resize: vertical; transition: all 0.15s ease;
}
.textarea-styled:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-subtle); }
input[type="color"] { width: 50px; height: 36px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; padding: 2px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); margin-right: 6px; width: 16px; height: 16px; cursor: pointer; }
.field-hint { display: block; font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.block-hint { color: var(--text-muted); font-size: 12px; margin-bottom: 8px; }
.form-actions { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border-light); }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.settings-grid .form-group { margin-bottom: 0; }

/* === ALERTS === */
.alert {
    padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px;
    display: flex; align-items: center; gap: 10px; border: 1px solid transparent; animation: slideDown 0.3s ease;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.alert-success { background: var(--success-light); color: #065f46; border-color: #a7f3d0; }
.alert-error { background: var(--danger-light); color: #991b1b; border-color: #fecaca; }
.alert-warning { background: var(--warning-light); color: #92400e; border-color: #fde68a; }
.alert-info { background: var(--info-light); color: #1e40af; border-color: #bfdbfe; }

/* === STATUS === */
.status {
    display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px;
    border-radius: var(--radius-sm); font-size: 12px; font-weight: 600;
}
.status-running { background: var(--info-light); color: #1d4ed8; }
.status-completed { background: var(--success-light); color: #047857; }
.status-error { background: var(--danger-light); color: #b91c1c; }
.status-pending, .status-new, .status-draft { background: var(--bg-tertiary); color: var(--text-muted); }
.status-queued { background: var(--warning-light); color: #92400e; }
.status-active { background: var(--success-light); color: #047857; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-dot.green { background: var(--success); }
.status-dot.red { background: var(--danger); }
.status-dot.yellow { background: var(--warning); }
.status-dot.blue { background: var(--info); }
.status-dot.gray { background: var(--text-muted); }

/* === TABS (horizontal) === */
.tab-nav { display: flex; gap: 2px; margin-bottom: 24px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tab-btn {
    padding: 10px 16px; background: none; border: none; border-bottom: 2px solid transparent;
    color: var(--text-muted); cursor: pointer; font-size: 13px; font-weight: 600;
    font-family: inherit; transition: all 0.15s ease; white-space: nowrap;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { min-height: 200px; }

/* === TABS (vertical — settings) === */
.settings-layout { display: flex; gap: 0; min-height: 500px; }
.settings-nav { width: 220px; flex-shrink: 0; border-right: 1px solid var(--border-light); padding-right: 0; }
.settings-nav-btn {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 16px;
    background: none; border: none; border-radius: var(--radius) 0 0 var(--radius);
    color: var(--text-secondary); cursor: pointer; font-size: 13px; font-weight: 500;
    font-family: inherit; text-align: left; transition: all 0.15s ease; margin-bottom: 2px;
}
.settings-nav-btn:hover { background: var(--bg-tertiary); color: var(--text); }
.settings-nav-btn.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.settings-nav-btn i { width: 16px; height: 16px; flex-shrink: 0; }
.settings-body { flex: 1; padding: 0 0 0 32px; min-width: 0; }

/* === PROGRESS BAR === */
.progress-bar { width: 100%; height: 6px; background: var(--bg-tertiary); border-radius: 3px; overflow: hidden; }
.progress-bar .fill { height: 100%; background: linear-gradient(90deg, var(--accent), #818cf8); border-radius: 3px; transition: width 0.4s ease; }
.progress-bar.sm { height: 4px; }

/* === PROJECT CARDS === */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.project-card {
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 20px; transition: all 0.2s ease; cursor: pointer; text-decoration: none; color: inherit;
    display: flex; flex-direction: column; min-height: 150px;
}
.project-card:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); color: inherit; transform: translateY(-1px); }
.project-card h4 { font-size: 15px; font-weight: 600; margin: 0; color: var(--text); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.35; }
.project-card .meta { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.project-card .actions { display: flex; gap: 8px; margin-top: 12px; }

/* === VIDEO CARDS (channel detail — flat video list) === */
.videos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.video-card {
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 16px 20px; transition: all 0.2s ease;
}
.video-card:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.video-card-title {
    font-size: 14px; font-weight: 600; margin-bottom: 0; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.video-card-title:hover { color: var(--primary); }

/* Stage progress bar (9 segments) */
.stage-progress { display: flex; gap: 2px; margin-top: 10px; }
.stage-dot {
    flex: 1; height: 5px; border-radius: 2.5px;
    background: var(--bg-tertiary); transition: background 0.3s;
}
.stage-dot.filled { background: var(--accent); }
.stage-dot.active {
    background: #6366f1;
    animation: stage-pulse 1.5s ease-in-out infinite;
}
@keyframes stage-pulse { 0%,100%{opacity:1} 50%{opacity:0.5} }

/* Batch tag */
.batch-tag {
    display: inline-block; font-size: 10px; color: var(--text-muted);
    background: var(--bg-tertiary); padding: 1px 8px; border-radius: 4px; margin-top: 8px;
}

/* Video error */
.video-error { color: var(--danger); font-size: 12px; margin-top: 6px; line-height: 1.3; }

/* Video card actions */
.video-card-actions { display: flex; gap: 6px; margin-top: 10px; align-items: center; }
.video-action-delete { margin-left: auto; color: var(--danger) !important; opacity: 0.4; transition: opacity 0.2s; }
.video-action-delete:hover { opacity: 1; }

/* === TOPIC LIST === */
.topic-list { list-style: none; }
.topic-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border-light); }
.topic-item:last-child { border-bottom: none; }
.topic-num {
    background: var(--bg-tertiary); width: 24px; height: 24px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; color: var(--text-secondary);
}
.topic-info { flex: 1; min-width: 0; }
.topic-info .name { font-size: 14px; font-weight: 500; }
.topic-info .stage { font-size: 12px; color: var(--text-muted); }

/* === CHANNEL CARDS === */
.channel-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.channel-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; }
.channel-card h4 { font-size: 11px; font-weight: 600; margin-bottom: 0; display: flex; align-items: center; gap: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel-card .slots { font-size: 16px; font-weight: 700; color: var(--text); }
.channel-card .slots-label { font-size: 10px; color: var(--text-muted); }
.channel-card.disabled { opacity: 0.5; }
.channel-card.at-max { border-color: #ef4444; box-shadow: 0 0 8px rgba(239,68,68,0.3); }
.channel-card.at-max .slots { color: #ef4444; }
.channel-card.at-max .fill { background: #ef4444 !important; }

/* === VOICE ROWS === */
.voice-row {
    display: flex; gap: 8px; align-items: center; margin-bottom: 8px;
    padding: 8px 12px; background: var(--bg-secondary); border-radius: var(--radius); border: 1px solid var(--border-light);
}
.voice-row input[type="text"], .voice-row input[type="password"] {
    padding: 7px 10px; background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text); font-size: 13px; font-family: inherit;
}
.voice-row input:focus { outline: none; border-color: var(--accent); }

/* === EMPTY STATE === */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .empty-icon { width: 48px; height: 48px; margin: 0 auto 16px; color: var(--text-muted); opacity: 0.4; }
.empty-state h4 { font-size: 16px; margin-bottom: 6px; color: var(--text-secondary); }
.empty-state p { font-size: 14px; color: var(--text-muted); margin-bottom: 16px; }

/* === MODAL === */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal { background: var(--bg); border-radius: var(--radius-xl); padding: 32px; width: 500px; max-width: 90%; max-height: 80vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal h3 { margin-bottom: 20px; }

/* === LOGIN === */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #f0f4ff 0%, #faf5ff 50%, #fef2f2 100%); }
.login-card { background: var(--bg); border-radius: var(--radius-xl); padding: 40px; width: 400px; max-width: 90%; box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.login-card .login-icon { width: 48px; height: 48px; background: var(--accent); border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center; color: #fff; margin: 0 auto 20px; }
.login-card h1 { text-align: center; font-size: 24px; font-weight: 700; margin-bottom: 2px; color: var(--text); letter-spacing: -0.5px; }
.login-card .login-tagline { text-align: center; font-size: 13px; font-weight: 500; color: var(--accent); margin-bottom: 6px; letter-spacing: 2px; text-transform: uppercase; }
.login-card .subtitle { text-align: center; color: var(--text-muted); margin-bottom: 28px; font-size: 14px; }
.login-card .error-msg { background: var(--danger-light); color: #b91c1c; padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; text-align: center; }
.login-card .btn { width: 100%; padding: 10px; font-size: 15px; justify-content: center; }

/* === QUICK ACTIONS === */
.actions-grid { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }
.action-card {
    display: flex; align-items: center; gap: 10px; padding: 12px 18px;
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
    text-decoration: none; color: var(--text-secondary); font-size: 13px; font-weight: 500; transition: all 0.15s ease;
}
.action-card:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.action-card i { width: 18px; height: 18px; }

/* === SERVICE CARDS (API check) === */
.service-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.service-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; transition: all 0.2s; }
.service-card .service-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.service-card .service-icon { width: 40px; height: 40px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; background: var(--bg-tertiary); color: var(--text-secondary); }
.service-card .service-name { font-weight: 600; font-size: 14px; }
.service-card .service-desc { font-size: 12px; color: var(--text-muted); }
.service-card.ok { border-color: var(--success); }
.service-card.error { border-color: var(--danger); }
.service-card.warning { border-color: var(--warning); }

/* Spinner */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.6s linear infinite; display: inline-block; }

/* === UTILITIES === */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* === MOBILE MENU === */
.mobile-menu-btn {
    display: none; position: fixed; top: 12px; left: 12px; z-index: 250;
    width: 40px; height: 40px; border-radius: var(--radius); background: var(--bg);
    border: 1px solid var(--border); cursor: pointer; align-items: center; justify-content: center;
    box-shadow: var(--shadow-sm); color: var(--text-secondary);
}
.mobile-menu-btn:hover { background: var(--bg-tertiary); }
.sidebar-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.3); z-index: 150;
}

/* === RESPONSIVE === */
/* Impersonation banner */
.impersonate-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #7c3aed, #6366f1);
    color: white;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
    box-shadow: var(--shadow-sm);
}
.impersonate-banner strong {
    color: #fbbf24;
}

/* === ANALYZER — Video Cards === */
.video-card {
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 16px; margin-bottom: 12px; transition: all 0.15s;
}
.video-card:hover { box-shadow: var(--shadow-sm); }
.video-card-header { display: flex; gap: 16px; }
.video-thumb {
    width: 120px; height: 68px; border-radius: var(--radius); background: var(--bg-tertiary);
    background-size: cover; background-position: center; flex-shrink: 0; position: relative;
}
.video-badge-short {
    position: absolute; bottom: 4px; right: 4px; background: #000; color: #fff;
    font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: 3px; letter-spacing: 0.3px;
}
.video-card-info { flex: 1; min-width: 0; }
.video-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; line-height: 1.3; }
.video-meta { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.video-meta span { display: inline-flex; align-items: center; gap: 3px; }
.video-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tag-badge {
    display: inline-flex; padding: 2px 8px; background: var(--bg-tertiary); border: 1px solid var(--border-light);
    border-radius: var(--radius-sm); font-size: 11px; color: var(--text-secondary); white-space: nowrap;
}
.tag-more { background: var(--accent-light); color: var(--accent); border-color: transparent; }
.video-card-actions { display: flex; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border-light); }

/* Retention bar */
.retention-bar-wrap { display: flex; align-items: center; gap: 4px; margin-top: 4px; }
.retention-bar { width: 40px; height: 6px; background: var(--bg-tertiary); border-radius: 3px; overflow: hidden; }
.retention-fill { height: 100%; background: var(--success); border-radius: 3px; }
.retention-label { font-size: 11px; color: var(--text-muted); margin-left: 4px; }

/* Transcript block */
.transcript-block {
    background: var(--bg-secondary); padding: 12px; border-radius: var(--radius);
    border: 1px solid var(--border-light);
}

/* Tags cloud */
.tags-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-cloud-item { padding: 4px 12px; cursor: default; }

/* ═══ STUDIO ═══ */
/* ═══════════════════════════════════════════════════════════════════
   STUDIO LAYOUT
   ═══════════════════════════════════════════════════════════════════ */
.studio-layout { display: flex; gap: 0; min-height: calc(100vh - 80px); margin: -32px; }

/* History sidebar */
.studio-history { width: 280px; flex-shrink: 0; border-right: 1px solid var(--border); background: var(--bg); overflow-y: auto; max-height: calc(100vh - 80px); }
.studio-history-header { padding: 16px 16px 8px; display: flex; align-items: center; justify-content: space-between; }
.studio-history-header h3 { margin: 0; font-size: 14px; font-weight: 600; color: var(--text-secondary); }
.studio-history-header span { font-size: 12px; color: var(--text-muted); }
.studio-history-empty { padding: 40px 20px; text-align: center; display: flex; flex-direction: column; align-items: center; }
.studio-history-empty p { margin: 8px 0 0; font-size: 13px; color: var(--text-muted); }
.studio-history-item { padding: 10px 14px; border-bottom: 1px solid var(--border-light, #f3f4f6); cursor: pointer; transition: background 0.15s; display: flex; gap: 10px; align-items: flex-start; }
.studio-history-item:hover { background: var(--bg-secondary); }
.studio-history-item.active { background: rgba(99,102,241,0.08); border-right: 3px solid var(--accent); }
.studio-history-item .thumb { width: 44px; height: 44px; border-radius: 6px; background: var(--bg-tertiary); background-size: cover; background-position: center; flex-shrink: 0; overflow: hidden; }
.studio-history-item .info { flex: 1; min-width: 0; }
.studio-history-item .prompt-text { font-size: 13px; font-weight: 500; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.3; }
.studio-history-item .meta { font-size: 11px; color: var(--text-muted); margin-top: 3px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.studio-history-item .delete-btn { opacity: 0; transition: opacity 0.15s; flex-shrink: 0; }
.studio-history-item:hover .delete-btn { opacity: 1; }
.model-badge-sm { font-size: 10px; padding: 1px 6px; border-radius: 4px; background: var(--bg-tertiary); color: var(--text-secondary); font-weight: 500; white-space: nowrap; }

/* Main content area */
.studio-main { flex: 1; padding: 28px 32px; min-width: 0; overflow-y: auto; max-height: calc(100vh - 80px); }

/* Prompt textarea (full-width, inside .card) */
.studio-textarea {
    width: 100%; min-height: 90px; max-height: 240px; padding: 12px 16px;
    border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 14px; font-family: inherit; resize: vertical;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: var(--bg); color: var(--text); line-height: 1.5;
}
.studio-textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-subtle); }
.studio-textarea:disabled { opacity: 0.6; cursor: not-allowed; }

/* Dropdown group labels and hints */
.cf-dropdown-group-label { padding: 6px 12px 2px; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.cf-dropdown-item { display: flex; align-items: center; gap: 8px; }
.cf-dropdown-hint { font-size: 11px; color: var(--text-muted); margin-left: auto; white-space: nowrap; }

/* Ratio buttons (larger, with label) */
.ratio-buttons { display: flex; gap: 6px; }
.ratio-btn {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 14px; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg); cursor: pointer; transition: all 0.15s;
    font-size: 13px; font-weight: 500; color: var(--text-secondary); font-family: inherit;
}
.ratio-btn:hover { border-color: var(--text-muted); }
.ratio-btn.active { border-color: var(--accent); background: var(--accent-light); color: var(--accent); font-weight: 600; }
.ratio-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ratio-icon { border: 2px solid var(--text-muted); border-radius: 2px; transition: border-color 0.15s; }
.ratio-btn.active .ratio-icon { border-color: var(--accent); }

/* Count buttons (larger, pill-style) */
.count-buttons { display: flex; gap: 4px; }
.count-btn {
    width: 40px; height: 38px; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg); cursor: pointer; font-size: 14px; font-weight: 600;
    color: var(--text-secondary); transition: all 0.15s; font-family: inherit;
}
.count-btn:hover { border-color: var(--text-muted); }
.count-btn.active { border-color: var(--accent); background: var(--accent-light); color: var(--accent); }
.count-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* References */
.ref-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.ref-slot { width: 64px; height: 64px; border: 2px dashed var(--border); border-radius: 8px; display: flex; align-items: center; justify-content: center; cursor: pointer; background: var(--bg); transition: border-color 0.15s; position: relative; overflow: hidden; }
.ref-slot:hover { border-color: var(--accent); }
.ref-slot.filled { border-style: solid; border-color: var(--border); }
.ref-slot.filled img { width: 100%; height: 100%; object-fit: cover; }
.ref-slot.add-slot { background: var(--bg-secondary); }
.ref-slot.add-slot:hover { background: var(--accent-light); border-color: var(--accent); }
.remove-ref { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--danger); color: white; display: none; align-items: center; justify-content: center; font-size: 12px; cursor: pointer; border: none; line-height: 1; }
.ref-slot:hover .remove-ref { display: flex; }

/* Empty state */
.studio-empty-state { padding: 80px 20px; text-align: center; display: flex; flex-direction: column; align-items: center; }

/* Results grid */
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.image-grid-item { position: relative; border-radius: 10px; overflow: hidden; background: var(--bg-tertiary); cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; }
.image-grid-item:hover { transform: scale(1.02); box-shadow: 0 8px 24px rgba(0,0,0,0.12); }
.image-grid-item img { width: 100%; display: block; }
.image-grid-item .overlay { position: absolute; inset: 0; background: linear-gradient(transparent 50%, rgba(0,0,0,0.5)); display: flex; align-items: flex-end; justify-content: center; padding: 10px; gap: 6px; opacity: 0; transition: opacity 0.15s; }
.image-grid-item:hover .overlay { opacity: 1; }
.overlay-btn { width: 36px; height: 36px; border-radius: 8px; background: rgba(255,255,255,0.9); color: var(--text); display: flex; align-items: center; justify-content: center; transition: background 0.15s; text-decoration: none; border: none; cursor: pointer; padding: 0; }
.overlay-btn:hover { background: white; }
.overlay-btn.upscale-done { background: var(--accent); color: white; }
.overlay-btn.upscale-done:hover { background: var(--accent-hover); }
.upscale-spinner-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.5); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 5; border-radius: inherit; }

/* Skeleton loading */
.skeleton { background: linear-gradient(90deg, var(--bg-tertiary) 25%, #e5e7eb 50%, var(--bg-tertiary) 75%); background-size: 200% 100%; animation: skeleton-anim 1.5s infinite; border-radius: 10px; }
@keyframes skeleton-anim { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Spinner */
.spinner-sm { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.3); border-top-color: white; border-radius: 50%; animation: spin 0.6s linear infinite; display: inline-block; }
.spinner-lg { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.6s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Lightbox */
.lightbox-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.85); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; z-index: 1100; }
.lightbox-content { position: relative; max-width: 90vw; }
.lightbox-close { position: absolute; top: -40px; right: 0; background: none; border: none; color: white; font-size: 28px; cursor: pointer; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 50%; transition: background 0.15s; }
.lightbox-close:hover { background: rgba(255,255,255,0.15); }
.lightbox-bar { display: flex; gap: 8px; justify-content: center; align-items: center; margin-top: 14px; }

/* Gallery modal */
.gallery-modal { background: var(--bg); border-radius: 16px; padding: 24px; max-width: 700px; width: 90vw; max-height: 80vh; overflow: hidden; display: flex; flex-direction: column; }

/* Video drop zone */
.video-drop-zone { border: 2px dashed var(--border); border-radius: 12px; padding: 36px; text-align: center; background: var(--bg-secondary); transition: border-color 0.15s, background 0.15s; cursor: pointer; display: flex; flex-direction: column; align-items: center; }
.video-drop-zone:hover, .video-drop-zone.dragover { border-color: var(--accent); background: rgba(99,102,241,0.06); }

/* Source preview */
.source-preview { text-align: center; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-secondary); }

/* Video player */
.video-player-wrap { border-radius: 12px; overflow: hidden; background: #000; }

/* Button icon */
.btn-icon-sm { background: none; border: none; cursor: pointer; padding: 4px; border-radius: 4px; }
.btn-icon-sm:hover { background: rgba(239,68,68,0.1); }

.btn-lg { padding: 8px 16px; font-size: 13px; }

@media (max-width: 768px) {
    .mobile-menu-btn { display: flex; }
    .sidebar { transform: translateX(-100%); transition: transform 0.3s ease; z-index: 200; }
    .sidebar.open { transform: translateX(0) !important; }
    .content { margin-left: 0 !important; padding: 16px; padding-top: 60px; }
    .sidebar-collapse-btn, .sidebar-expand-zone { display: none !important; }
    .settings-layout { flex-direction: column; }
    .settings-nav { width: 100%; border-right: none; border-bottom: 1px solid var(--border-light); padding-bottom: 12px; margin-bottom: 20px; display: flex; flex-wrap: wrap; gap: 4px; }
    .settings-nav-btn { border-radius: var(--radius); }
    .settings-body { padding-left: 0; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .projects-grid { grid-template-columns: 1fr; }
    .studio-layout { flex-direction: column; }
    .studio-history { width: 100%; max-height: 200px; border-right: none; border-bottom: 1px solid var(--border); }
    .studio-main { max-height: none; }
}

/* Gender toggle buttons */
.gender-btn, .gender-btn-active {
    width: 24px;
    height: 24px;
    font-size: 10px;
    font-weight: 600;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
    line-height: 1;
}
.gender-btn {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.gender-btn-active {
    background: var(--accent);
    color: #fff;
    border: 1px solid var(--accent);
}
