/* ================================================
   Complex Collective - YouTube Scraper Dark Theme
   ================================================ */

:root {
    --bg-primary: #0d1117;
    --bg-surface: #161b22;
    --bg-surface-hover: #1c2129;
    --bg-surface-raised: #21262d;
    --border: #30363d;
    --border-light: #21262d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-dim: #484f58;
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --success: #3fb950;
    --success-bg: #0d2818;
    --warning: #d29922;
    --warning-bg: #2a1f00;
    --danger: #f85149;
    --danger-bg: #2d1214;
    --running-bg: #1a1a00;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    --radius: 8px;
    --radius-sm: 6px;
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

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

/* ---- NAVBAR ---- */
.navbar {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 16px;
}
.nav-brand:hover { color: var(--text-primary); }
.brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #ff0000;
    color: white;
    border-radius: var(--radius-sm);
    font-size: 14px;
}
.nav-links {
    display: flex;
    gap: 4px;
}
.nav-link {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
}
.nav-link:hover {
    background: var(--bg-surface-raised);
    color: var(--text-primary);
}
.nav-link.active {
    background: var(--bg-surface-raised);
    color: var(--text-primary);
}

/* ---- MAIN CONTENT ---- */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
}

/* ---- PAGE HEADER ---- */
.page-header {
    margin-bottom: 24px;
}
.page-header h1 {
    font-size: 28px;
    font-weight: 600;
}
.subtitle {
    color: var(--text-secondary);
    margin-top: 4px;
    font-size: 14px;
}
.run-count {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: 8px;
}
.back-link {
    font-size: 14px;
    color: var(--text-secondary);
    display: inline-block;
    margin-bottom: 8px;
}
.back-link:hover { color: var(--accent); }

/* ---- CARDS ---- */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h2 {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.header-actions {
    display: flex;
    gap: 8px;
}
.card-body {
    padding: 20px;
}
.table-card {
    overflow: hidden;
}
.table-card .card-body { padding: 0; }

/* ---- ITEM COUNT ---- */
.item-count {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-surface-raised);
    padding: 2px 8px;
    border-radius: 10px;
}

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-surface-raised);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    font-family: var(--font-sans);
}
.btn:hover {
    background: var(--border);
    color: var(--text-primary);
}
.btn-sm {
    padding: 4px 10px;
    font-size: 13px;
}
.btn-lg {
    padding: 12px 28px;
    font-size: 16px;
}
.btn-primary {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}
.btn-primary:hover {
    background: #2ea043;
    border-color: #2ea043;
    color: #fff;
}
.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.btn-secondary {
    background: var(--bg-surface-raised);
    border-color: var(--border);
}
.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover {
    background: var(--bg-surface-raised);
    color: var(--text-primary);
}
.btn-danger {
    color: var(--danger);
}
.btn-danger:hover {
    background: var(--danger-bg);
    color: var(--danger);
}
.btn-icon {
    font-size: 12px;
}

/* ---- SEARCH TERMS ---- */
.term-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.term-number {
    width: 28px;
    text-align: right;
    color: var(--text-dim);
    font-size: 13px;
    font-family: var(--font-mono);
    flex-shrink: 0;
}
.term-input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-sans);
    transition: border-color 0.15s;
}
.term-input:focus {
    outline: none;
    border-color: var(--accent);
}
.btn-remove {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 18px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}
.btn-remove:hover {
    background: var(--danger-bg);
    color: var(--danger);
}
.terms-actions {
    margin-top: 12px;
}

/* Bulk edit textarea */
#bulkEditArea {
    width: 100%;
    padding: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-sans);
    line-height: 1.6;
    resize: vertical;
}
#bulkEditArea:focus {
    outline: none;
    border-color: var(--accent);
}

/* Read-only terms list (run detail) */
.terms-list-readonly {
    display: grid;
    gap: 4px;
}
.term-readonly {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    font-size: 14px;
}

/* ---- PRESET ROW ---- */
.preset-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.preset-group label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}
.preset-group select {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-sans);
    cursor: pointer;
}
.preset-group select:focus {
    outline: none;
    border-color: var(--accent);
}
.preset-group select option {
    background: var(--bg-surface);
}

/* ---- SETTINGS ---- */
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.setting-row label {
    font-size: 14px;
    font-weight: 500;
}
.input-number {
    width: 80px;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-sans);
    text-align: center;
}
.input-number:focus {
    outline: none;
    border-color: var(--accent);
}

/* ---- FORM ACTIONS ---- */
.form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

/* ---- RUNS TABLE ---- */
.runs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.runs-table thead {
    background: var(--bg-surface-raised);
}
.runs-table th {
    padding: 10px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.runs-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}
.runs-table tr:last-child td {
    border-bottom: none;
}
.run-row:hover td {
    background: var(--bg-surface-hover);
}
.num { font-family: var(--font-mono); font-size: 13px; }
.dim { color: var(--text-secondary); }

/* ---- STATUS BADGES ---- */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
}
.status-lg {
    padding: 6px 14px;
    font-size: 14px;
}
.status-running {
    background: var(--running-bg);
    color: var(--warning);
    border: 1px solid #3d3200;
}
.status-completed {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid #1a3a1a;
}
.status-failed {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid #3d1214;
}
.status-queued {
    background: var(--bg-surface-raised);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.phase-text {
    font-weight: 400;
    font-size: 12px;
    opacity: 0.8;
}

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

/* ---- ACTION BUTTONS ---- */
.action-buttons {
    display: flex;
    gap: 4px;
    align-items: center;
}

/* ---- DETAIL GRID ---- */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}
.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.detail-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.detail-value {
    font-size: 20px;
    font-weight: 600;
    font-family: var(--font-mono);
}
.detail-actions {
    display: flex;
    gap: 10px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ---- ERROR BOX ---- */
.error-box {
    background: var(--danger-bg);
    border: 1px solid #3d1214;
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 16px;
    color: var(--danger);
    font-size: 14px;
}

/* ---- NEXT STEP ---- */
.next-step-box {
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    padding: 16px;
}
.next-step-box p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 10px;
}
.command-block {
    display: block;
    background: var(--bg-surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--success);
    word-break: break-all;
}

/* ---- EMPTY STATE ---- */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-secondary);
}

/* ---- TERMS PREVIEW ---- */
.terms-preview {
    color: var(--text-secondary);
    font-size: 13px;
}

/* ---- STATS BANNER ---- */
.stats-banner {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}
.stat-item {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.stat-number {
    font-size: 24px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--accent);
}
.stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---- GENERATOR CONTROLS ---- */
.card-description {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 16px;
    line-height: 1.5;
}
.generator-controls {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 16px;
    align-items: end;
}

/* ---- TEXT COLORS ---- */
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-linkedin { color: #58a6ff; }

/* ---- TOGGLE SWITCH ---- */
.setting-hint {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 400;
    margin-top: 2px;
}
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--bg-surface-raised);
    border: 1px solid var(--border);
    border-radius: 24px;
    transition: 0.2s;
}
.toggle-slider:before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: 0.2s;
}
.toggle-switch input:checked + .toggle-slider {
    background: var(--success);
    border-color: var(--success);
}
.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
    background: #fff;
}

/* ---- ENRICHING STATUS ---- */
.status-enriching {
    background: #0d1a2e;
    color: var(--accent);
    border: 1px solid #1a3050;
}

/* ---- PROGRESS BAR ---- */
.progress-section { max-width: 100%; }
.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
}
.progress-label {
    font-size: 14px;
    font-weight: 500;
}
.progress-numbers {
    font-family: var(--font-mono);
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
}
.progress-bar-container {
    width: 100%;
    height: 24px;
    background: var(--bg-primary);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--success), #2ea043);
    border-radius: 12px;
    transition: width 0.5s ease;
    min-width: 2px;
}
.progress-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* ---- CHART ---- */
.chart-container {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    justify-content: space-between;
    padding: 20px 0;
    min-height: 180px;
}
.chart-day {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.chart-bars {
    display: flex;
    gap: 4px;
    align-items: flex-end;
    height: 120px;
}
.chart-bar {
    width: 20px;
    border-radius: 3px 3px 0 0;
    min-height: 2px;
    transition: height 0.3s;
}
.chart-bar-total { background: var(--bg-surface-raised); border: 1px solid var(--border); }
.chart-bar-linkedin { background: var(--accent); opacity: 0.8; }
.chart-label {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
}
.chart-value {
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--text-primary);
}
.chart-legend {
    display: flex;
    gap: 20px;
    justify-content: center;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}
.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}
.legend-total { background: var(--bg-surface-raised); border: 1px solid var(--border); }
.legend-linkedin { background: var(--accent); }

/* ---- MINI STATS ---- */
.mini-stat {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
}
.mini-stat:last-child { border-bottom: none; }
.mini-stat-number {
    font-size: 18px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--accent);
}
.mini-stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .preset-row { grid-template-columns: 1fr; }
    .stats-banner { grid-template-columns: repeat(2, 1fr); }
    .generator-controls { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: repeat(2, 1fr); }
    .runs-table { font-size: 13px; }
    .runs-table th, .runs-table td { padding: 8px 10px; }
    .main-content { padding: 20px 16px; }
    .chart-bar { width: 14px; }
}
