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

/* Import CSS Variables System */
@import url('/static/css/variables.css');

/* Legacy variable mappings */
:root {
    --primary: var(--color-primary);
    --primary-dark: var(--color-primary-hover);
    --secondary: var(--neutral-500);
    --success: var(--color-success);
    --danger: var(--color-error);
    --warning: var(--color-warning);
    --background: var(--neutral-50);
    --surface: var(--color-background);
    --text: var(--color-text-primary);
    --text-light: var(--color-text-secondary);
    --border: var(--color-border);
}

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

/* Chrome Extension Live Status */
.extension-status-container {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    color: white;
}

.extension-status-container h4 {
    margin: 0 0 15px 0;
    font-size: 18px;
    font-weight: 600;
}

.extension-stats {
    display: grid;
    gap: 12px;
}

.stat-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stat-row .stat-label {
    flex: 0 0 150px;
    font-weight: 500;
    opacity: 0.9;
}

.stat-row .stat-value {
    font-weight: 600;
    color: #ffd700;
}

.mini-progress-bar {
    flex: 1;
    height: 20px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    position: relative;
    overflow: hidden;
}

.mini-progress-bar .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    transition: width 0.3s ease;
    border-radius: 10px;
}

.mini-progress-bar .progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.admin-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.admin-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.admin-header h1 {
    margin-bottom: 1rem;
    color: var(--primary);
}

.admin-nav {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.nav-btn {
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: var(--text);
    font-size: 0.95rem;
}

.nav-btn:hover {
    background: var(--background);
    border-color: var(--primary);
}

.nav-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.admin-main {
    flex: 1;
    padding: 2rem;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

.tab-content {
    display: none;
}

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

.settings-section, .experts-section, .history-section {
    background: var(--surface);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.settings-section h2 {
    margin-bottom: 1.5rem;
    color: var(--text);
    font-size: 1.25rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0.5rem;
}

.settings-group {
    margin-bottom: 2rem;
}

.setting-item {
    margin-bottom: 1.5rem;
}

.setting-item label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text);
}

.setting-item small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-light);
    font-size: 0.875rem;
}

.input-group {
    display: flex;
    gap: 0.5rem;
}

.api-key-input, .setting-input, .form-input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
    font-family: monospace;
    transition: border-color 0.2s;
}

.api-key-input:focus, .setting-input:focus, .form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn-toggle-visibility {
    padding: 0.75rem 1rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-toggle-visibility:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.setting-select, .filter-select {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.setting-select:focus, .filter-select:focus {
    outline: none;
    border-color: var(--primary);
}

.button-group {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

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

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

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.message {
    padding: 1rem;
    border-radius: 6px;
    margin-top: 1rem;
}

.message.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.message.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.message.hidden {
    display: none;
}

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

.experts-list {
    display: grid;
    gap: 1rem;
}

.expert-card {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: start;
}

.expert-info h3 {
    margin-bottom: 0.5rem;
    color: var(--text);
}

.expert-info p {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.expert-status {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.expert-status.active {
    background: #d1fae5;
    color: #065f46;
}

.expert-status.inactive {
    background: #fee2e2;
    color: #991b1b;
}

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

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--surface);
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content.modal-large {
    max-width: 800px;
}

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

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
}

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

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
    resize: vertical;
}

.history-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.filter-input {
    flex: 1;
    min-width: 200px;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
}

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

.history-item {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}

.history-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-light);
}

.history-content {
    display: grid;
    gap: 0.5rem;
}

.chat-message {
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.9rem;
}

.chat-message.user {
    background: #dbeafe;
}

.chat-message.assistant {
    background: #f3f4f6;
}

/* Sync Status Panel */
.sync-status-panel {
    background: var(--surface);
    border-radius: 8px;
    padding: 2rem;
    margin-top: 2rem;
    border: 1px solid var(--border);
}

.sync-status-panel.hidden {
    display: none;
}

.sync-progress {
    margin: 1.5rem 0;
}

.progress-bar {
    height: 24px;
    background: var(--background);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    margin-top: 0.5rem;
    color: var(--text-light);
}

.sync-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.sync-stat {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--background);
    border-radius: 6px;
}

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

.stat-value {
    font-weight: 600;
    color: var(--text);
}

.video-stats {
    margin-top: 2rem;
}

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

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

.stat-number {
    display: block;
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

/* Channel Info */
.channel-info {
    margin: 1rem 0;
}

.channel-info.hidden {
    display: none;
}

.info-card {
    background: var(--background);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.info-grid {
    display: grid;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.info-item {
    display: flex;
    justify-content: space-between;
}

.info-label {
    color: var(--text-light);
}

.info-value {
    font-weight: 600;
}

/* Form Sections */
.form-section {
    background: var(--background);
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
}

.form-section h4 {
    margin-bottom: 1rem;
    color: var(--text);
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.radio-label input {
    margin-right: 0.5rem;
}

.sync-option {
    margin-top: 1rem;
}

.sync-option.hidden {
    display: none;
}

/* Prompts Section */
.prompts-section {
    background: var(--surface);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.prompts-info {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin: 1.5rem 0;
}

.prompts-info p {
    margin-bottom: 0.5rem;
    color: var(--text);
}

.prompts-info ul {
    margin: 0.5rem 0 0 1.5rem;
}

.prompts-info li {
    margin: 0.25rem 0;
    color: var(--text-light);
}

.prompts-info code {
    background: var(--surface);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: monospace;
    color: var(--primary);
}

.prompts-list {
    display: grid;
    gap: 1rem;
}

.prompt-card {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
}

.prompt-card.active {
    border-color: var(--success);
    background: #f0fdf4;
}

.prompt-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
}

.prompt-info h3 {
    margin-bottom: 0.25rem;
    color: var(--text);
}

.prompt-info .prompt-name {
    font-family: monospace;
    color: var(--primary);
    font-size: 0.9rem;
}

.prompt-status {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
}

.prompt-status.active {
    background: var(--success);
    color: white;
}

.prompt-status.inactive {
    background: var(--secondary);
    color: white;
}

.prompt-description {
    color: var(--text-light);
    margin: 0.5rem 0;
}

.prompt-preview {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    margin: 1rem 0;
    font-family: monospace;
    font-size: 0.875rem;
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
}

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

/* Enhanced Expert Cards */
.expert-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s ease;
}

.expert-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.expert-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.expert-header h3 {
    color: var(--text);
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.expert-status {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.expert-status.active {
    background: var(--success);
    color: white;
}

.expert-status.inactive {
    background: var(--text-light);
    color: white;
}

.expert-description {
    color: var(--text-light);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.expert-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--background);
    border-radius: 8px;
}

.expert-stats .stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.expert-stats .stat-label {
    font-weight: 500;
    color: var(--text-light);
    font-size: 0.9rem;
}

.expert-stats .stat-value {
    font-weight: 600;
    color: var(--text);
}

.expert-stats .stat-value.sync-running {
    color: var(--success);
}

.expert-stats .stat-value.sync-error {
    color: var(--danger);
}

.expert-stats .stat-value.sync-paused {
    color: var(--warning);
}

.expert-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.expert-actions .btn {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* API Status Panel */
.api-status-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1.5rem 0;
    display: none;
}

.api-status-panel h3 {
    margin-bottom: 1rem;
    color: var(--text);
    font-size: 1.1rem;
}

.api-status-panel .status-grid {
    display: grid;
    gap: 0.75rem;
}

.api-status-panel .status-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--background);
    border-radius: 6px;
    border: 1px solid var(--border);
}

.api-status-panel .status-indicator {
    font-size: 1.2rem;
    line-height: 1;
}

.api-status-panel .status-indicator.success {
    color: var(--success);
}

.api-status-panel .status-indicator.error {
    color: var(--danger);
}

.api-status-panel .status-label {
    font-weight: 600;
    min-width: 120px;
}

.api-status-panel .status-message {
    color: var(--text-light);
    font-size: 0.9rem;
    flex: 1;
}

/* Enhanced Video Extraction Info */
.extraction-note {
    margin-top: 1rem;
    padding: 1rem;
    background: linear-gradient(135deg, #f0f7ff 0%, #e6f3ff 100%);
    border: 1px solid #b3d9ff;
    border-radius: 8px;
    border-left: 4px solid var(--primary);
}

.extraction-note.hidden {
    display: none;
}

.note-content strong {
    color: var(--primary);
    margin-bottom: 0.5rem;
    display: block;
}

.note-content p {
    color: var(--text);
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

.api-recommendation {
    margin-top: 1rem;
    padding: 1rem;
    background: linear-gradient(135deg, #fffbf0 0%, #fff5e6 100%);
    border: 1px solid #ffd699;
    border-radius: 8px;
    border-left: 4px solid var(--warning);
}

.api-recommendation.hidden {
    display: none;
}

.recommendation-content strong {
    color: var(--warning);
    margin-bottom: 0.5rem;
    display: block;
}

.recommendation-content p {
    color: var(--text);
    margin: 0.5rem 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

.recommendation-content small {
    color: var(--text-light);
    font-size: 0.8rem;
    display: block;
    margin-top: 0.5rem;
    font-style: italic;
}

#total-videos-count {
    font-weight: 600;
    color: var(--primary);
}

/* Enhanced info grid for better video count display */
.info-item .info-value.video-count {
    font-weight: 700;
    color: var(--success);
}

.info-item .info-value.total-videos {
    font-weight: 600;
    color: var(--primary);
}

.info-item .info-value.extraction-method {
    font-weight: 500;
    color: var(--text-light);
    font-size: 0.9rem;
}

/* YouTube API status indicator in settings */
.setting-item .youtube-api-note {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: var(--background);
    border-radius: 6px;
    border-left: 3px solid var(--warning);
    font-size: 0.85rem;
    color: var(--text-light);
}

.setting-item .youtube-api-note.configured {
    border-left-color: var(--success);
    background: #f0fdf4;
    color: var(--success);
}

@media (max-width: 768px) {
    .admin-main {
        padding: 1rem;
    }
    
    .settings-section, .experts-section, .history-section {
        padding: 1rem;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .section-header {
        flex-direction: column;
        align-items: start;
        gap: 1rem;
    }
    
    .modal-content.modal-large {
        max-width: 95%;
    }
    
    .extraction-note, .api-recommendation {
        padding: 0.75rem;
        margin-top: 0.75rem;
    }
    
    .note-content p, .recommendation-content p {
        font-size: 0.85rem;
    }
}

/* Desktop App Section */
.desktop-app-section {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.desktop-app-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.desktop-controls {
    display: flex;
    gap: 10px;
}

.desktop-status {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 15px;
    margin: 15px 0;
}

.desktop-status .status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.status-badge.connected {
    color: #10b981;
    font-weight: 600;
}

.status-badge.disconnected {
    color: #6b7280;
}

.desktop-clients-list {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e5e7eb;
}

.desktop-clients-list h4 {
    margin-bottom: 10px;
    color: #374151;
    font-size: 14px;
}

.desktop-client-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: white;
    border-radius: 4px;
    margin-bottom: 8px;
    border: 1px solid #e5e7eb;
}

.client-id {
    font-family: monospace;
    font-size: 12px;
    color: #6b7280;
}

.client-status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 12px;
    background: #f3f4f6;
    color: #374151;
}

.client-status.downloading {
    background: #dbeafe;
    color: #1e40af;
}

.client-status.idle {
    background: #f3f4f6;
    color: #6b7280;
}

.client-progress {
    font-size: 12px;
    color: #3b82f6;
    font-weight: 600;
}