:root {
    --primary: #6c5ce7;
    --primary-light: #a29bfe;
    --primary-dark: #5a4bd1;
    --accent: #00cec9;
    --success: #00b894;
    --warning: #fdcb6e;
    --danger: #ff7675;
    --danger-dark: #d63031;

    --bg-dark: #0f0f23;
    --bg-card: rgba(255, 255, 255, 0.06);
    --bg-card-hover: rgba(255, 255, 255, 0.10);
    --bg-input: rgba(255, 255, 255, 0.08);
    --bg-sidebar: rgba(255, 255, 255, 0.04);

    --text-primary: #ffffff;
    --text-secondary: #b2bec3;
    --text-muted: #636e72;

    --border: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(108, 92, 231, 0.5);

    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);

    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    --transition: all 0.2s ease;
}

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

body {
    font-family: var(--font);
    background: var(--bg-dark);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(108, 92, 231, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(0, 206, 201, 0.1) 0%, transparent 50%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

/* ========== TYPOGRAPHY ========== */
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.5rem; font-weight: 700; }
h3 { font-size: 1.15rem; font-weight: 600; }
p { color: var(--text-secondary); }

/* ========== FORMS ========== */
input, select, textarea {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: var(--font);
    width: 100%;
    transition: var(--transition);
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}

input::placeholder, textarea::placeholder {
    color: var(--text-muted);
}

select option {
    background: #1a1a2e;
    color: var(--text-primary);
}

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #55efc4);
    color: #1a1a2e;
}

.btn-danger {
    background: rgba(255, 118, 117, 0.15);
    color: var(--danger);
    border: 1px solid rgba(255, 118, 117, 0.2);
}
.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-icon {
    padding: 8px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-icon:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

/* ========== CARD ========== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: var(--transition);
}
.card:hover {
    background: var(--bg-card-hover);
}

/* ========== BADGE ========== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}
.badge-success { background: rgba(0,184,148,0.15); color: var(--success); }
.badge-danger { background: rgba(255,118,117,0.15); color: var(--danger); }
.badge-primary { background: rgba(108,92,231,0.15); color: var(--primary-light); }
.badge-warning { background: rgba(253,203,110,0.15); color: var(--warning); }

/* ========== TABLE ========== */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: rgba(255,255,255,0.03);
}

th {
    text-align: left;
    padding: 12px 16px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 12px 16px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

tr:last-child td { border-bottom: none; }

tr:hover td {
    background: rgba(255,255,255,0.02);
}

/* ========== STAT CARD ========== */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-card .stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ========== MODAL ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: #1a1a2e;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 550px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(20px) scale(0.95);
    transition: var(--transition);
}

.modal-overlay.active .modal {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

/* ========== TOAST ========== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
    min-width: 250px;
    box-shadow: var(--shadow);
}

.toast-success { background: var(--success); color: #1a1a2e; }
.toast-error { background: var(--danger); color: white; }
.toast-warning { background: var(--warning); color: #1a1a2e; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes fadeOut {
    to { opacity: 0; transform: translateX(50%); }
}

/* ========== LOADING ========== */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary-light);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
}

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

/* ========== UTILITIES ========== */
.hidden { display: none !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }
.mt-md { margin-top: 16px; }
.mb-md { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }

/* ========== LOGIN PAGE ========== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    backdrop-filter: blur(20px);
}

.login-card h1 {
    text-align: center;
    margin-bottom: 8px;
}

.login-card p {
    text-align: center;
    margin-bottom: 24px;
}

.login-card .form-group {
    margin-bottom: 16px;
}

.login-card .btn {
    width: 100%;
    justify-content: center;
    padding: 12px;
    margin-top: 8px;
}

.login-error {
    background: rgba(255, 118, 117, 0.1);
    border: 1px solid rgba(255, 118, 117, 0.2);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 16px;
    display: none;
}

/* ========== ADMIN LAYOUT ========== */
.admin-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    grid-template-rows: 64px 1fr;
    min-height: 100vh;
}

.admin-header {
    grid-column: 1 / -1;
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.admin-header .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 700;
}

.admin-header .logo span {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.admin-header .user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-sidebar {
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    padding: 20px 12px;
    overflow-y: auto;
}

.admin-sidebar .nav-section {
    margin-bottom: 24px;
}

.admin-sidebar .nav-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0 12px;
    margin-bottom: 8px;
}

.admin-sidebar .nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    user-select: none;
}

.admin-sidebar .nav-item:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text-primary);
}

.admin-sidebar .nav-item.active {
    background: rgba(108, 92, 231, 0.15);
    color: var(--primary-light);
}

.admin-sidebar .nav-item .nav-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.admin-content {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(100vh - 64px);
}

.admin-content .page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

/* ========== STAT GRID ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

/* ========== FILE DROP ========== */
.file-drop {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-muted);
    font-size: 0.9rem;
}

.file-drop:hover,
.file-drop.drag-over {
    border-color: var(--primary);
    background: rgba(108, 92, 231, 0.05);
    color: var(--primary-light);
}

.file-drop img {
    max-width: 200px;
    max-height: 150px;
    border-radius: var(--radius-sm);
    margin-top: 10px;
}

/* ========== FORM GRID ========== */
.form-grid {
    display: grid;
    gap: 16px;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* ========== MOBILE BOTTOM NAV ========== */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 62px;
    background: rgba(15, 15, 35, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    z-index: 200;
    grid-template-columns: repeat(5, 1fr);
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 0.6rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    padding: 6px 2px;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.mobile-nav-item .mobile-nav-icon {
    font-size: 1.3rem;
    line-height: 1;
}

.mobile-nav-item.active {
    color: var(--primary-light);
}

.mobile-nav-item:active {
    opacity: 0.7;
}

/* ========== RESPONSIVE ========== */

/* Tablet: icon-only sidebar (769px - 1100px) */
@media (min-width: 769px) and (max-width: 1100px) {
    .admin-layout {
        grid-template-columns: 64px 1fr;
    }
    .admin-sidebar {
        padding: 20px 6px;
    }
    .admin-sidebar .nav-label {
        display: none;
    }
    .admin-sidebar .nav-section {
        margin-bottom: 8px;
    }
    .admin-sidebar .nav-item {
        justify-content: center;
        padding: 12px 8px;
        gap: 0;
    }
    .admin-sidebar .nav-item .nav-text {
        display: none;
    }
    .admin-sidebar .nav-item .nav-icon {
        font-size: 1.3rem;
        width: auto;
    }
}

/* Mobile: bottom nav (<768px) */
@media (max-width: 768px) {
    .admin-layout {
        grid-template-columns: 1fr;
    }
    .admin-sidebar {
        display: none;
    }
    .admin-content {
        padding: 16px;
        padding-bottom: 80px;
    }
    .mobile-nav {
        display: grid;
    }
    .toast-container {
        top: auto;
        bottom: 74px;
        right: 12px;
        left: 12px;
    }
    .toast {
        min-width: unset;
    }
    .form-grid-2 {
        grid-template-columns: 1fr;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .admin-header {
        padding: 0 16px;
    }
    .table-wrapper {
        font-size: 0.82rem;
    }
    td, th {
        padding: 10px 12px;
    }
}

/* ========== PDF EXTRACTION ========== */
.pdf-questions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    max-height: 55vh;
    overflow-y: auto;
    padding-right: 4px;
}

.pdf-question-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: var(--transition);
}

.pdf-question-card:hover {
    border-color: var(--primary);
}

.pdf-question-img {
    position: relative;
    cursor: pointer;
    background: #fff;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pdf-question-img img {
    width: 100%;
    height: auto;
    max-height: 200px;
    object-fit: contain;
    display: block;
}

.pdf-question-number {
    position: absolute;
    top: 6px;
    left: 6px;
    background: var(--primary);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.pdf-question-controls {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pdf-answer-group {
    display: flex;
    gap: 4px;
}

.pdf-answer-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 4px;
    border-radius: 6px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: var(--transition);
    color: var(--text-secondary);
    margin-bottom: 0;
}

.pdf-answer-option:has(input:checked) {
    background: rgba(108, 92, 231, 0.2);
    border-color: var(--primary);
    color: var(--primary-light);
}

.pdf-answer-option input[type="radio"] {
    display: none;
}

.pdf-difficulty-select {
    width: 100%;
    padding: 5px 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
}

@media (max-width: 768px) {
    .pdf-questions-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .pdf-questions-grid {
        grid-template-columns: 1fr;
    }
}
