/* ============================================
   Quiz App - Modern Design System
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #e0e7ff;
    --primary-bg: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --secondary: #64748b;
    --success: #10b981;
    --success-hover: #059669;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --warning: #f59e0b;
    --info: #06b6d4;
    --dark: #1e293b;
    --darker: #0f172a;
    --light: #f8fafc;
    --lighter: #f1f5f9;
    --white: #ffffff;
    --body-bg: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;
    --transition: all 0.2s ease;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* --- Global Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background-color: var(--body-bg);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

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

/* --- Navbar --- */
.navbar-modern {
    background: var(--darker) !important;
    padding: 0.75rem 0;
    box-shadow: var(--shadow-md);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.navbar-modern .navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.025em;
    background: var(--primary-bg);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.navbar-modern .nav-link {
    color: rgba(255, 255, 255, 0.7) !important;
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem !important;
    border-radius: var(--radius);
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.navbar-modern .nav-link:hover {
    color: var(--white) !important;
    background: rgba(255, 255, 255, 0.1);
}

.navbar-modern .nav-link i {
    font-size: 1rem;
}

.navbar-modern .btn-link.nav-link {
    color: rgba(255, 255, 255, 0.7) !important;
    text-decoration: none;
    padding: 0.5rem 0.75rem !important;
}

.navbar-modern .btn-link.nav-link:hover {
    color: var(--white) !important;
    background: rgba(255, 255, 255, 0.1);
}

.user-badge {
    background: rgba(99, 102, 241, 0.2);
    border: 1px solid rgba(99, 102, 241, 0.3);
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.8125rem;
    color: var(--white);
    font-weight: 500;
}

/* --- Main Content --- */
.main-content {
    flex: 1 0 auto;
    padding: 2rem 0;
}

/* --- Cards --- */
.card-modern {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    transition: var(--transition);
    overflow: hidden;
}

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

.card-header-modern {
    background: var(--white);
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
    font-weight: 600;
}

.card-body-modern {
    padding: 1.5rem;
}

/* --- Page Headers --- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1,
.page-header h2 {
    font-weight: 700;
    font-size: 1.75rem;
    letter-spacing: -0.025em;
    color: var(--text-primary);
    margin: 0;
}

.page-header .subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* --- Buttons --- */
.btn {
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    border: none;
    cursor: pointer;
}

.btn i {
    font-size: 1rem;
}

.btn-primary {
    background: var(--primary-bg);
    color: var(--white);
    box-shadow: 0 1px 2px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success);
    color: var(--white);
    box-shadow: 0 1px 2px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    background: var(--success-hover);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
    box-shadow: 0 1px 2px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: var(--danger-hover);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
    transform: translateY(-1px);
}

.btn-outline-primary {
    border: 1px solid var(--primary);
    color: var(--primary);
    background: transparent;
}

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

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

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

.btn-outline-danger {
    border: 1px solid var(--danger);
    color: var(--danger);
    background: transparent;
}

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

.btn-outline-success {
    border: 1px solid var(--success);
    color: var(--success);
    background: transparent;
}

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

.btn-outline-info {
    border: 1px solid var(--info);
    color: var(--info);
    background: transparent;
}

.btn-outline-info:hover {
    background: var(--info);
    color: var(--white);
}

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

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

/* --- Forms --- */
.form-control,
.form-select {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
    transition: var(--transition);
    background: var(--white);
    color: var(--text-primary);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    outline: none;
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
}

.form-text {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* --- Auth Forms (Login/Register) --- */
.auth-wrapper {
    min-height: calc(100vh - 200px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-card {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 440px;
    overflow: hidden;
}

.auth-card-header {
    background: var(--primary-bg);
    padding: 2rem;
    text-align: center;
    color: var(--white);
}

.auth-card-header h2 {
    font-weight: 700;
    font-size: 1.5rem;
    margin: 0;
    letter-spacing: -0.025em;
}

.auth-card-header p {
    margin: 0.5rem 0 0;
    opacity: 0.9;
    font-size: 0.9375rem;
}

.auth-card-body {
    padding: 2rem;
}

.auth-card-footer {
    padding: 1.25rem 2rem;
    background: var(--lighter);
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.auth-card-footer a {
    font-weight: 500;
}

/* --- Landing Page --- */
.hero-section {
    background: var(--primary-bg);
    color: var(--white);
    padding: 4rem 0;
    text-align: center;
}

.hero-section h1 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    margin-bottom: 1rem;
}

.hero-section p {
    font-size: 1.125rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto 2rem;
}

.hero-section .btn {
    padding: 0.75rem 2rem;
    font-size: 1rem;
}

/* --- Stats Cards --- */
.stat-card {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.stat-icon.primary {
    background: var(--primary-light);
    color: var(--primary);
}

.stat-icon.success {
    background: #d1fae5;
    color: var(--success);
}

.stat-icon.warning {
    background: #fef3c7;
    color: var(--warning);
}

.stat-icon.info {
    background: #cffafe;
    color: var(--info);
}

.stat-info h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

.stat-info p {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin: 0;
}

/* --- Accordion (Topics) --- */
.accordion-modern .accordion-item {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg) !important;
    margin-bottom: 0.75rem;
    overflow: hidden;
    background: var(--white);
    box-shadow: var(--shadow-sm);
}

.accordion-modern .accordion-button {
    padding: 1rem 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--white);
    border: none;
    box-shadow: none;
}

.accordion-modern .accordion-button:not(.collapsed) {
    background: var(--primary-light);
    color: var(--primary);
}

.accordion-modern .accordion-button:focus {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.accordion-modern .accordion-button::after {
    width: 1.25rem;
    height: 1.25rem;
    background-size: 1.25rem;
}

.accordion-modern .accordion-body {
    padding: 1.25rem;
    border-top: 1px solid var(--border-color);
}

/* --- List Groups --- */
.list-group-item {
    border-color: var(--border-color);
    padding: 0.875rem 1.25rem;
}

.list-group-item:hover {
    background: var(--lighter);
}

/* --- Badges --- */
.badge {
    font-weight: 500;
    font-size: 0.75rem;
    padding: 0.375rem 0.625rem;
    border-radius: var(--radius-full);
}

/* --- Alerts --- */
.alert {
    border: none;
    border-radius: var(--radius-lg);
    font-weight: 500;
    font-size: 0.9375rem;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border-left: 4px solid var(--success);
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid var(--danger);
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border-left: 4px solid var(--warning);
}

.alert-info {
    background: #cffafe;
    color: #155e75;
    border-left: 4px solid var(--info);
}

/* --- Tables --- */
.table {
    border-color: var(--border-color);
}

.table thead th {
    background: var(--lighter);
    border-color: var(--border-color);
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

/* --- Modals --- */
.modal-content {
    border: none;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
}

/* --- Footer --- */
.footer {
    background: var(--darker);
    color: rgba(255, 255, 255, 0.7);
    padding: 1rem 0;
    margin-top: auto;
}

.footer h5 {
    color: var(--white);
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 1rem;
}

.footer a {
    color: rgba(255, 255, 255, 0.6);
    transition: var(--transition);
}

.footer a:hover {
    color: var(--white);
}

.footer-links li {
    margin-bottom: 0.5rem;
}

.footer-links a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 1.5rem;
    margin-top: 1.5rem;
    font-size: 0.8125rem;
}

/* --- HTMX Loading States --- */
.htmx-loading {
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-block;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

.htmx-settling .htmx-indicator,
.htmx-settling.htmx-indicator {
    display: none;
}

/* Spinner for HTMX */
.htmx-spinner {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

.animate-slide-down {
    animation: slideDown 0.3s ease-out;
}

/* --- Empty States --- */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    display: block;
}

.empty-state h3 {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 0.9375rem;
    margin-bottom: 1.5rem;
}

/* --- Page Title Block --- */
{% block title %}{% endblock %}

/* --- Quiz Specific --- */
.quiz-card {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: var(--transition);
}

.quiz-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .hero-section h1 {
        font-size: 1.75rem;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .page-header h1,
    .page-header h2 {
        font-size: 1.375rem;
    }
    
    .navbar-modern .navbar-collapse {
        background: var(--darker);
        padding: 1rem;
        border-radius: var(--radius);
        margin-top: 0.5rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-info h3 {
        font-size: 1.25rem;
    }
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--lighter);
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}
