@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --background: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --radius: 12px;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    margin: 0;
}

/* Navbar */
header {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    gap: 12px;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.025em;
}

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

.nav-link {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9375rem;
    transition: 0.2s;
}

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

.welcome-user {
    color: #0f172a;
    /* Deep navy/black */
    font-weight: 700;
    font-size: 0.9rem;
    padding-right: 12px;
}

/* Containers */
.container {
    max-width: 1200px;
    margin: 2.5rem auto;
    padding: 0 1.5rem;
}

/* Global Content Card (default for many pages) */
.page-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 2.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

/* Typography */
h1,
h2,
h3,
h4 {
    color: var(--text-main);
    font-weight: 700;
    letter-spacing: -0.025em;
}

h1 {
    font-size: 2.25rem;
    margin-bottom: 1.5rem;
}

h2 {
    font-size: 1.875rem;
    margin-bottom: 1.25rem;
}

h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9375rem;
    text-decoration: none;
    transition: 0.2s;
    cursor: pointer;
    border: none;
    gap: 8px;
}

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

.btn-primary:hover,
.btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
    background-color: #f1f5f9;
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background-color: #e2e8f0;
    color: var(--text-main);
}

.logout-btn {
    background-color: #fee2e2;
    color: #991b1b;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.875rem;
}

.logout-btn:hover {
    background-color: #fecaca;
}

.btn-pdf {
    background-color: #fef2f2;
    color: #dc2626;
    border: 1px solid #fee2e2;
}

.btn-pdf:hover {
    background-color: #fee2e2;
    color: #991b1b;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(220, 38, 38, 0.1);
}

/* Form Styling */
.form-group {
    margin-bottom: 1.5rem;
}

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

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 1rem;
    font-family: inherit;
    transition: 0.2s;
    background: white;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    font-weight: 500;
    border: 1px solid transparent;
}

.alert-error,
.alert-danger {
    background-color: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

.alert-success {
    background-color: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}

/* Quiz List Items (Dashboard) */
.quiz-list-item {
    background: white;
    border: 1px solid var(--border);
    padding: 1.5rem;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    transition: 0.2s;
}

.quiz-list-item:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--primary);
}

.quiz-list-item h4 {
    margin-bottom: 0.25rem;
    font-size: 1.125rem;
}

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

/* Badge */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-link {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
}

.badge-link:hover {
    background: var(--primary) !important;
    color: white !important;
    border-color: var(--primary) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3);
}

/* Responsive */
@media (max-width: 768px) {
    .header-container {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-menu {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .container {
        margin-top: 1.5rem;
    }

    .quiz-list-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
    }

    .quiz-list-item div:last-child {
        width: 100%;
        display: flex;
        flex-direction: column;
    }

    .quiz-list-item .btn {
        width: 100%;
    }
}

/* Markdown & Math Spacing */
.q-text table,
.passage-box table,
.solution-block table,
.q-content table {
    width: auto;
    max-width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.95rem;
    border: 1px solid var(--border);
    background: white;
}

.q-text th,
.passage-box th,
.solution-block th,
.q-content th,
.q-text td,
.passage-box td,
.solution-block td,
.q-content td {
    padding: 10px 16px;
    border: 1px solid var(--border);
    text-align: left;
}

.q-text th,
.passage-box th,
.solution-block th,
.q-content th {
    background: #f1f5f9;
    font-weight: 700;
    color: var(--text-main);
}

.q-text tr:nth-child(even),
.passage-box tr:nth-child(even),
.q-content tr:nth-child(even) {
    background: #f8fafc;
}

/* Image Styling - Global */
.q-img,
.sol-img,
.q-inline-img,
.q-text img,
.q-content img,
.solution-block img,
.opt-img,
.mat-img {
    display: block;
    margin: 2rem auto;
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border);
    background: white;
}

.opt-img,
.mat-img {
    margin: 1rem 0;
    max-width: 200px;
    max-height: 150px;
    box-shadow: none;
    border-radius: 8px;
}

.q-img:hover {
    transform: scale(1.01);
    transition: transform 0.2s ease;
}

/* Math & Overflow Handling */
.q-text,
.solution-block,
.passage-box,
.q-content {
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-width: 0;
}

/* MathJax responsiveness */
.MathJax,
.mjx-chtml,
.mjx-math {
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    vertical-align: middle;
}

/* Responsive adjustment for images */
@media (max-width: 600px) {

    .q-img,
    .sol-img,
    .q-inline-img {
        max-width: 100%;
    }
}