/* =============================================
   Bank Soal - Modern UI Stylesheet
   ============================================= */

/* ---------- CSS Variables ---------- */
:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --primary-bg: #eef2ff;
    --secondary: #64748b;
    --success: #10b981;
    --success-bg: #ecfdf5;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --info: #3b82f6;
    --info-bg: #eff6ff;
    
    --bg: #f1f5f9;
    --bg-white: #ffffff;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --topbar-height: 65px;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.04);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,.1), 0 8px 10px -6px rgba(0,0,0,.04);
    --transition: all 0.3s cubic-bezier(.4,0,.2,1);
}

/* ---------- Reset ---------- */
*, *::before, *::after {
    margin: 0; padding: 0; box-sizing: border-box;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; }
button { cursor: pointer; border: none; outline: none; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #1e1b4b 0%, #312e81 40%, #4338ca 70%, #2563eb 100%);
    min-height: 100vh;
    position: fixed;
    left: 0; top: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    box-shadow: 4px 0 20px rgba(0,0,0,.15);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    font-size: 1.3rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
}

.logo i {
    font-size: 1.5rem;
    color: var(--primary-light);
    min-width: 30px;
    text-align: center;
}

.sidebar-toggle {
    background: rgba(255,255,255,.1);
    color: #fff;
    padding: 8px;
    border-radius: var(--radius-xs);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.sidebar-toggle:hover { background: rgba(255,255,255,.2); }

.sidebar.collapsed .sidebar-header { justify-content: center; padding: 20px 10px; }
.sidebar.collapsed .logo span { display: none; }
.sidebar.collapsed .sidebar-toggle { display: none; }
.sidebar.collapsed .nav-item span { display: none; }
.sidebar.collapsed .sidebar-footer { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 14px; }
.sidebar.collapsed .nav-item i { margin: 0; min-width: auto; font-size: 1.2rem; }

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: rgba(255,255,255,.7);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
}

.nav-item i {
    min-width: 22px;
    text-align: center;
    font-size: 1.05rem;
    transition: var(--transition);
}

.nav-item:hover {
    background: rgba(255,255,255,.1);
    color: #fff;
}

.nav-item.active {
    background: rgba(255,255,255,.15);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--primary-light);
}

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

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,.1);
    color: rgba(255,255,255,.4);
    font-size: .8rem;
    text-align: center;
}

/* ---------- Main Content ---------- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    max-width: calc(100% - var(--sidebar-width));
    min-width: 0;
    overflow-x: hidden;
    transition: var(--transition);
    min-height: 100vh;
}

.sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed);
    width: calc(100% - var(--sidebar-collapsed));
    max-width: calc(100% - var(--sidebar-collapsed));
}

/* ---------- Top Bar ---------- */
.topbar {
    background: var(--bg-white);
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 20px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow);
}

.mobile-toggle {
    display: none;
    background: none;
    color: var(--text);
    font-size: 1.3rem;
    padding: 8px;
}

.page-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box i {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    font-size: .9rem;
}

.search-box input {
    padding: 8px 16px 8px 38px;
    border: 2px solid var(--border);
    border-radius: 50px;
    background: var(--bg);
    width: 280px;
    transition: var(--transition);
    color: var(--text);
}

.search-box input:focus {
    border-color: var(--primary);
    outline: none;
    background: #fff;
    box-shadow: 0 0 0 3px var(--primary-bg);
}

/* ---------- Content Area ---------- */
.content-area {
    padding: 24px;
}

.page { display: none; }
.page.active { display: block; animation: fadeIn .3s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    border: 1px solid var(--border-light);
}

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

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

.stat-total .stat-icon { background: var(--primary-bg); color: var(--primary); }
.stat-mcq .stat-icon { background: var(--success-bg); color: var(--success); }
.stat-essay .stat-icon { background: var(--info-bg); color: var(--info); }
.stat-cat .stat-icon { background: var(--warning-bg); color: var(--warning); }

.stat-info h3 {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.2;
    color: var(--text);
}

.stat-info p {
    color: var(--text-secondary);
    font-size: .85rem;
    font-weight: 500;
}

/* ---------- Cards ---------- */
.card {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, #fafbff 0%, #f8fafc 100%);
}

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
}

.card-header h2 i {
    color: var(--primary);
    font-size: 1rem;
}

.card-body {
    padding: 24px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---------- Dashboard Grid ---------- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

.chart-container {
    min-height: 200px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chart-bar-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chart-bar-label {
    min-width: 100px;
    font-size: .85rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chart-bar-track {
    flex: 1;
    height: 28px;
    background: var(--bg);
    border-radius: 50px;
    overflow: hidden;
    position: relative;
}

.chart-bar-fill {
    height: 100%;
    border-radius: 50px;
    transition: width 0.8s cubic-bezier(.4,0,.2,1);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 10px;
    font-size: .75rem;
    font-weight: 700;
    color: #fff;
    min-width: 24px;
    max-width: 100%;
}

.chart-bar-fill.bar-1 { background: linear-gradient(135deg, #4f46e5, #7c3aed); }
.chart-bar-fill.bar-2 { background: linear-gradient(135deg, #10b981, #059669); }
.chart-bar-fill.bar-3 { background: linear-gradient(135deg, #f59e0b, #d97706); }
.chart-bar-fill.bar-4 { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.chart-bar-fill.bar-5 { background: linear-gradient(135deg, #ef4444, #dc2626); }
.chart-bar-fill.bar-6 { background: linear-gradient(135deg, #ec4899, #db2777); }

.difficulty-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.difficulty-item {
    text-align: center;
    padding: 20px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    transition: var(--transition);
}

.difficulty-item:hover {
    transform: scale(1.02);
}

.difficulty-item .diff-count {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.2;
}

.difficulty-item .diff-label {
    font-size: .85rem;
    font-weight: 600;
    margin-top: 4px;
}

.diff-easy { border-color: var(--success); }
.diff-easy .diff-count { color: var(--success); }
.diff-easy .diff-label { color: var(--success); }

.diff-medium { border-color: var(--warning); }
.diff-medium .diff-count { color: var(--warning); }
.diff-medium .diff-label { color: var(--warning); }

.diff-hard { border-color: var(--danger); }
.diff-hard .diff-count { color: var(--danger); }
.diff-hard .diff-label { color: var(--danger); }

/* ---------- Filters ---------- */
.filters-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-group { flex: 1; min-width: 160px; }

/* ---------- Forms ---------- */
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--bg-white);
    color: var(--text);
    transition: var(--transition);
    font-size: .95rem;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

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

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
    font-size: .9rem;
}

.form-group label i {
    color: var(--primary);
    margin-right: 4px;
}

.required { color: var(--danger); }

.form-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.col-4 { flex: 0 0 calc(33.333% - 14px); }
.col-8 { flex: 0 0 calc(66.666% - 6px); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }

/* ---------- Options Grid ---------- */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
    padding: 20px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.option-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: .9rem;
}

.option-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-size: .8rem;
    font-weight: 700;
    color: #fff;
}

.badge-a { background: #4f46e5; }
.badge-b { background: #10b981; }
.badge-c { background: #f59e0b; }
.badge-d { background: #3b82f6; }
.badge-e { background: #ec4899; }

/* ---------- Form Actions ---------- */
.form-actions {
    display: flex;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-xs);
    font-weight: 600;
    font-size: .9rem;
    transition: var(--transition);
    border: none;
    white-space: nowrap;
}

.btn:active { transform: scale(.97); }

.btn-sm { padding: 6px 14px; font-size: .8rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }
.btn-block { display: flex; width: 100%; }

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 2px 8px rgba(79,70,229,.3);
}
.btn-primary:hover { box-shadow: 0 4px 12px rgba(79,70,229,.4); transform: translateY(-1px); }

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

.btn-success { background: linear-gradient(135deg, var(--success), #059669); color: #fff; box-shadow: 0 2px 8px rgba(16,185,129,.3); }
.btn-success:hover { box-shadow: 0 4px 12px rgba(16,185,129,.4); transform: translateY(-1px); }

.btn-danger { background: linear-gradient(135deg, var(--danger), #dc2626); color: #fff; box-shadow: 0 2px 8px rgba(239,68,68,.3); }
.btn-danger:hover { box-shadow: 0 4px 12px rgba(239,68,68,.4); transform: translateY(-1px); }

.btn-warning { background: linear-gradient(135deg, var(--warning), #d97706); color: #fff; }
.btn-info { background: linear-gradient(135deg, var(--info), #2563eb); color: #fff; }

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-xs);
    font-size: .9rem;
}

.btn-icon.btn-sm { width: 30px; height: 30px; font-size: .8rem; }

/* ---------- Table ---------- */
.table-responsive {
    overflow-x: auto;
    margin: 0 -4px;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table th {
    background: var(--bg);
    padding: 12px 16px;
    text-align: left;
    font-weight: 700;
    font-size: .8rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: .5px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: var(--transition);
}

.data-table tbody tr:hover {
    background: var(--primary-bg);
}

.data-table tbody tr.selected {
    background: #ede9fe;
}

.question-text-cell {
    max-width: 350px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    color: var(--text);
    font-weight: 500;
}

.question-text-cell:hover {
    color: var(--primary);
}

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 50px;
    font-size: .75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-mcq { background: var(--success-bg); color: var(--success); }
.badge-essay { background: var(--info-bg); color: var(--info); }
.badge-easy { background: var(--success-bg); color: var(--success); }
.badge-medium { background: var(--warning-bg); color: var(--warning); }
.badge-hard { background: var(--danger-bg); color: var(--danger); }
.badge-answer { background: var(--primary-bg); color: var(--primary); font-weight: 700; }

/* ---------- Action Buttons ---------- */
.action-btns {
    display: flex;
    gap: 6px;
}

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding-top: 20px;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: var(--radius-xs);
    font-weight: 600;
    font-size: .85rem;
    background: var(--bg-white);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    transition: var(--transition);
    cursor: pointer;
}

.page-btn:hover { background: var(--primary-bg); color: var(--primary); border-color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- Import Section ---------- */
.upload-area {
    border: 3px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg);
    margin-bottom: 24px;
}

.upload-area.dragover {
    border-color: var(--primary);
    background: var(--primary-bg);
}

.upload-area:hover {
    border-color: var(--primary-light);
}

.upload-icon {
    font-size: 3.5rem;
    color: var(--primary-light);
    margin-bottom: 16px;
}

.upload-area h3 {
    font-size: 1.2rem;
    color: var(--text);
    margin-bottom: 8px;
}

.upload-area p {
    color: var(--text-secondary);
    font-size: .9rem;
}

.file-preview {
    margin-bottom: 20px;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--primary-bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--primary-light);
    font-weight: 600;
    color: var(--primary);
}

.file-info i:first-child { font-size: 1.3rem; }
.file-info span { flex: 1; }

.import-options {
    margin-bottom: 24px;
}

.import-result {
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-weight: 600;
}

.import-result.success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success);
}

.import-result.error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid var(--danger);
}

/* ---------- Format Guide ---------- */
.format-guide {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 24px;
    border: 1px solid var(--border);
}

.format-guide h3 {
    font-size: 1.05rem;
    margin-bottom: 16px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.format-guide h3 i { color: var(--info); }

.guide-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.guide-tab {
    padding: 8px 20px;
    background: var(--bg-white);
    border: 2px solid var(--border);
    border-radius: 50px;
    font-weight: 600;
    font-size: .85rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.guide-tab.active, .guide-tab:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.guide-content { display: none; }
.guide-content.active { display: block; animation: fadeIn .3s ease; }

.guide-content h4 {
    font-size: .95rem;
    margin-bottom: 8px;
    color: var(--text);
}

.guide-content p {
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.code-block {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: .82rem;
    line-height: 1.7;
    overflow-x: auto;
    margin-bottom: 16px;
    white-space: pre;
}

.guide-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .82rem;
    margin-bottom: 12px;
}

.guide-table th, .guide-table td {
    padding: 8px 12px;
    border: 1px solid var(--border);
    text-align: left;
}

.guide-table th { background: var(--primary-bg); color: var(--primary); font-weight: 700; }
.guide-table td { background: var(--bg-white); }

/* ---------- Categories Grid ---------- */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.category-card {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 20px;
    border: 1px solid var(--border);
    transition: var(--transition);
    position: relative;
}

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

.category-card h3 {
    font-size: 1.05rem;
    color: var(--text);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.category-card h3 i { color: var(--primary); font-size: .9rem; }

.category-card .cat-desc {
    color: var(--text-secondary);
    font-size: .85rem;
    margin-bottom: 12px;
    line-height: 1.5;
}

.category-card .cat-count {
    font-size: .85rem;
    color: var(--text-muted);
    font-weight: 600;
}

.category-card .cat-count span {
    color: var(--primary);
    font-weight: 800;
    font-size: 1.1rem;
}

.category-card .cat-actions {
    display: flex;
    gap: 6px;
    margin-top: 12px;
}

/* ---------- Modal ---------- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 24px;
    backdrop-filter: blur(4px);
}

.modal-overlay.active {
    display: flex;
    animation: fadeIn .2s ease;
}

.modal {
    background: var(--bg-white);
    border-radius: var(--radius);
    width: 100%;
    max-width: 700px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
    animation: slideUp .3s ease;
}

.modal-sm { max-width: 480px; }

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.modal-header h2 { font-size: 1.15rem; }

.modal-close {
    background: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    padding: 4px;
    line-height: 1;
    transition: var(--transition);
}

.modal-close:hover { color: var(--danger); }

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

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

/* Question detail in modal */
.question-detail {
    line-height: 1.8;
}

.question-detail .qd-label {
    font-weight: 700;
    color: var(--text-secondary);
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 4px;
    margin-top: 16px;
}

.question-detail .qd-label:first-child { margin-top: 0; }

.question-detail .qd-text {
    color: var(--text);
    font-size: 1rem;
    padding: 8px 0;
    white-space: pre-wrap;
}

.question-detail .qd-option {
    padding: 8px 14px;
    margin: 4px 0;
    border-radius: var(--radius-xs);
    background: var(--bg);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    transition: var(--transition);
}

.question-detail .qd-option.correct {
    background: var(--success-bg);
    border: 1px solid var(--success);
}

.question-detail .qd-option .opt-letter {
    font-weight: 700;
    color: var(--primary);
    min-width: 20px;
}

.question-detail .qd-option.correct .opt-letter {
    color: var(--success);
}

/* ---------- Toast ---------- */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    color: #fff;
    font-weight: 600;
    font-size: .9rem;
    box-shadow: var(--shadow-lg);
    min-width: 280px;
    max-width: 400px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastIn .3s ease;
}

.toast.toast-exit {
    animation: toastOut .3s ease forwards;
}

.toast-success { background: linear-gradient(135deg, #10b981, #059669); }
.toast-error { background: linear-gradient(135deg, #ef4444, #dc2626); }
.toast-info { background: linear-gradient(135deg, #3b82f6, #2563eb); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    to { opacity: 0; transform: translateX(40px); }
}

/* ---------- Loading ---------- */
.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,.7);
    z-index: 250;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

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

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

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

.empty-state h3 {
    font-size: 1.15rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.empty-state p {
    font-size: .9rem;
}

/* ---------- Recent Questions List ---------- */
.recent-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.recent-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    background: var(--bg);
    transition: var(--transition);
    cursor: pointer;
}

.recent-item:hover {
    background: var(--primary-bg);
}

.recent-item .ri-number {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .8rem;
    flex-shrink: 0;
}

.recent-item .ri-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.recent-item .ri-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
    .form-row { flex-direction: column; }
    .col-4, .col-8 { flex: 1 1 100%; }
    .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 200;
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
        max-width: 100%;
    }
    
    .mobile-toggle {
        display: flex;
    }
    
    .topbar {
        padding: 0 16px;
    }
    
    .search-box input { width: 180px; }
    
    .content-area { padding: 16px; }
    
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    
    .options-grid { grid-template-columns: 1fr; }
    
    .filters-bar { flex-direction: column; }
    .filter-group { min-width: auto; }
    
    .modal { max-height: 90vh; margin: 16px; }
    
    .difficulty-grid { grid-template-columns: 1fr; }
    
    .categories-grid { grid-template-columns: 1fr; }
    
    .page-title { font-size: 1.15rem; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .search-box { display: none; }
    .form-actions { flex-direction: column; }
    .btn-lg { width: 100%; }
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---------- Utilities ---------- */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.fw-bold { font-weight: 700; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.gap-2 { gap: 16px; }

/* ---------- Settings Page ---------- */
.settings-section {
    margin-bottom: 32px;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border);
}

.settings-section-title i {
    color: var(--primary);
    font-size: 1rem;
}

/* Theme Presets */
.theme-presets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 16px;
}

.theme-preset {
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    padding: 8px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
}

.theme-preset:hover {
    border-color: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.theme-preset.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.preset-preview {
    width: 100%;
    height: 70px;
    border-radius: var(--radius-xs);
    overflow: hidden;
    display: flex;
    margin-bottom: 8px;
}

.preset-sidebar {
    width: 30%;
    height: 100%;
}

.preset-content {
    width: 70%;
    height: 100%;
    position: relative;
}

.preset-content::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    height: 8px;
    background: rgba(255,255,255,.8);
    border-radius: 4px;
}

.preset-content::after {
    content: '';
    position: absolute;
    top: 22px;
    left: 8px;
    width: 40%;
    height: 30px;
    background: rgba(255,255,255,.6);
    border-radius: 4px;
}

.theme-preset span {
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.theme-preset.active span {
    color: var(--primary);
}

/* Color Settings Grid */
.color-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}

.color-group {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 20px;
    border: 1px solid var(--border);
}

.color-group h4 {
    font-size: .95rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-group h4 i {
    color: var(--primary);
    font-size: .85rem;
}

.color-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
}

.color-row:last-child {
    border-bottom: none;
}

.color-row label {
    font-size: .88rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.color-picker-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-picker-wrap input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    width: 36px;
    height: 36px;
    border: 2px solid var(--border);
    border-radius: var(--radius-xs);
    cursor: pointer;
    padding: 2px;
    background: var(--bg-white);
    transition: var(--transition);
}

.color-picker-wrap input[type="color"]:hover {
    border-color: var(--primary);
    transform: scale(1.1);
}

.color-picker-wrap input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.color-picker-wrap input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 3px;
}

.color-hex {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: .78rem;
    color: var(--text-muted);
    min-width: 64px;
    text-align: center;
    padding: 4px 8px;
    background: var(--bg-white);
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
}

@media (max-width: 768px) {
    .color-settings-grid { grid-template-columns: 1fr; }
    .theme-presets { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- User Dropdown ---------- */
.user-dropdown {
    position: relative;
}

.user-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 50px;
    padding: 6px 16px 6px 6px;
    cursor: pointer;
    transition: var(--transition);
}

.user-dropdown-toggle:hover {
    background: var(--primary-bg);
    border-color: var(--primary-light);
}

.user-dropdown-toggle .fa-chevron-down {
    font-size: .7rem;
    color: var(--text-muted);
    transition: transform .3s;
}

.user-avatar-sm {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: .8rem;
    font-weight: 700;
}

.user-avatar-md {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    flex-shrink: 0;
}

.user-name-topbar {
    font-weight: 600;
    font-size: .88rem;
    color: var(--text);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 260px;
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all .25s ease;
    z-index: 100;
    overflow: hidden;
}

.user-dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
}

.dropdown-user-info strong {
    display: block;
    font-size: .92rem;
    color: var(--text);
}

.dropdown-user-info small {
    color: var(--text-muted);
    font-size: .78rem;
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    font-size: .88rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition);
    cursor: pointer;
}

.dropdown-item:hover {
    background: var(--primary-bg);
    color: var(--primary);
}

.dropdown-item i {
    width: 18px;
    text-align: center;
    font-size: .9rem;
}

.dropdown-item-danger:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

/* ---------- Nav Logout Item ---------- */
.nav-item-logout {
    margin-top: auto;
}

.nav-item-logout:hover {
    background: rgba(239, 68, 68, .2) !important;
    color: #fca5a5 !important;
}

/* ---------- Profile Page ---------- */
.profile-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 24px;
    align-items: start;
}

.profile-card {
    text-align: center;
    overflow: visible;
}

.profile-card-header {
    padding: 32px 24px 24px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border-radius: var(--radius) var(--radius) 0 0;
}

.profile-avatar-lg {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 12px;
    border: 3px solid rgba(255,255,255,.3);
}

.profile-card-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.profile-card-header .text-muted {
    color: rgba(255,255,255,.7) !important;
    font-size: .85rem;
}

.profile-card-body {
    padding: 20px 24px;
}

.profile-stat {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: .88rem;
    color: var(--text-secondary);
}

.profile-stat:last-child {
    border-bottom: none;
}

.profile-stat i {
    color: var(--primary);
    width: 18px;
    text-align: center;
    font-size: .95rem;
}

.profile-stat span {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-forms {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ---------- Password Toggle in Forms ---------- */
.password-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-wrap .form-input {
    padding-right: 44px;
}

.password-toggle {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
    transition: color .3s;
}

.password-toggle:hover {
    color: var(--primary);
}

/* ---------- Password Strength ---------- */
.password-strength {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 8px 0;
}

.strength-bar {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.strength-fill {
    height: 100%;
    border-radius: 10px;
    transition: all .4s ease;
    width: 0;
}

.strength-text {
    font-size: .82rem;
    font-weight: 600;
    min-width: 90px;
    text-align: right;
}

@media (max-width: 1024px) {
    .profile-layout { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .user-name-topbar { display: none; }
    .user-dropdown-toggle .fa-chevron-down { display: none; }
    .user-dropdown-toggle { padding: 4px; }
    .user-dropdown-menu { right: -10px; }
    .profile-layout { grid-template-columns: 1fr; }
}
