/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4a90d9;
    --primary-dark: #357abd;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #17a2b8;
    --text-color: #333;
    --text-muted: #6c757d;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --border-color: #e1e5eb;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navbar */
.navbar {
    background-color: var(--card-bg);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand a {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-color);
    text-decoration: none;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

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

.nav-user {
    color: var(--text-color);
    font-weight: 500;
}

.nav-logout {
    color: var(--danger-color) !important;
}

/* Container */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
}

/* Flash messages */
.flash-messages {
    margin-bottom: 1.5rem;
}

.flash {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.flash-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.flash-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.flash-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Auth pages */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.auth-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.auth-card h1 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-link {
    text-align: center;
    margin-top: 1rem;
    color: var(--text-muted);
}

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

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

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-help {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.static-value {
    padding: 0.75rem 1rem;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-color);
    font-weight: 500;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-actions {
    margin-top: 1.5rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s;
}

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

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

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-large {
    padding: 0.75rem 1.5rem;
    font-size: 1.1rem;
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

/* Dashboard */
.dashboard h1 {
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.job-form {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 2rem;
}

.info-box {
    background: #e7f3ff;
    border: 1px solid #b3d7ff;
    border-radius: 8px;
    padding: 1.5rem;
}

.info-box h3 {
    margin-bottom: 1rem;
    color: var(--primary-dark);
}

.info-box ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.info-box li {
    margin-bottom: 0.5rem;
}

/* Status page */
.status-page {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

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

.status-header h1 {
    font-size: 1.5rem;
}

.status-badge {
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-pending {
    background-color: #fff3cd;
    color: #856404;
}

.status-running {
    background-color: #cce5ff;
    color: #004085;
}

.status-completed {
    background-color: #d4edda;
    color: #155724;
}

.status-failed {
    background-color: #f8d7da;
    color: #721c24;
}

.status-script_running {
    background-color: #cce5ff;
    color: #004085;
}

.status-awaiting_approval {
    background-color: #fff3cd;
    color: #856404;
    border: 2px solid #ffc107;
}

.status-voiceover_running {
    background-color: #d1ecf1;
    color: #0c5460;
}

.status-info {
    margin-bottom: 1.5rem;
}

.info-row {
    display: flex;
    margin-bottom: 0.5rem;
}

.info-row .label {
    font-weight: 500;
    width: 100px;
    color: var(--text-muted);
}

.progress-section,
.error-section {
    margin-bottom: 1.5rem;
}

.progress-section h2,
.error-section h2 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}

.progress-log,
.error-log {
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.875rem;
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
}

.error-log {
    background: #fff5f5;
    border-color: #f5c6cb;
}

.status-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* Approval Section */
.approval-section {
    background: #fffbeb;
    border: 2px solid #fcd34d;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.approval-section h2 {
    color: #92400e;
    margin-bottom: 0.75rem;
}

.approval-instructions {
    color: #78350f;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.intro-preview {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.intro-preview pre {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
    color: var(--text-color);
}

.approval-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.inline-form {
    display: inline;
}

.reject-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

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

.feedback-input textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

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

.btn-success:hover {
    background-color: #218838;
}

.btn-warning {
    background-color: #e67e22;
    color: white;
}

.btn-warning:hover {
    background-color: #d35400;
}

/* Jobs list */
.jobs-page .page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.jobs-page {
    max-width: 1000px;
}

.jobs-table {
    width: 100%;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border-collapse: collapse;
    overflow: hidden;
}

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

.jobs-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
}

.jobs-table tbody tr:hover {
    background-color: #f8f9fa;
}

.jobs-table tbody tr:last-child td {
    border-bottom: none;
}

.jobs-table .title-cell {
    font-weight: 500;
}

.jobs-table .actions-cell {
    display: flex;
    gap: 0.5rem;
}

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

.job-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.job-header {
    margin-bottom: 1rem;
}

.job-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.job-meta {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.job-meta-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.job-meta-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    min-width: 70px;
}

.job-meta-value {
    font-size: 0.875rem;
}

.channel-tag,
.voice-tag,
.date-tag {
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background: #f0f0f0;
    color: var(--text-muted);
}

.channel-ALL {
    background: #e8f4fd;
    color: #1a73e8;
}

.channel-WYL {
    background: #fef3e2;
    color: #e37400;
}

.job-actions {
    display: flex;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

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

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* Admin Navigation */
.nav-admin {
    color: #9333ea !important;
    font-weight: 500;
}

.nav-admin:hover,
.nav-admin.active {
    color: #7e22ce !important;
}

/* Admin Pages */
.admin-page {
    max-width: 1000px;
}

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

.admin-page h1 {
    margin: 0;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Admin Sections */
.admin-section {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 1.5rem;
}

.admin-section h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.action-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Admin Table */
.admin-table {
    width: 100%;
    border-collapse: collapse;
}

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

.admin-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.875rem;
    text-transform: uppercase;
}

.admin-table tbody tr:hover {
    background-color: #f8f9fa;
}

.admin-table .actions-cell {
    display: flex;
    gap: 0.5rem;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-admin {
    background: #f3e8ff;
    color: #7e22ce;
}

.badge-user {
    background: #e0f2fe;
    color: #0369a1;
}

.badge-info {
    background: #dbeafe;
    color: #1d4ed8;
    margin-left: 0.5rem;
}

/* Form Card */
.form-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    max-width: 500px;
}

.admin-form .form-actions {
    display: flex;
    gap: 0.75rem;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
}

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

.btn-danger:hover {
    background-color: #c82333;
}

/* User Jobs Section */
.user-jobs-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.user-jobs-section h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

/* Back Link */
.back-link {
    margin-top: 2rem;
}

.back-link a {
    color: var(--text-muted);
    text-decoration: none;
}

.back-link a:hover {
    color: var(--primary-color);
}

/* Empty Message */
.empty-message {
    color: var(--text-muted);
    font-style: italic;
}

/* Error Pages */
.error-page {
    text-align: center;
    padding: 4rem 2rem;
}

.error-page h1 {
    font-size: 6rem;
    color: var(--text-muted);
    margin-bottom: 0;
}

.error-page h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.error-page p {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* Footer */
.footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    border-top: 1px solid var(--border-color);
}

/* Responsive */
@media (max-width: 640px) {
    .container {
        padding: 1rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .navbar {
        padding: 1rem;
    }

    .nav-links {
        gap: 1rem;
    }

    .status-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .status-actions {
        flex-direction: column;
    }

    .job-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}
