:root {
    /* Color Palette */
    --primary: #FFD13B;
    --primary-light: #FFE485;
    --primary-dark: #E6B82E;
    --secondary: #3E2723;
    --bg-main: #FFF8D6; /* Soft yellow for dashboard background to prevent eye strain, matching theme */
    --bg-card: #ffffff;
    --text-primary: #3E2723;
    --text-secondary: #5D4037;
    --text-muted: #8D6E63;
    --border: #E8D5B5;
    
    /* Layout */
    --sidebar-width: 260px;
    --header-height: 80px;
    
    /* Effects */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --radius-md: 12px;
    --radius-lg: 20px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    overflow-x: hidden;
}

/* Dashboard Container */
.dashboard-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-header {
    height: auto;
    display: flex;
    justify-content: center;
    padding: 24px 16px;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--primary);
}

.logo-img {
    height: 60px;
    width: auto;
    object-fit: contain;
}

.logo-text {
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.4;
    text-align: center;
    color: var(--secondary);
    text-transform: uppercase;
}

.nav-links {
    list-style: none;
    padding: 24px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-links a, .sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.nav-links a:hover, .sidebar-footer a:hover {
    background-color: var(--bg-main);
    color: var(--secondary);
    transform: translateX(5px);
}

.nav-links a i, .sidebar-footer a i {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.nav-links li.active a {
    background-color: var(--primary);
    color: var(--secondary);
    font-weight: 600;
}

.sidebar-footer {
    padding: 24px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

/* Header */
.top-header {
    height: var(--header-height);
    background-color: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 90;
    backdrop-filter: blur(10px);
    background-color: rgba(255, 255, 255, 0.8);
}

.search-bar {
    display: flex;
    align-items: center;
    background-color: var(--bg-main);
    padding: 10px 20px;
    border-radius: 30px;
    width: 400px;
    border: 1px solid transparent;
    transition: var(--transition);
}

.search-bar:focus-within {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.search-bar i {
    color: var(--text-muted);
    margin-right: 12px;
}

.search-bar input {
    border: none;
    background: none;
    outline: none;
    width: 100%;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 24px;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
    position: relative;
    transition: var(--transition);
}

.icon-btn:hover {
    color: var(--primary);
    transform: scale(1.1);
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: #D4960D;
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    height: 18px;
    width: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid white;
}

.profile-info {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 30px;
    transition: var(--transition);
}

.profile-info:hover {
    background-color: var(--bg-main);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-light);
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.user-level {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Dashboard Body */
.dashboard-body {
    padding: 40px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.page-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(90deg, var(--text-primary), var(--primary-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.page-subtitle {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

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

.stat-card {
    background-color: var(--bg-card);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: var(--transition);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background-color: var(--primary);
    opacity: 0;
    transition: var(--transition);
}

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

.stat-card:hover::before {
    opacity: 1;
}

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

.stat-info h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 8px;
}

.stat-info p {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Layout Columns */
.content-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 32px;
}

.card {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    padding: 24px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.card-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
}

.view-all {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
}

.view-all:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* In Progress Exams */
.exam-in-progress-item {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    margin-bottom: 16px;
    transition: var(--transition);
    background-color: var(--bg-main);
}

.exam-in-progress-item:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
    transform: translateY(-2px);
}

.exam-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    background-color: var(--primary-light);
    color: var(--secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.exam-details {
    flex: 1;
}

.exam-title {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 1.05rem;
}

.exam-meta {
    display: flex;
    gap: 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.progress-bar {
    height: 6px;
    background-color: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 3px;
    transition: width 1s ease-in-out;
}

.btn-secondary {
    background-color: transparent;
    color: var(--secondary);
    border: 1px solid var(--secondary);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

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

/* Recommended Exams Grid */
.exam-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.exam-card {
    padding: 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    transition: var(--transition);
    background-color: var(--bg-main);
    position: relative;
    display: flex;
    flex-direction: column;
}

.exam-card:hover {
    background-color: var(--bg-main);
    border-color: var(--primary-dark);
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

.badge-new {
    position: absolute;
    top: -10px;
    right: 20px;
    background-color: #D4960D;
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 12px;
}

.exam-card-title {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 12px;
    line-height: 1.4;
    flex: 1;
}

.exam-card-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.exam-card-info span {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--secondary);
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
}

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

/* Recent Results */
.result-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-radius: var(--radius-md);
    background-color: var(--bg-main);
    border: 1px solid transparent;
    transition: var(--transition);
}

.result-item:hover {
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
    transform: translateX(5px);
}

.result-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.result-title {
    font-size: 0.95rem;
    font-weight: 600;
}

.result-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.result-score {
    display: flex;
    align-items: baseline;
    font-weight: 700;
}

.score-value {
    font-size: 1.2rem;
}

.score-value.pass {
    color: var(--secondary);
}

.score-value.fail {
    color: #A85A32;
}

.score-max {
    font-size: 0.8rem;
    color: var(--text-muted);
}

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

.dashboard-body {
    animation: fadeIn 0.5s ease-out forwards;
}

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

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .main-content {
        margin-left: 0;
    }
    .search-bar {
        width: 200px;
    }
}

/* Auth Page Styles */
.auth-page {
    background-color: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-container {
    display: flex;
    max-width: 1000px;
    width: 100%;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.auth-left {
    flex: 1;
    background: linear-gradient(135deg, #FFFDF5, #FDE68A);
    color: #4A3000;
    padding: 40px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border-right: 1px solid #FDE68A;
}

.auth-branding h1 {
    font-size: 2rem;
    margin: 20px 0 10px;
    font-weight: 700;
}

.auth-branding p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.auth-logo {
    height: 60px;
    background: white;
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(212, 150, 13, 0.1);
}

.community-info {
    margin-top: 40px;
}

.community-info h3 {
    font-size: 1.2rem;
    margin-bottom: 20px;
    font-weight: 600;
}

.community-links {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.community-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(255, 255, 255, 0.7);
    padding: 16px;
    border-radius: var(--radius-md);
    text-decoration: none;
    color: #4A3000;
    transition: var(--transition);
    border: 1px solid rgba(212, 150, 13, 0.2);
}

.community-card:hover {
    background: #ffffff;
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(212, 150, 13, 0.15);
}

.community-card.zalo .icon-wrapper {
    background: #0068ff;
}

.community-card.facebook .icon-wrapper {
    background: #1877f2;
}

.icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.community-text h4 {
    font-size: 1rem;
    margin-bottom: 4px;
}

.community-text p {
    font-size: 0.85rem;
    opacity: 0.8;
}

.auth-right {
    flex: 1.2;
    padding: 40px;
    background: white;
}

.auth-form-container h2 {
    font-size: 1.8rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.auth-subtitle {
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

.form-row .form-group {
    flex: 1;
}

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

.form-group label {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
}

.required {
    color: #ef4444;
}

.form-group input, 
.form-group select, 
.form-group textarea {
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: inherit;
    transition: var(--transition);
    background-color: var(--bg-main);
}

.form-group input:focus, 
.form-group select:focus, 
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    background-color: white;
}

.auth-submit {
    margin-top: 10px;
    padding: 14px;
    font-size: 1.1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

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

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

.modal-content {
    background: white;
    padding: 40px;
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: var(--transition);
}

.modal-overlay.show .modal-content {
    transform: translateY(0);
}

.modal-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    margin: 0 auto 24px;
}

.modal-icon.success {
    background: #d1fae5;
    color: #10b981;
}

.modal-content h2 {
    font-size: 1.8rem;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.6;
}

.modal-notice {
    background: #fffbeb;
    border: 1px solid #fde68a;
    padding: 16px;
    border-radius: var(--radius-md);
    display: flex;
    gap: 12px;
    text-align: left;
    margin-bottom: 32px;
}

.modal-notice i {
    color: #f59e0b;
    font-size: 1.2rem;
    margin-top: 2px;
}

.modal-notice p {
    margin: 0;
    font-size: 0.9rem;
    color: #92400e;
}

@media (max-width: 768px) {
    .auth-container {
        flex-direction: column;
    }
    
    .form-row {
        flex-direction: column;
        gap: 20px;
    }
}

/* Exam Interface Styles */
.exam-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: var(--bg-main);
    overflow: hidden;
}

.exam-header {
    height: 70px;
    background-color: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

.exam-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.back-btn {
    color: var(--text-secondary);
    font-size: 1.2rem;
    transition: var(--transition);
}

.back-btn:hover {
    color: var(--primary);
    transform: translateX(-3px);
}

.exam-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.exam-logo {
    height: 32px;
}

#exam-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.exam-timer {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #FFF9E6;
    color: #D4960D;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 1.25rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    border: 1px solid #FDE68A;
    transition: all 0.3s;
}

.exam-timer.warning {
    background: #FEF2F2;
    color: #EF4444;
    border-color: #FECACA;
    animation: pulse-danger 1s infinite;
}

@keyframes pulse-danger {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.exam-workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.resource-panel {
    flex: 2;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: white;
}

.resource-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #FFFDF8;
}

.resource-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
}

.pdf-container {
    flex: 1;
    background: #EAE3DF;
}

.answer-panel {
    flex: 1;
    min-width: 350px;
    max-width: 450px;
    display: flex;
    flex-direction: column;
    background: var(--bg-main);
}

.exam-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: white;
}

.exam-tab {
    flex: 1;
    padding: 16px 0;
    text-align: center;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.exam-tab:hover {
    color: var(--primary);
    background: #FFFDF8;
}

.exam-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: #FFFDF8;
}

.answer-sheet {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* Bubble Sheet Grid */
.question-row {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
    background: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    border: 1px solid transparent;
    transition: var(--transition);
}

.question-row.active-q {
    border-color: var(--secondary);
    background: #FFF9E6;
}

.q-number {
    width: 30px;
    font-weight: 700;
    color: var(--text-primary);
}

.q-bubbles {
    display: flex;
    gap: 12px;
    flex: 1;
    justify-content: center;
}

.bubble-radio {
    display: none;
}

.bubble-label {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.2s;
    background: white;
}

.bubble-label:hover {
    border-color: var(--secondary);
    color: var(--secondary);
}

.bubble-radio:checked + .bubble-label {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: scale(1.1);
}

.bubble-radio:disabled + .bubble-label {
    cursor: not-allowed;
    opacity: 0.7;
}

/* Writing Area */
.writing-question {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.writing-header {
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 12px;
    font-size: 1.1rem;
}

.writing-textarea {
    width: 100%;
    height: 150px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    resize: vertical;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.6;
}

.writing-textarea:focus {
    outline: none;
    border-color: var(--secondary);
}

.writing-textarea:disabled {
    background-color: #F9F6F4;
    cursor: not-allowed;
}

/* Modal specific */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}
.modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}
.text-center { text-align: center; }

/* History Page Styles */
.question-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

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

.question-number {
    font-weight: 700;
    color: var(--secondary);
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.question-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.status-correct {
    background-color: #D1FAE5;
    color: #065F46;
}

.status-incorrect {
    background-color: #FEE2E2;
    color: #991B1B;
}

.question-text {
    font-size: 1.1rem;
    color: var(--text-primary);
    line-height: 1.6;
    margin-bottom: 20px;
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.option {
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    cursor: default;
    display: flex;
    align-items: center;
    transition: var(--transition);
    background-color: #FAFAFA;
}

.option-number {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: var(--border);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 16px;
    font-weight: 600;
}

.option.correct {
    background-color: #ECFDF5;
    border-color: #10B981;
}

.option.correct .option-number {
    background-color: #10B981;
    color: white;
}

.option.incorrect {
    background-color: #FEF2F2;
    border-color: #EF4444;
}

.option.incorrect .option-number {
    background-color: #EF4444;
    color: white;
}

/* AI Explanation Box */
.ai-explanation-box {
    margin-top: 24px;
    padding: 20px;
    background: linear-gradient(135deg, #FFFDF0 0%, #FFF8D6 100%);
    border: 1px solid var(--primary);
    border-radius: 12px;
    display: none; /* hidden by default */
    animation: fadeIn 0.5s ease;
}

.ai-explanation-box.visible {
    display: block;
}

.ai-header {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    color: var(--primary-dark);
    font-weight: 700;
    gap: 8px;
}

.ai-header i {
    color: var(--primary-dark);
}

.ai-content {
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* AI Loading Spinner */
.ai-loading {
    display: none;
    align-items: center;
    margin-top: 16px;
    color: var(--primary-dark);
    font-size: 0.9rem;
    font-weight: 600;
}

.ai-loading.visible {
    display: flex;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 209, 59, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-dark);
    animation: spin 1s ease-in-out infinite;
    margin-right: 10px;
}

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

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

/* Writing Page Styles */
.writing-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    position: relative;
}

@media (min-width: 1024px) {
    .writing-container {
        grid-template-columns: 1fr 1fr;
    }
}

.writing-input-section {
    display: flex;
    flex-direction: column;
}

.textarea-wrapper textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 209, 59, 0.2);
}

.error-highlight {
    background-color: #FEE2E2;
    color: #991B1B;
    border-bottom: 2px dashed #EF4444;
    cursor: help;
    padding: 0 4px;
    border-radius: 4px;
    position: relative;
    display: inline-block;
}

.error-highlight .error-tooltip {
    visibility: hidden;
    width: 200px;
    background-color: var(--secondary);
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 8px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.85rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.error-highlight .error-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: var(--secondary) transparent transparent transparent;
}

.error-highlight:hover .error-tooltip {
    visibility: visible;
    opacity: 1;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    z-index: 10;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    backdrop-filter: blur(4px);
}

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

.spinner-large {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 209, 59, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s ease-in-out infinite;
}

/* Admin Dashboard Styles */
.admin-mode {
    background-color: #f8fafc;
}

.admin-sidebar {
    background: linear-gradient(180deg, #3E2723 0%, #2D1E12 100%);
}

.admin-sidebar .logo-text {
    color: var(--primary);
}

.admin-sidebar .nav-links a {
    color: #E8D5B5;
}

.admin-sidebar .nav-links a:hover {
    background-color: rgba(255, 209, 59, 0.1);
    color: var(--primary);
}

.admin-sidebar .nav-links li.active a {
    background-color: var(--primary);
    color: var(--secondary);
}

.admin-sidebar .sidebar-footer a {
    color: #E8D5B5;
}

.admin-sidebar .sidebar-footer a:hover {
    background-color: rgba(255, 209, 59, 0.1);
    color: var(--primary);
}

.admin-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    transition: var(--transition);
    outline: none;
    resize: vertical;
}

.admin-input:focus {
    border-color: var(--primary-dark);
    box-shadow: 0 0 0 3px rgba(255, 209, 59, 0.2);
}

.admin-tabs {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border);
}

.tab-btn {
    background: none;
    border: none;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
    transition: var(--transition);
}

.tab-btn:hover {
    color: var(--secondary);
}

.tab-btn.active {
    color: var(--primary-dark);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: var(--primary);
    border-radius: 3px 3px 0 0;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

.file-upload-zone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    background-color: #FAFAFA;
    transition: var(--transition);
}

.file-upload-zone:hover {
    border-color: var(--primary);
    background-color: var(--bg-main);
}

.drag-drop-zone {
    border: 2px dashed var(--primary-dark);
    border-radius: 12px;
    padding: 40px;
    background-color: rgba(255, 209, 59, 0.05);
    max-width: 600px;
    margin: 0 auto;
    transition: var(--transition);
}

.drag-drop-zone:hover {
    background-color: rgba(255, 209, 59, 0.1);
}

.options-inputs {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.option-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.opt-label {
    font-weight: 700;
    color: var(--secondary);
}

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

.data-table th, .data-table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background-color: var(--bg-main);
    color: var(--secondary);
    font-weight: 600;
    white-space: nowrap;
}

.data-table tr:hover {
    background-color: #FAFAFA;
}

.table-responsive {
    overflow-x: auto;
}

.hidden {
    display: none !important;
}

.shared-context-box {
    background-color: #F8FAFC;
    padding: 16px;
    border-radius: 8px;
    border-left: 4px solid var(--primary);
    margin-bottom: 20px;
}

/* Exam Split Screen Styles */
.exam-mode {
    background-color: #F4F6F8;
    padding-bottom: 80px; /* Space for sticky footer */
    height: 100vh;
    overflow: hidden; /* Stop body scrolling, let columns scroll */
}

.exam-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background-color: var(--secondary);
    color: white;
    height: 60px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 50;
}

.exam-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.exam-logo .logo-text {
    color: var(--primary);
    font-weight: 800;
    font-size: 1.2rem;
}

.exam-title-badge h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
}

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

.btn-submit-exam {
    padding: 8px 16px;
    font-size: 0.9rem;
    background-color: #EF4444;
    color: white;
    border-radius: 6px;
}

.btn-submit-exam:hover {
    background-color: #DC2626;
}

/* Layout */
.exam-layout {
    display: grid;
    grid-template-columns: 2fr 1fr; /* 66% left, 33% right */
    gap: 24px;
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
    height: calc(100vh - 140px); /* 60px header + 80px footer */
}

/* Left Col: Questions */
.exam-questions-col {
    overflow-y: auto;
    padding-right: 12px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding-bottom: 40px;
}

/* Custom scrollbar for columns */
.exam-questions-col::-webkit-scrollbar,
.sheet-scroll-area::-webkit-scrollbar {
    width: 6px;
}
.exam-questions-col::-webkit-scrollbar-thumb,
.sheet-scroll-area::-webkit-scrollbar-thumb {
    background-color: rgba(0,0,0,0.2);
    border-radius: 4px;
}

.question-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    border-left: 4px solid var(--primary);
}

.question-number {
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--secondary);
    margin-bottom: 12px;
    display: inline-block;
}

.question-text {
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.mcq-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mcq-option-label {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.mcq-option-label:hover {
    background-color: #FAFAFA;
    border-color: var(--primary);
}

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

.mcq-circle {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-muted);
    transition: var(--transition);
}

.mcq-option-label input[type="radio"]:checked + .mcq-circle {
    background-color: var(--secondary);
    border-color: var(--secondary);
    color: white;
}

.mcq-option-label input[type="radio"]:checked ~ .mcq-text {
    font-weight: 600;
    color: var(--secondary);
}

/* Right Col: Answer Sheet */
.exam-answer-sheet-col {
    position: sticky;
    top: 0;
    height: 100%;
}

.answer-sheet-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    height: 100%;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
}

.sheet-title {
    padding: 16px;
    margin: 0;
    text-align: center;
    background-color: #F8FAFC;
    border-bottom: 1px solid var(--border);
    border-radius: 12px 12px 0 0;
    color: var(--secondary);
    font-size: 1.1rem;
}

.sheet-scroll-area {
    overflow-y: auto;
    padding: 16px;
    flex: 1;
}

.omr-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.omr-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.omr-q-num {
    font-weight: 700;
    width: 24px;
    text-align: right;
    color: var(--secondary);
}

.omr-options {
    display: flex;
    gap: 8px;
}

.omr-circle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    background-color: white;
}

.omr-circle:hover {
    border-color: var(--primary);
}

.omr-circle.selected {
    background-color: var(--secondary);
    border-color: var(--secondary);
    color: white;
}

/* Sticky Footer Audio Player */
.exam-audio-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 80px;
    background-color: white;
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 10px rgba(0,0,0,0.05);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.audio-player-container {
    width: 100%;
    max-width: 1200px;
    padding: 0 24px;
}

.audio-controls {
    display: flex;
    align-items: center;
    gap: 24px;
}

.play-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: var(--primary);
    color: var(--secondary);
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.play-btn:hover {
    background-color: var(--primary-dark);
    transform: scale(1.05);
}

.audio-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.audio-title {
    font-weight: 600;
    color: var(--secondary);
    font-size: 0.95rem;
}

.progress-bar-container {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.progress-bar-container input[type="range"],
.audio-volume input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    height: 6px;
    background: #E2E8F0;
    border-radius: 3px;
    outline: none;
}

.progress-bar-container input[type="range"]::-webkit-slider-thumb,
.audio-volume input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--secondary);
    cursor: pointer;
}

.audio-volume {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 150px;
    color: var(--text-muted);
}

/* Mobile Responsiveness */
@media (max-width: 900px) {
    .exam-layout {
        grid-template-columns: 1fr;
        height: auto;
        overflow-y: auto;
    }
    
    .exam-mode {
        overflow-y: auto; /* Let body scroll on mobile */
    }

    .exam-questions-col {
        overflow-y: visible;
        padding-right: 0;
        padding-bottom: 24px;
    }

    .exam-answer-sheet-col {
        position: relative;
        top: 0;
        height: auto;
        margin-bottom: 24px;
    }

    .sheet-scroll-area {
        max-height: 400px; /* Limit height on mobile so it doesn't take up whole page */
    }

    .omr-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}

@media (max-width: 600px) {
    .exam-header {
        flex-direction: column;
        height: auto;
        gap: 12px;
        padding: 16px;
    }

    .exam-layout {
        height: calc(100vh - 120px);
    }
}

/* --- AI PDF Import Styles --- */
.loading-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
}

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

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

/* Editable Table Inputs */
.editable-input, .editable-textarea {
    width: 100%;
    border: 1px solid transparent;
    background: transparent;
    padding: 6px;
    font-size: 0.9rem;
    color: var(--text-primary);
    border-radius: 4px;
    transition: var(--transition);
}

.editable-textarea {
    resize: vertical;
    min-height: 40px;
}

.editable-input:focus, .editable-textarea:focus {
    border-color: var(--primary);
    background: #fff;
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 209, 59, 0.2);
}

.editable-input.modified, .editable-textarea.modified {
    background-color: var(--bg-main);
    border-color: var(--primary-light);
}

td.td-options {
    min-width: 200px;
}
.opt-edit-row {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
    align-items: center;
}
.opt-edit-row span {
    font-weight: 600;
    color: var(--primary-dark);
}

/* Level Switcher (Toggle) */
.level-switcher {
    position: relative;
    display: inline-flex;
    background-color: var(--border);
    border-radius: 30px;
    padding: 4px;
    z-index: 1;
}

.level-switcher input[type="radio"] {
    display: none;
}

.level-switcher label {
    position: relative;
    z-index: 2;
    padding: 10px 24px;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.3s ease;
    border-radius: 26px;
    user-select: none;
    text-align: center;
}

.level-switcher input[type="radio"]:checked + label {
    color: var(--secondary);
}

.switcher-slider {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    width: calc(50% - 4px);
    background-color: white;
    border-radius: 26px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    z-index: 1;
}

/* Logic cho slider (khi chọn TOPIK II thì trượt sang phải) */
#topik2:checked ~ .switcher-slider {
    transform: translateX(100%);
}

@media (max-width: 600px) {
    .dashboard-header-flex {
        flex-direction: column;
        align-items: stretch !important;
    }
    
    .level-switcher {
        display: flex;
        width: 100%;
    }
    
    .level-switcher label {
        flex: 1;
        padding: 12px 0;
    }
}

/* Analytics Redesign Responsive */
@media (max-width: 800px) {
    .analytics-grid {
        grid-template-columns: 1fr !important;
    }
}
