/* =============================================
   VideoGen Platform — Main Stylesheet
   ============================================= */

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --sidebar-width: 240px;
    --topbar-height: 56px;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: var(--gray-800);
    background: var(--gray-50);
    line-height: 1.5;
}

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

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-width);
    background: var(--gray-900);
    color: #fff;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    overflow-y: auto;
    z-index: 100;
    transition: transform .2s;
}
.sidebar-brand {
    padding: 16px 20px;
    font-size: 18px;
    font-weight: 700;
    border-bottom: 1px solid var(--gray-700);
    display: flex; align-items: center; gap: 10px;
}
.sidebar-brand i { color: var(--primary); font-size: 22px; }
.sidebar-nav { padding: 12px 0; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 20px;
    color: var(--gray-300);
    text-decoration: none;
    font-size: 13px;
    transition: background .15s, color .15s;
}
.sidebar-nav a:hover { background: var(--gray-700); color: #fff; }
.sidebar-nav a.active { background: var(--primary); color: #fff; }
.sidebar-nav a i { width: 18px; text-align: center; font-size: 14px; }
.sidebar-section { margin-top: 8px; border-top: 1px solid var(--gray-700); padding-top: 8px; }
.sidebar-section-title { padding: 8px 20px 4px; font-size: 11px; text-transform: uppercase; color: var(--gray-500); letter-spacing: .5px; }

/* MAIN WRAPPER */
.main-wrapper { margin-left: var(--sidebar-width); flex: 1; min-width: 0; }

/* TOP BAR */
.top-bar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px;
    position: sticky; top: 0; z-index: 150;
}
.sidebar-toggle { display: none; background: none; border: none; font-size: 18px; cursor: pointer; color: var(--gray-600); }
.top-bar-right { display: flex; align-items: center; gap: 16px; }

/* Language Switcher */
.language-switcher { position: relative; }
.lang-btn {
    background: var(--gray-100); border: 1px solid var(--gray-200); border-radius: 6px;
    padding: 6px 12px; cursor: pointer; display: flex; align-items: center; gap: 6px;
    font-size: 13px; color: var(--gray-700);
}
.lang-dropdown {
    display: none; position: absolute; right: 0; top: 100%; margin-top: 4px;
    background: #fff; border: 1px solid var(--gray-200); border-radius: 6px;
    box-shadow: var(--shadow-lg); min-width: 120px; z-index: 1000;
}
.lang-dropdown.show { display: block; }
.lang-dropdown a {
    display: block; padding: 8px 16px; color: var(--gray-700); text-decoration: none; font-size: 13px;
}
.lang-dropdown a:hover { background: var(--gray-50); }
.lang-dropdown a.active { font-weight: 600; color: var(--primary); }

/* User Menu */
.user-menu { display: flex; align-items: center; gap: 10px; }
.user-name { font-weight: 500; font-size: 13px; }
.logout-btn { color: var(--gray-400); text-decoration: none; background: none; border: none; cursor: pointer; font-size: inherit; padding: 4px; }
.logout-btn:hover { color: var(--danger); }

/* MAIN CONTENT */
.main-content { padding: 24px; }

/* =============================================
   PAGE COMPONENTS
   ============================================= */
.page-header {
    display: flex; align-items: center; gap: 12px; margin-bottom: 24px; flex-wrap: wrap;
}
.page-header h1 { font-size: 24px; font-weight: 700; }
.page-header .btn { margin-left: auto; }

/* Cards */
.card {
    background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius);
    box-shadow: var(--shadow); margin-bottom: 20px;
}
.card-header {
    padding: 16px 20px; border-bottom: 1px solid var(--gray-100);
    display: flex; align-items: center; justify-content: space-between;
}
.card-header h2, .card-header h3 { font-size: 16px; font-weight: 600; }
.card-body { padding: 20px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); gap: 20px; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--gray-100); }
.data-table th { font-size: 12px; text-transform: uppercase; color: var(--gray-500); font-weight: 600; letter-spacing: .5px; background: var(--gray-50); }
.data-table tbody tr:hover { background: var(--gray-50); }
.data-table a { color: var(--primary); text-decoration: none; font-weight: 500; }
.data-table a:hover { text-decoration: underline; }

/* Badges */
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px;
    font-weight: 600; text-transform: uppercase; letter-spacing: .3px;
    background: var(--gray-100); color: var(--gray-600);
}
.badge-lg { font-size: 13px; padding: 5px 14px; }
.badge-draft { background: #fef3c7; color: #92400e; }
.badge-processing { background: #dbeafe; color: #1e40af; }
.badge-ready { background: #d1fae5; color: #065f46; }
.badge-published { background: #059669; color: #fff; }
.badge-unpublished { background: var(--gray-200); color: var(--gray-600); }
.badge-failed, .badge-dead_letter { background: #fee2e2; color: #991b1b; }
.badge-cancelled { background: #fef3c7; color: #92400e; }
.badge-deleted { background: var(--gray-200); color: var(--gray-400); }
.badge-disabled { background: var(--gray-200); color: var(--gray-400); }
.badge-managed { background: #ede9fe; color: #5b21b6; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-completed { background: #d1fae5; color: #065f46; }
.badge-queued { background: #e0e7ff; color: #3730a3; }
.badge-cancelled { background: var(--gray-200); color: var(--gray-500); }
.badge-downloading { background: #dbeafe; color: #1e40af; }
.badge-downloaded { background: #bfdbfe; color: #1e40af; }
.badge-metadata_extracted { background: #c7d2fe; color: #3730a3; }
.badge-summarized { background: #ddd6fe; color: #5b21b6; }
.badge-voiceover_generated { background: #ede9fe; color: #6d28d9; }
.badge-encoded { background: #a7f3d0; color: #065f46; }
.badge-success { background: #d1fae5; color: #065f46; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 4px; font-size: 13px; font-weight: 500; color: var(--gray-700); }
.form-input {
    width: 100%; padding: 8px 12px; border: 1px solid var(--gray-300); border-radius: 6px;
    font-size: 14px; transition: border-color .15s;
}
.form-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.form-input-sm { padding: 5px 8px; font-size: 13px; width: auto; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; gap: 12px; margin-top: 24px; }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check input { margin: 0; }
.form-inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.form-inline-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 16px; border-radius: 6px; font-size: 13px; font-weight: 500;
    border: none; cursor: pointer; text-decoration: none; transition: all .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: #fff; border: 1px solid var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { background: var(--gray-50); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius);
    padding: 20px; display: flex; align-items: center; gap: 16px;
}
.stat-icon { font-size: 28px; color: var(--primary); opacity: .7; }
.stat-value { display: block; font-size: 28px; font-weight: 700; color: var(--gray-900); }
.stat-label { font-size: 12px; color: var(--gray-500); text-transform: uppercase; letter-spacing: .5px; }
.stat-sublabel { font-size: 11px; color: var(--gray-400); }

/* Action Bar */
.action-bar { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }

/* Detail List */
.detail-list { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; }
.detail-list dt { color: var(--gray-500); font-size: 13px; }
.detail-list dd { font-weight: 500; }

/* Thumbnails */
.thumb-sm { width: 60px; height: 34px; object-fit: cover; border-radius: 4px; }
.thumb-placeholder { width: 60px; height: 34px; background: var(--gray-100); border-radius: 4px; display: flex; align-items: center; justify-content: center; color: var(--gray-400); }
.thumbnail-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb-candidate {
    border: 2px solid transparent; border-radius: 4px; padding: 2px; cursor: pointer; background: none;
    transition: border-color .15s;
}
.thumb-candidate:hover { border-color: var(--primary); }
.thumb-candidate.selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(79,70,229,.3); }
.thumb-candidate img { width: 100px; height: 56px; object-fit: cover; border-radius: 2px; display: block; }

/* Settings rows */
.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--gray-100); }
.setting-info { flex: 1; }
.setting-info strong { display: block; font-size: 13px; }
.setting-info small { color: var(--gray-500); font-size: 12px; }
.setting-control { display: flex; gap: 8px; align-items: center; }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--gray-100); }
.page-info { font-size: 13px; color: var(--gray-500); }

/* Empty State */
.empty-state { text-align: center; padding: 40px 20px; color: var(--gray-400); }
.empty-state i { margin-bottom: 12px; }
.empty-state p { margin-bottom: 16px; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 13px; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }

/* Text utilities */
.text-muted { color: var(--gray-500); }
.text-danger { color: var(--danger); }

/* =============================================
   LOGIN PAGE
   ============================================= */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--gray-100); }
.login-container { width: 100%; max-width: 400px; padding: 20px; }
.login-card { background: #fff; padding: 32px; border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand h1 { font-size: 28px; color: var(--primary); }
.login-brand p { color: var(--gray-500); font-size: 13px; }
.login-lang { text-align: center; margin-top: 16px; font-size: 12px; color: var(--gray-400); }
.login-lang a { color: var(--gray-500); }

/* =============================================
   PIPELINE STAGES
   ============================================= */
.pipeline-stage { border: 1px solid #e5e7eb; }
.pipeline-completed { background: #ecfdf5; border-color: #6ee7b7; color: #065f46; }
.pipeline-running { background: #eff6ff; border-color: #93c5fd; color: #1e40af; animation: pipeline-pulse 2s ease-in-out infinite; }
.pipeline-failed { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }
.pipeline-queued { background: #fffbeb; border-color: #fcd34d; color: #92400e; }
.pipeline-pending { background: #f9fafb; border-color: #e5e7eb; color: #9ca3af; }
@keyframes pipeline-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.7; } }

/* Pipeline dots for video list */
.pipeline-dot { display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;border-radius:50%;font-size:0.6rem;line-height:1;border:1px solid #e5e7eb; }
.pipeline-dot-completed { background:#ecfdf5;border-color:#6ee7b7;color:#065f46; }
.pipeline-dot-running { background:#eff6ff;border-color:#93c5fd;color:#1e40af;animation:pipeline-pulse 2s ease-in-out infinite; }
.pipeline-dot-failed { background:#fef2f2;border-color:#fca5a5;color:#991b1b; }
.pipeline-dot-queued { background:#fffbeb;border-color:#fcd34d;color:#92400e; }
.pipeline-dot-pending { background:#f9fafb;border-color:#e5e7eb;color:#9ca3af; }

/* Resource detail expandable rows */
.resource-detail-row td { border-top:none !important; }
.resource-edit-form textarea { font-family:inherit; }
.resource-edit-form input[readonly] { background:#f3f4f6;color:#6b7280; }
.toggle-detail { padding:4px 8px !important; }
.toggle-detail i { transition:transform 0.2s; }

/* Audio source badges */
.badge-voiceover { background:#ede9fe;color:#6d28d9;border:1px solid #c4b5fd; }
.badge-resource_audio { background:#ecfdf5;color:#065f46;border:1px solid #6ee7b7; }
.badge-library { background:#eff6ff;color:#1e40af;border:1px solid #93c5fd; }
.badge-none { background:#f3f4f6;color:#6b7280;border:1px solid #d1d5db; }

/* Processing status: BLOCKED */
.badge-blocked { background:#fef3c7;color:#92400e;border:1px solid #fcd34d; }

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: block; }
    .main-wrapper { margin-left: 0; }
    .form-row { grid-template-columns: 1fr; }
    .card-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr; }
}
