/* News Aggregator - Main Stylesheet with Theme Support */

/* ============ THEME DEFINITIONS ============ */

/* Default: Amber Dark */
:root, [data-theme="amber"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #262626;
    --bg-card: #333333;
    --text-primary: #f5f5f5;
    --text-secondary: #a3a3a3;
    --accent: #d97706;
    --accent-hover: #f59e0b;
    --success: #22c55e;
    --warning: #eab308;
    --error: #ef4444;
    --info: #3b82f6;
    --border: #404040;
}

[data-theme="nord"] {
    --bg-primary: #2e3440;
    --bg-secondary: #3b4252;
    --bg-card: #434c5e;
    --text-primary: #eceff4;
    --text-secondary: #d8dee9;
    --accent: #88c0d0;
    --accent-hover: #8fbcbb;
    --success: #a3be8c;
    --warning: #ebcb8b;
    --error: #bf616a;
    --info: #81a1c1;
    --border: #4c566a;
}

[data-theme="github"] {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-card: #21262d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --success: #3fb950;
    --warning: #d29922;
    --error: #f85149;
    --info: #58a6ff;
    --border: #30363d;
}

[data-theme="monokai"] {
    --bg-primary: #272822;
    --bg-secondary: #2d2e27;
    --bg-card: #3e3d32;
    --text-primary: #f8f8f2;
    --text-secondary: #a6a28c;
    --accent: #a6e22e;
    --accent-hover: #c2f74c;
    --success: #a6e22e;
    --warning: #e6db74;
    --error: #f92672;
    --info: #66d9ef;
    --border: #49483e;
}

[data-theme="slate"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --accent: #38bdf8;
    --accent-hover: #7dd3fc;
    --success: #4ade80;
    --warning: #fbbf24;
    --error: #f87171;
    --info: #38bdf8;
    --border: #475569;
}

[data-theme="charcoal"] {
    --bg-primary: #18181b;
    --bg-secondary: #27272a;
    --bg-card: #3f3f46;
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --accent: #10b981;
    --accent-hover: #34d399;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #06b6d4;
    --border: #52525b;
}

[data-theme="ocean"] {
    --bg-primary: #0c1222;
    --bg-secondary: #131b2e;
    --bg-card: #1a2744;
    --text-primary: #e2e8f0;
    --text-secondary: #8892a4;
    --accent: #22d3ee;
    --accent-hover: #67e8f9;
    --success: #2dd4bf;
    --warning: #fcd34d;
    --error: #fb7185;
    --info: #22d3ee;
    --border: #2a3a5a;
}

[data-theme="espresso"] {
    --bg-primary: #1c1917;
    --bg-secondary: #292524;
    --bg-card: #3d3835;
    --text-primary: #fafaf9;
    --text-secondary: #a8a29e;
    --accent: #fb923c;
    --accent-hover: #fdba74;
    --success: #86efac;
    --warning: #fde047;
    --error: #fca5a5;
    --info: #93c5fd;
    --border: #57534e;
}

/* ============ BASE STYLES ============ */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

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

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

/* ============ NAVIGATION ============ */

.navbar {
    background: var(--bg-secondary);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    gap: 2rem;
    border-bottom: 1px solid var(--border);
}

.nav-brand a {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent);
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 1.5rem;
    flex: 1;
}

.nav-links a {
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--text-primary);
    background: var(--bg-card);
}

/* Theme Switcher in Nav */
.theme-switcher {
    position: relative;
}

.theme-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

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

.theme-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem;
    min-width: 160px;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.theme-dropdown.show {
    display: block;
}

.theme-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s;
}

.theme-option:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.theme-option.active {
    background: var(--accent);
    color: #fff;
}

.theme-swatch {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--border);
}

/* Logout button in nav */
.nav-logout-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.nav-logout-btn:hover {
    color: var(--error);
    border-color: var(--error);
    background: transparent;
}

/* ============ CONTAINER ============ */

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* ============ DASHBOARD ============ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
}

.stat-card h3 {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--accent);
}

/* ============ FORMS ============ */

.inline-form {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.inline-form input[type="text"],
.inline-form input[type="date"],
.inline-form select {
    flex: 1;
    min-width: 200px;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
}

.inline-form input:focus {
    outline: none;
    border-color: var(--accent);
}

button, .btn {
    padding: 0.75rem 1.5rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
}

button:hover, .btn:hover {
    background: var(--accent-hover);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

button.danger, .btn-danger {
    background: var(--error);
}

button.danger:hover, .btn-danger:hover {
    background: var(--error);
    opacity: 0.9;
}

button.small {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

/* ============ LAYOUT ============ */

.two-column {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 768px) {
    .two-column {
        grid-template-columns: 1fr;
    }

    .navbar {
        flex-wrap: wrap;
        padding: 1rem;
    }

    .nav-links {
        order: 3;
        width: 100%;
        justify-content: center;
        margin-top: 1rem;
    }
}

.column h2 {
    margin-bottom: 1rem;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* ============ VIDEO LIST ============ */

.video-list, .job-list {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1rem;
    max-height: 400px;
    overflow-y: auto;
}

.video-item, .job-item {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.video-item:last-child, .job-item:last-child {
    border-bottom: none;
}

.video-item a {
    display: block;
    margin-bottom: 0.25rem;
}

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

/* ============ STATUS BADGES ============ */

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

.status-badge.pending {
    background: var(--warning);
    color: #000;
}

.status-badge.running {
    background: var(--info);
    color: #fff;
}

.status-badge.completed {
    background: var(--success);
    color: #000;
}

.status-badge.failed {
    background: var(--error);
    color: #fff;
}

/* ============ CHANNELS ============ */

.channels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.channel-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 8px;
}

.channel-card h3 {
    margin-bottom: 0.5rem;
}

.channel-stats {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.channel-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.channel-actions button, .channel-actions .btn {
    flex: 1;
    padding: 0.5rem;
    font-size: 0.85rem;
    min-width: fit-content;
}

.channel-link {
    color: var(--text-primary);
    text-decoration: none;
}

.channel-link:hover h3 {
    color: var(--accent);
}

/* ============ TABLES ============ */

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--bg-card);
    color: var(--text-secondary);
    font-weight: 600;
}

/* ============ TAGS ============ */

.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    background: var(--bg-card);
    border-radius: 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.tag.clickable {
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
}

.tag.clickable:hover {
    background: var(--accent);
    color: #fff;
}

a.tag.clickable {
    color: var(--text-secondary);
}

a.tag.clickable:hover {
    color: #fff;
}

/* ============ TWEET SECTION ============ */

.tweet-section h2 {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.tweet-section .char-count {
    font-size: 0.75rem;
    font-weight: normal;
    color: var(--text-secondary);
    padding: 0.2rem 0.5rem;
    background: var(--bg-card);
    border-radius: 8px;
}

.tweet-container {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.tweet-text {
    flex: 1;
    background: var(--bg-card);
    padding: 1rem 1.25rem;
    border-radius: 8px;
    font-size: 1.05rem;
    line-height: 1.5;
    border-left: 4px solid var(--accent);
    color: var(--text-primary);
    word-wrap: break-word;
}

.btn-copy {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.btn-copy:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-copy.copied {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}

.copy-icon {
    font-size: 1rem;
}

/* ============ SEARCH ============ */

.search-forms {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.search-box {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 8px;
}

.search-box h3 {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.tags-browser {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.tag-category {
    margin-bottom: 1rem;
}

.tag-category h4 {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* ============ RESULTS ============ */

.results-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.result-item {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 8px;
}

.result-item h3 {
    margin-bottom: 0.5rem;
}

.result-meta {
    display: flex;
    gap: 1rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.result-summary {
    color: var(--text-secondary);
}

/* ============ VIDEO DETAIL ============ */

.video-detail {
    max-width: 900px;
}

.video-header {
    margin-bottom: 2rem;
}

.video-header h1 {
    margin-bottom: 1rem;
}

.video-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.video-actions {
    display: flex;
    gap: 1rem;
}

.section {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.section h2 {
    margin-bottom: 1rem;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.section.collapsible h2 {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
}

.collapsed {
    display: none;
}

.transcript-text {
    white-space: pre-wrap;
    font-size: 0.9rem;
    line-height: 1.8;
    max-height: 500px;
    overflow-y: auto;
}

/* ============ CONSOLIDATE ============ */

.consolidate-page .description {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.consolidate-form {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.synthesis-header {
    margin-bottom: 1.5rem;
}

.synthesis-content {
    background: var(--bg-secondary);
    padding: 2rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    line-height: 1.8;
}

.sources-list {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 8px;
}

.sources-list ul {
    list-style: none;
}

.sources-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

/* Form layout for consolidate */
.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

.form-group small {
    display: block;
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

/* Section divider */
.section-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
}

/* Saved consolidations */
.saved-consolidations h2 {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.saved-item {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: background 0.2s;
}

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

.saved-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.saved-item-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.saved-item-meta .tags {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.saved-item-meta .tag {
    background: var(--bg-card);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.saved-item-meta .source-count {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Synthesis section headers */
.synthesis-section-header {
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--accent);
    margin: 1.5rem 0 0.75rem 0;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border);
}

.synthesis-section-header:first-child {
    margin-top: 0;
}

.synthesis-content ul {
    margin: 0.5rem 0 0.5rem 1.5rem;
    list-style: disc;
}

.synthesis-content li {
    margin-bottom: 0.5rem;
}

/* Tone and urgency badges in sources */
.tone-badge, .urgency-badge {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

.tone-badge {
    background: var(--info);
    color: white;
}

.tone-badge.alarming { background: var(--error); }
.tone-badge.concerned { background: var(--warning); color: #000; }
.tone-badge.neutral { background: var(--text-secondary); }
.tone-badge.optimistic { background: var(--success); }

.urgency-badge {
    background: var(--bg-card);
}

.urgency-badge.high { background: var(--error); color: white; }
.urgency-badge.medium { background: var(--warning); color: #000; }
.urgency-badge.low { background: var(--text-secondary); color: white; }

/* Button variants */
.btn-danger {
    background: var(--error);
    color: white;
}

.btn-danger:hover {
    opacity: 0.9;
}

/* ============ CHANNEL DETAIL PAGE ============ */

.channel-detail-page .channel-header {
    margin-bottom: 2rem;
}

.channel-detail-page .back-link {
    display: inline-block;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.channel-detail-page .back-link:hover {
    color: var(--accent);
}

.channel-detail-page h1 {
    margin-bottom: 0.5rem;
}

.channel-detail-page .channel-actions {
    margin-top: 1rem;
}

.count-badge {
    background: var(--bg-card);
    padding: 0.3rem 0.8rem;
    border-radius: 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Video Row List */
.videos-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.video-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border-left: 4px solid var(--border);
}

.video-row.pending {
    border-left-color: var(--warning);
}

.video-row.completed {
    border-left-color: var(--success);
}

.video-row.failed {
    border-left-color: var(--error);
}

.video-info {
    flex: 1;
    min-width: 0;
}

.video-title {
    display: block;
    font-weight: 500;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Button variants */
.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.btn-primary {
    background: var(--accent);
}

.btn-warning {
    background: var(--warning);
    color: #000;
}

.btn-warning:hover {
    background: var(--warning);
    opacity: 0.9;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border);
}

/* Scheduler toggle button */
.scheduler-toggle {
    margin-left: 1rem;
    vertical-align: middle;
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.scheduler-toggle:hover {
    background: var(--border);
}

.scheduler-toggle.paused {
    background: var(--warning);
    color: #000;
    border-color: var(--warning);
}

.scheduler-toggle.paused:hover {
    background: var(--warning);
    opacity: 0.9;
}

/* Status colors inline */
.status-pending { color: var(--warning); }
.status-completed { color: var(--success); }
.status-failed { color: var(--error); }

/* ============ UTILITY ============ */

.loading {
    color: var(--text-secondary);
    text-align: center;
    padding: 2rem;
}

.empty {
    color: var(--text-secondary);
    text-align: center;
    padding: 2rem;
}

.error {
    color: var(--error);
    padding: 1rem;
    background: color-mix(in srgb, var(--error) 15%, transparent);
    border-radius: 4px;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
}

.filters {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 8px;
}

.filter-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.filters label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.filters select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-card);
    color: var(--text-primary);
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: 0.6rem 1rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.95rem;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
}

.search-input::placeholder {
    color: var(--text-secondary);
}

/* Add form styling */
.add-form {
    margin-bottom: 2rem;
}

/* ============ VIDEO DETAIL ENHANCED ============ */

.video-header {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 8px;
}

.video-thumbnail {
    flex-shrink: 0;
    width: 320px;
    border-radius: 8px;
    overflow: hidden;
}

.video-thumbnail img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
}

.video-header .video-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.video-header h1 {
    margin-bottom: 0.75rem;
    font-size: 1.5rem;
    line-height: 1.3;
}

.analysis-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
    margin-left: 0.5rem;
}

.analysis-badge.complete {
    background: var(--success);
    color: #000;
}

.analysis-badge.partial {
    background: var(--warning);
    color: #000;
}

.analysis-badge.transcript_only {
    background: var(--info);
    color: #fff;
}

.analysis-badge.none {
    background: var(--text-secondary);
    color: #000;
}

/* Tone & Urgency Badges (for video lists) */
.tone-badge, .urgency-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: capitalize;
    margin-left: 0.5rem;
}

.tone-badge.tone-optimistic {
    background: var(--success);
    color: #000;
}

.tone-badge.tone-neutral {
    background: var(--info);
    color: #fff;
}

.tone-badge.tone-pessimistic {
    background: var(--error);
    color: #fff;
}

.urgency-badge.urgency-high {
    background: var(--error);
    color: #fff;
}

.urgency-badge.urgency-medium {
    background: var(--warning);
    color: #000;
}

.urgency-badge.urgency-low {
    background: var(--success);
    color: #000;
}

/* No Speech Badge - for videos without spoken audio */
.no-speech-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
    background: #6b7280;
    color: #fff;
    margin-left: 0.25rem;
}

/* Analysis status badge for no_speech */
.analysis-badge.no_speech {
    background: #6b7280;
    color: #fff;
}

/* Deep Analysis Styles */
.analysis-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--bg-card);
    border-radius: 6px;
}

.meta-item {
    font-size: 0.9rem;
}

.sentiment-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.tone, .urgency {
    padding: 0.3rem 0.8rem;
    border-radius: 16px;
    font-size: 0.85rem;
    font-weight: 500;
}

.tone-optimistic { background: var(--success); color: #000; }
.tone-neutral { background: var(--info); color: #fff; }
.tone-pessimistic { background: var(--error); color: #fff; }

.urgency-high { background: var(--error); color: #fff; }
.urgency-medium { background: var(--warning); color: #000; }
.urgency-low { background: var(--success); color: #000; }

.analysis-content h3 {
    margin-top: 1.25rem;
    margin-bottom: 0.75rem;
    color: var(--accent);
    font-size: 1rem;
}

.analysis-content ul {
    list-style: disc inside;
    color: var(--text-primary);
}

.analysis-content li {
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.supporting-points {
    margin-top: 0.5rem;
    margin-left: 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.supporting-points li {
    margin-bottom: 0.25rem;
}

.confidence {
    font-size: 0.8rem;
    padding: 0.15rem 0.5rem;
    border-radius: 8px;
    background: var(--bg-card);
}

.confidence-high { color: var(--success); }
.confidence-medium { color: var(--warning); }
.confidence-low { color: var(--text-secondary); }

.arguments-list, .insights-list, .rules-list {
    list-style: none;
}

.arguments-list > li, .insights-list > li, .rules-list > li {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--bg-card);
    border-radius: 6px;
    border-left: 3px solid var(--accent);
}

/* Responsive video header */
@media (max-width: 768px) {
    .video-header {
        flex-direction: column;
    }

    .video-thumbnail {
        width: 100%;
        max-width: 480px;
    }
}

/* ============ VIDEO PREVIEW PANEL ============ */

.video-preview-panel {
    background: var(--bg-secondary);
    border: 2px solid var(--accent);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.preview-header h3 {
    margin: 0;
    color: var(--text-primary);
}

.preview-list {
    max-height: 400px;
    overflow-y: auto;
}

.preview-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background 0.2s;
}

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

.preview-item img {
    width: 80px;
    height: 45px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.preview-info {
    flex: 1;
    min-width: 0;
}

.preview-num {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-right: 0.5rem;
}

.preview-info a {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-footer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    text-align: center;
}

/* ============ SUBSCRIPTION & AD-HOC STYLES ============ */

/* Filter tabs */
.filter-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.tab-btn {
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px 4px 0 0;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--accent);
    color: var(--bg-primary);
    font-weight: 600;
}

/* Subscription badges */
.subscription-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.subscription-badge.subscribed {
    background: var(--success);
    color: var(--bg-primary);
}

.subscription-badge.adhoc {
    background: var(--warning);
    color: var(--bg-primary);
}

/* Ad-hoc channel card styling */
.channel-card.adhoc-channel {
    border-left: 3px solid var(--warning);
}

/* Subscribe/Unsubscribe buttons */
.btn-subscribe {
    background: var(--success) !important;
    color: var(--bg-primary) !important;
}

.btn-subscribe:hover {
    background: #16a34a !important;
}

.btn-unsubscribe {
    background: var(--warning) !important;
    color: var(--bg-primary) !important;
}

.btn-unsubscribe:hover {
    background: #ca8a04 !important;
}

/* Archive/Restore buttons */
.btn-archive {
    background: var(--text-secondary) !important;
    color: var(--bg-primary) !important;
}

.btn-archive:hover {
    background: var(--warning) !important;
}

.btn-restore {
    background: var(--success) !important;
    color: var(--bg-primary) !important;
}

.btn-restore:hover {
    background: #16a34a !important;
}

/* Archived channel styling */
.channel-card.archived-channel {
    border-left: 3px solid var(--text-secondary);
    opacity: 0.8;
}

.subscription-badge.archived {
    background: var(--text-secondary);
    color: var(--bg-primary);
}

/* Video detail subscribe button */
.video-actions .btn-subscribe {
    background: var(--success);
    color: white;
    border: none;
}

.video-actions .btn-subscribe:hover {
    background: #16a34a;
}

.video-actions .btn-subscribe.subscribed {
    background: var(--text-secondary);
    cursor: default;
}

/* Clickable stat cards */
.stat-card.clickable {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card.clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Sort headers */
.sort-header {
    cursor: pointer;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.sort-header:hover {
    color: var(--accent);
}

.sort-header .sort-icon {
    font-size: 0.75rem;
    opacity: 0.5;
}

.sort-header.active .sort-icon {
    opacity: 1;
    color: var(--accent);
}

.sort-label {
    font-size: 0.7rem;
    font-weight: normal;
    color: var(--text-secondary);
    margin-left: 0.25rem;
}

/* ============ LIVE VIDEO BADGES ============ */

.live-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    background: #ef4444;
    color: #fff;
    animation: live-pulse 2s infinite;
    margin-left: 0.25rem;
}

@keyframes live-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.upcoming-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    background: var(--info);
    color: #fff;
    margin-left: 0.25rem;
}

/* ============ CLICKABLE DATE LINK ============ */

.date-link {
    cursor: pointer;
    color: var(--accent);
    text-decoration: underline;
    text-decoration-style: dotted;
    transition: color 0.2s;
}

.date-link:hover {
    color: var(--accent-hover);
    text-decoration-style: solid;
}

/* ============ VIDEO FILTERS ============ */

.video-filters {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.video-filters select,
.video-filters input[type="date"] {
    flex: 0 0 auto;
    width: auto;
    min-width: 140px;
}

/* Ensure all form selects use dark theme */
select {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    color-scheme: dark;
}

select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

input[type="date"] {
    color-scheme: dark;
}

button.secondary, .btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

button.secondary:hover, .btn-secondary:hover {
    background: var(--border);
    color: var(--text-primary);
}

/* ============ RESPONSIVE DESIGN ============ */

/* Mobile menu toggle (hidden by default) */
.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
}

/* Tablet breakpoint (max 1024px) */
@media (max-width: 1024px) {
    .container {
        padding: 1.5rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .channels-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .video-filters .inline-form {
        gap: 0.75rem;
    }
}

/* Mobile breakpoint (max 768px) */
@media (max-width: 768px) {
    /* Navigation */
    .navbar {
        flex-wrap: wrap;
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }

    .nav-brand a {
        font-size: 1.25rem;
    }

    .mobile-menu-toggle {
        display: block;
        margin-left: auto;
    }

    .nav-links {
        display: none;
        order: 3;
        width: 100%;
        flex-direction: column;
        gap: 0.25rem;
        margin-top: 0.5rem;
        padding-top: 0.75rem;
        border-top: 1px solid var(--border);
    }

    .nav-links.show {
        display: flex;
    }

    .nav-links a {
        padding: 0.75rem 1rem;
        text-align: center;
    }

    .nav-logout-btn {
        display: none;
    }

    .nav-links.show + form .nav-logout-btn,
    .nav-links ~ form {
        order: 4;
        width: 100%;
    }

    .nav-links.show ~ form .nav-logout-btn {
        display: block;
        width: 100%;
        margin-top: 0.5rem;
    }

    .theme-switcher {
        order: 2;
    }

    /* Container */
    .container {
        padding: 1rem;
    }

    /* Stats */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-number {
        font-size: 1.75rem;
    }

    .stat-card h3 {
        font-size: 0.8rem;
    }

    /* Forms and filters */
    .inline-form {
        flex-direction: column;
        gap: 0.75rem;
    }

    .inline-form input[type="text"],
    .inline-form input[type="date"],
    .inline-form select {
        min-width: 100%;
        width: 100%;
    }

    .filter-tabs {
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 0.5rem;
        -webkit-overflow-scrolling: touch;
    }

    .filter-tabs .tab-btn {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }

    .video-filters {
        padding: 0.75rem;
    }

    .video-filters .inline-form {
        gap: 0.5rem;
    }

    /* Channel cards */
    .channels-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .channel-card {
        padding: 1rem;
    }

    .channel-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .channel-actions button,
    .channel-actions .btn {
        width: 100%;
        padding: 0.75rem;
    }

    /* Tables - horizontal scroll */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
    }

    th, td {
        padding: 0.75rem 0.5rem;
        font-size: 0.85rem;
    }

    /* Video detail */
    .video-header {
        flex-direction: column;
    }

    .video-thumbnail {
        width: 100%;
        max-width: none;
    }

    .video-info h1 {
        font-size: 1.25rem;
    }

    .video-actions {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .video-actions button,
    .video-actions .btn {
        flex: 1 1 45%;
        padding: 0.75rem;
        font-size: 0.85rem;
    }

    /* Two column layout */
    .two-column {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    /* Search results */
    .search-result {
        padding: 1rem;
    }

    .search-result h3 {
        font-size: 1rem;
    }

    /* Video list on dashboard */
    .video-list, .job-list {
        max-height: 300px;
    }

    /* Consolidate page */
    .consolidate-form {
        padding: 1rem;
    }

    .synthesis-content {
        padding: 1rem;
        font-size: 0.9rem;
    }

    /* Tags */
    .tags-list {
        gap: 0.375rem;
    }

    .tag {
        padding: 0.25rem 0.6rem;
        font-size: 0.8rem;
    }

    /* Buttons general */
    button, .btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }

    /* Page titles */
    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    /* Video preview panel */
    .preview-item img {
        width: 60px;
        height: 34px;
    }

    .preview-info a {
        font-size: 0.9rem;
    }
}

/* Small mobile (max 480px) */
@media (max-width: 480px) {
    .navbar {
        padding: 0.5rem 0.75rem;
    }

    .nav-brand a {
        font-size: 1.1rem;
    }

    .container {
        padding: 0.75rem;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .stat-card {
        padding: 0.75rem;
    }

    .stat-number {
        font-size: 1.5rem;
    }

    .channel-card h3 {
        font-size: 1rem;
    }

    .channel-stats {
        font-size: 0.8rem;
    }

    .video-actions button,
    .video-actions .btn {
        flex: 1 1 100%;
    }

    /* Login page adjustments */
    .login-container {
        margin: 1rem;
        padding: 1.5rem;
    }

    .login-header h1 {
        font-size: 1.25rem;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    button, .btn, .tab-btn {
        min-height: 44px;
    }

    .nav-links a {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .tag.clickable {
        min-height: 36px;
        display: inline-flex;
        align-items: center;
    }

    /* Remove hover effects on touch devices */
    .channel-card:hover,
    .video-item:hover,
    .search-result:hover {
        transform: none;
    }
}

/* Print styles */
@media print {
    .navbar,
    .nav-logout-btn,
    .theme-switcher,
    .mobile-menu-toggle,
    .video-actions,
    .channel-actions,
    button,
    .btn {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    .container {
        max-width: 100%;
        padding: 0;
    }
}

/* ============ MODAL STYLES ============ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 8px;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

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

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-body .saved-item {
    margin-bottom: 0.75rem;
}

.modal-body .empty {
    color: var(--text-secondary);
    text-align: center;
    padding: 2rem;
}

/* ============ SOURCE PREVIEW STYLES ============ */

.source-preview {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.preview-header h3 {
    margin: 0;
    color: var(--text-primary);
}

.preview-actions {
    display: flex;
    gap: 0.5rem;
}

.preview-hint {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.source-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
}

.source-item {
    background: var(--bg-card);
    border-radius: 6px;
    padding: 0.75rem;
    transition: background 0.2s;
}

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

.source-checkbox {
    display: flex;
    gap: 0.75rem;
    cursor: pointer;
    align-items: flex-start;
}

.source-checkbox input[type="checkbox"] {
    margin-top: 0.25rem;
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent);
}

.source-info {
    flex: 1;
}

.source-info strong {
    display: block;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.source-info .meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 0.5rem;
}

.source-info .summary-preview {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.4;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.form-actions button {
    flex: 1;
}

.form-actions button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============ FAILED VIDEOS PANEL ============ */

.stat-card.warning {
    border-left: 3px solid var(--warning);
}

.stat-card.warning:hover {
    border-color: var(--error);
}

.failed-panel {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 2rem;
    border: 1px solid var(--border);
}

.failed-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.failed-panel .panel-header h2 {
    margin: 0;
    color: var(--warning);
}

.failed-panel .panel-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.failed-panel select {
    padding: 0.5rem;
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.failed-list {
    max-height: 400px;
    overflow-y: auto;
}

.failed-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
}

.failed-item:last-child {
    border-bottom: none;
}

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

.failed-info {
    flex: 1;
    min-width: 0;
}

.failed-title {
    display: block;
    color: var(--text-primary);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}

.failed-title:hover {
    color: var(--accent);
}

.failure-reason {
    display: inline-block;
    background: var(--error);
    color: white;
    padding: 0.125rem 0.5rem;
    border-radius: 3px;
    font-size: 0.75rem;
    margin-right: 0.5rem;
}

.failed-actions {
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .failed-panel .panel-header {
        flex-direction: column;
        align-items: stretch;
    }

    .failed-panel .panel-actions {
        justify-content: flex-start;
    }

    .failed-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .failed-actions {
        width: 100%;
        margin-top: 0.5rem;
    }
}
