/* === RESET & BASE === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
}

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

/* === LAYOUT === */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

main.container {
    padding: 2rem 1rem;
    min-height: calc(100vh - 140px);
}

/* === NAVBAR === */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

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

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

.nav-menu a {
    color: var(--text);
    text-decoration: none;
    padding: 0.5rem 0;
    transition: color 0.2s;
}

.nav-menu a:hover {
    color: var(--primary);
}

.nav-dropdown {
    position: relative;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    padding: 0.5rem 0;
    list-style: none;
}

.nav-dropdown:hover .dropdown-menu {
    display: block;
}

.dropdown-menu a {
    display: block;
    padding: 0.5rem 1rem;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    gap: 0.5rem;
}

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

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

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

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

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

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

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

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

.btn-block {
    width: 100%;
}

.btn-back {
    background: transparent;
    color: var(--text-muted);
}

.btn-back:hover {
    color: var(--text);
}

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

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

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

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

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

.form-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 150px;
}

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

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

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

.input-small {
    padding: 0.375rem 0.5rem !important;
    font-size: 0.875rem !important;
}

.flex-grow {
    flex-grow: 1;
}

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

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-body {
    padding: 1.5rem;
}

.card-title {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.card-subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

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

.card-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.card-footer {
    padding: 1rem 1.5rem;
    background: var(--background);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.5rem;
}

/* === BADGES === */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
    background: var(--secondary);
    color: white;
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius);
}

.status-pending {
    background: #fef3c7;
    color: #92400e;
}

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

.status-completed {
    background: #dcfce7;
    color: #166534;
}

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

.clickable {
    cursor: pointer;
    border: none;
}

/* === ALERTS === */
.alert {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

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

/* === TABLES === */
.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
}

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

.table th {
    background: var(--background);
    font-weight: 600;
}

.table tr:hover {
    background: var(--background);
}

.table .actions {
    white-space: nowrap;
}

.table .actions form.inline {
    display: inline;
}

.row-inactive {
    opacity: 0.6;
}

/* === PAGE HEADER === */
.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.page-header p {
    color: var(--text-muted);
}

.page-header .lead {
    font-size: 1.125rem;
}

/* === TABS === */
.tabs {
    display: flex;
    gap: 0.5rem;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.5rem;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--text);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-panel {
    display: none;
}

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

/* === BIBBIA === */
.bibbia-content {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.bibbia-content h1,
.bibbia-content h2,
.bibbia-content h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.bibbia-content h1:first-child,
.bibbia-content h2:first-child,
.bibbia-content h3:first-child {
    margin-top: 0;
}

.bibbia-content ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.bibbia-preview {
    max-height: 400px;
    overflow-y: auto;
    font-size: 0.875rem;
}

/* === GALLERY === */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.gallery-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.gallery-item img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    cursor: pointer;
}

.gallery-item-info {
    padding: 0.75rem;
}

.gallery-item-info p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* === LIGHTBOX === */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.9);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    padding: 2rem;
}

.lightbox.active {
    display: flex;
}

.lightbox-image {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
}

.lightbox-caption {
    color: white;
    margin-top: 1rem;
    text-align: center;
}

/* === TWO COLUMN LAYOUT === */
.two-column-layout {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 2rem;
}

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

.sidebar-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.sidebar-box h3 {
    margin-bottom: 1rem;
}

/* === EPISODE VIEW === */
.episode-badge {
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-right: 0.5rem;
}

.episode-meta {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    color: var(--text-muted);
}

.episode-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

.screenplay {
    padding: 2rem;
    white-space: pre-wrap;
    font-family: "Courier New", monospace;
    font-size: 0.9rem;
    line-height: 1.8;
    max-height: 70vh;
    overflow-y: auto;
}

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

/* === EPISODES LIST === */
.episodes-list,
.episodes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.episode-number {
    background: var(--primary);
    color: white;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius);
    font-size: 0.75rem;
    margin-right: 0.5rem;
}

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

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

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

.stat-label {
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.stat-link {
    font-size: 0.875rem;
}

.stat-pending .stat-number {
    color: var(--warning);
}

.stat-processing .stat-number {
    color: var(--primary);
}

.stat-error .stat-number {
    color: var(--error);
}

.admin-sections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
}

.admin-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.admin-section h2 {
    margin-bottom: 1rem;
    font-size: 1.125rem;
}

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

.admin-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.panel-section {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.panel-section:last-child {
    border-bottom: none;
}

.panel-section h2 {
    margin-bottom: 1rem;
    font-size: 1.125rem;
}

.form-inline .form-row {
    align-items: flex-end;
}

/* === MEDIA ADMIN === */
.media-admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.media-admin-item {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.media-admin-item img {
    width: 100%;
    height: 150px;
    object-fit: cover;
}

.media-edit-form {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

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

/* === FILTERS === */
.filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

/* === DETAILS ROW === */
.details-row td {
    background: var(--background);
}

.request-details {
    padding: 1rem;
}

.request-details pre {
    background: var(--surface);
    padding: 1rem;
    border-radius: var(--radius);
    white-space: pre-wrap;
    margin: 0.5rem 0;
}

/* === CSV EXAMPLE === */
.csv-example {
    margin-top: 2rem;
    padding: 1rem;
    background: var(--background);
    border-radius: var(--radius);
}

.csv-example h3 {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.csv-example pre {
    font-size: 0.875rem;
    font-family: monospace;
}

/* === EMPTY STATE === */
.empty-state {
    text-align: center;
    padding: 3rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.empty-state h3 {
    margin-bottom: 0.5rem;
}

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

/* === UTILITIES === */
.text-muted {
    color: var(--text-muted);
}

.text-error {
    color: var(--error);
}

.truncate {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
}

.inline {
    display: inline;
}

/* === LOGIN PAGE === */
.login-page {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 1rem;
}

.login-box {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

.login-title {
    text-align: center;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

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

/* === FOOTER === */
.footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 1rem 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* === SERIES ACTIONS === */
.series-actions {
    margin-bottom: 2rem;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .nav-container {
        flex-wrap: wrap;
    }

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

    .cards-grid {
        grid-template-columns: 1fr;
    }

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

    .admin-sections {
        grid-template-columns: 1fr;
    }

    .form-row {
        flex-direction: column;
    }

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