:root {
    /* Professional color palette */
    --bg-color: #0f1419;
    --surface-dark: #1a1f2e;
    --surface-light: #252c3d;
    --card-bg: #1e2433;
    
    /* Professional accent colors */
    --primary-color: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #60a5fa;
    --secondary-color: #6366f1;
    --accent-color: #06b6d4;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    
    /* Text colors */
    --text-color: #e2e8f0;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    
    /* Border and effects */
    --border-color: #2d3748;
    --border-light: #374151;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
}

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

body {
    font-family: 'Segoe UI', 'Noto Sans', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 2;
}

/* Navigation */
.navbar {
    background: var(--surface-dark);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-color);
}

.nav-logo {
    font-size: 1.8rem;
}

.nav-links {
    display: flex;
    gap: 8px;
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-weight: 500;
}

.nav-link:hover {
    background: var(--surface-light);
    color: var(--primary-color);
}

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

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

/* Typography */
h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    font-weight: 700;
    letter-spacing: -0.5px;
}

h2 {
    font-size: 1.75rem;
    margin-bottom: 1rem;
    color: var(--text-color);
    font-weight: 600;
    position: relative;
    padding-left: 15px;
}

h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 70%;
    background: var(--primary-color);
    border-radius: 2px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.15rem;
    margin-bottom: 2rem;
    font-weight: 400;
    letter-spacing: 0.3px;
}

.page-header {
    margin-bottom: 32px;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

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

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: none;
    letter-spacing: 0;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--surface-dark);
    border-color: var(--border-light);
}

/* Form Inputs */
input[type="text"],
input[type="password"],
input[type="number"],
input[type="url"],
select,
textarea {
    width: 100%;
    padding: 0.75rem;
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 1rem;
    transition: all 0.2s ease;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="url"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--surface-dark);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    font-weight: 600;
    font-size: 0.95rem;
}

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

/* Grid Layouts */
.grid {
    display: grid;
    gap: 24px;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.stat-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

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

/* Library Styles */
.anime-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
    margin-top: 30px;
}

.anime-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
    display: block;
}

.anime-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.anime-card-header h3 {
    margin: 0 0 15px 0;
    color: var(--text-color);
    font-size: 1.3em;
    font-weight: 600;
}

.anime-card-body {
    display: flex;
    gap: 20px;
}

/* Episode List */
.episode-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 30px;
}

.episode-item {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.episode-item:hover {
    border-color: var(--primary-color);
    transform: translateX(4px);
    box-shadow: var(--shadow-lg);
}

.episode-info {
    flex: 1;
}

.episode-name {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-color);
    font-size: 1.1em;
}

.episode-meta {
    font-size: 0.9em;
    color: var(--text-muted);
    display: flex;
    gap: 12px;
    align-items: center;
}

.btn-download {
    background: var(--primary-color);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-download:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-download:active {
    transform: translateY(0);
}

/* Back Link */
.back-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    transition: all 0.2s ease;
    background: rgba(59, 130, 246, 0.1);
}

.back-link:hover {
    background: rgba(59, 130, 246, 0.2);
}

/* Progress Bars */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--surface-light);
    border-radius: 8px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s ease;
    border-radius: 8px;
}

/* Status Badges */
.status-badge {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-downloading,
.status-merging {
    background: var(--primary-color);
    color: white;
}

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

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

/* Loading & Empty States */
.loading,
.empty-state,
.error {
    text-align: center;
    padding: 4rem 3rem;
    color: var(--text-muted);
    font-size: 1.2rem;
    background: var(--card-bg);
    border-radius: 12px;
    border: 2px dashed var(--border-color);
}

.error {
    border-color: var(--danger-color);
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

/* Spinner */
.spinner {
    border: 3px solid rgba(59, 130, 246, 0.2);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 6px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 6px;
    border: 2px solid var(--bg-color);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* Selection Styling */
::selection {
    background: var(--primary-color);
    color: white;
}

::-moz-selection {
    background: var(--primary-color);
    color: white;
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: var(--card-bg);
    padding: 3rem;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    max-width: 450px;
    width: 100%;
    border: 1px solid var(--border-color);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

/* Alert/Error Messages */
.alert {
    padding: 1rem 1.25rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger-color);
    color: var(--danger-color);
}

/* Download Job Card */
.job-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
    margin-bottom: 16px;
    transition: all 0.2s ease;
}

.job-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.job-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 12px;
}

.job-title {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-color);
}

.log-container {
    background: var(--surface-dark);
    border-radius: 8px;
    padding: 12px;
    max-height: 200px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    border: 1px solid var(--border-color);
}

.log-entry {
    margin-bottom: 4px;
    color: var(--text-muted);
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 16px;
    }

    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
    }

    h1 {
        font-size: 2rem;
    }

    .anime-list {
        grid-template-columns: 1fr;
    }

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

    .episode-item {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }

    .btn-download {
        width: 100%;
    }
}
