/* ============================================================
   AVA - Design System
   Modern, clean, responsive CSS for embed-friendly UI
   ============================================================ */

/* ---------- CSS Variables (Theme) ---------- */
:root {
    --primary: #0050B3;
    --primary-dark: #213B5C;
    --primary-light: #1877F2;
    --primary-bg: #F0F2F5;

    --success: #10b981;
    --success-bg: #d1fae5;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --info: #1877F2;
    --info-bg: #eef2ff;

    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    --bg: #FAFAFA;
    --surface: #FFFFFF;
    --text: #000000;
    --text-secondary: #4D4D4D;
    --border: #E4E6EB;
    --hover-bg: #F0F2F5;

    --sidebar-bg: #FFFFFF;
    --sidebar-text: #4D4D4D;
    --sidebar-hover: #F0F2F5;

    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-pill: 9999px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}

[data-theme="dark"] {
    --bg: #121212;
    --surface: #1E1E1E;
    --text: #F5F5F5;
    --text-secondary: #A6A6A6;
    --border: #333333;
    --hover-bg: #2D2D2D;

    --primary-light: #3B82F6;
    --primary-bg: #252525;

    --sidebar-bg: #1E1E1E;
    --sidebar-text: #F5F5F5;
    --sidebar-hover: #2D2D2D;

    --gray-50: #1E1E1E;
    --gray-100: #252525;
    --gray-200: #2D2D2D;
    --gray-300: #333333;
    --gray-800: #e2e8f0;
    --gray-900: #f8fafc;
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

img {
    max-width: 100%;
    height: auto;
}

/* ---------- Layout ---------- */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
    border-right: 1px solid var(--border);
}

.sidebar-header {
    padding: 1.25rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-logo {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    color: #fff;
}

.sidebar-brand {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.sidebar-brand small {
    display: block;
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--gray-400);
    letter-spacing: 0;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.nav-section {
    padding: 0.5rem 1.25rem 0.25rem;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gray-500);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.25rem;
    color: inherit;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all var(--transition);
    border-left: 3px solid transparent;
    opacity: 0.85;
}

.nav-link:hover {
    background: var(--sidebar-hover);
    color: var(--primary);
    opacity: 1;
}

.nav-link.active {
    background: var(--primary-bg);
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 600;
    opacity: 1;
}

.nav-link svg,
.nav-link .nav-icon {
    width: 18px;
    height: 18px;
    opacity: 0.7;
    flex-shrink: 0;
}

.nav-link.active svg,
.nav-link.active .nav-icon {
    opacity: 1;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    font-size: 0.82rem;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.sidebar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.7rem;
    color: var(--gray-400);
    text-transform: capitalize;
}

.main-content {
    flex: 1;
    margin-left: 250px;
    padding: 1.5rem 2rem;
    min-width: 0;
}

/* Mobile sidebar */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 200;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 1.2rem;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: flex;
    }

    .sidebar-overlay.show {
        display: block;
    }

    .main-content {
        margin-left: 0;
        padding: 3.5rem 1rem 1rem;
    }
}

/* ---------- Page Header ---------- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.02em;
}

.page-subtitle {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

.page-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    border-left: 4px solid var(--primary-light);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition);
}

.card:hover {
    transform: translateX(4px);
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
    background: var(--gray-50);
}

/* Stat cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    border-left: 4px solid var(--primary-light);
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
    transform: translateX(4px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-icon.primary {
    background: var(--primary-bg);
    color: var(--primary);
}

.stat-icon.success {
    background: var(--success-bg);
    color: var(--success);
}

.stat-icon.warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.stat-icon.danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.stat-icon.info {
    background: var(--info-bg);
    color: var(--info);
}

.stat-info h3 {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-info p {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1.25rem;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: var(--font);
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.4;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-light);
    color: #fff;
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-success:hover {
    background: #059669;
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #dc2626;
    color: #fff;
}

.btn-warning {
    background: var(--warning);
    color: #fff;
}

.btn-warning:hover {
    background: #d97706;
    color: #fff;
}

.btn-outline {
    background: transparent;
    color: var(--gray-700);
    border-color: var(--border);
}

.btn-outline:hover {
    background: var(--hover-bg);
    color: var(--text);
}

.btn-ghost {
    background: transparent;
    color: var(--gray-600);
    border: none;
    padding: 0.4rem 0.6rem;
}

.btn-ghost:hover {
    background: var(--hover-bg);
    color: var(--text);
    box-shadow: none;
    transform: none;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 0.7rem 1.5rem;
    font-size: 1rem;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    padding: 0.5rem;
}

.btn-group {
    display: flex;
    gap: 0.35rem;
}

/* ---------- Forms ---------- */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.3rem;
}

.form-label .required {
    color: var(--danger);
}

.form-control {
    width: 100%;
    padding: 0.55rem 0.85rem;
    font-size: 0.9rem;
    font-family: var(--font);
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.form-control.error {
    border-color: var(--danger);
}

.form-control::placeholder {
    color: var(--gray-400);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8.825L.35 3.175l.7-.7L6 7.425l4.95-4.95.7.7z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.25rem;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.form-hint {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.form-error {
    font-size: 0.78rem;
    color: var(--danger);
    margin-top: 0.25rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.88rem;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* ---------- Checkbox List Picker (multi-select replacement) ---------- */
.checkbox-list-picker {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
}

.checkbox-list-picker .clp-search {
    position: relative;
    border-bottom: 1px solid var(--border);
}

.checkbox-list-picker .clp-search input {
    width: 100%;
    padding: 0.55rem 0.85rem 0.55rem 2.2rem;
    font-size: 0.85rem;
    border: none;
    outline: none;
    background: var(--gray-50);
    font-family: var(--font);
    color: var(--text);
}

.checkbox-list-picker .clp-search input::placeholder {
    color: var(--gray-400);
}

.checkbox-list-picker .clp-search i {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    font-size: 0.9rem;
}

.checkbox-list-picker .clp-items {
    max-height: 200px;
    overflow-y: auto;
    padding: 0.25rem 0;
}

.checkbox-list-picker .clp-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.85rem;
    cursor: pointer;
    transition: background 0.15s ease;
    font-size: 0.85rem;
    user-select: none;
}

.checkbox-list-picker .clp-item:hover {
    background: var(--hover-bg);
}

.checkbox-list-picker .clp-item.selected {
    background: var(--primary-bg);
}

.checkbox-list-picker .clp-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}

.checkbox-list-picker .clp-item-label {
    flex: 1;
    min-width: 0;
}

.checkbox-list-picker .clp-item-name {
    font-weight: 500;
    color: var(--text);
}

.checkbox-list-picker .clp-item-detail {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.checkbox-list-picker .clp-empty {
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.84rem;
}

.checkbox-list-picker .clp-footer {
    padding: 0.4rem 0.85rem;
    border-top: 1px solid var(--border);
    background: var(--gray-50);
    font-size: 0.78rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.checkbox-list-picker .clp-count {
    background: var(--primary);
    color: #fff;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
}

/* ---------- Avatar Upload ---------- */
.avatar-upload-wrapper {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 1rem;
}

.avatar-preview {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-400);
    overflow: hidden;
    border: 3px solid var(--border);
    flex-shrink: 0;
}

.avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-upload-info {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.form-switch {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
}

/* ---------- Tables ---------- */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.table th,
.table td {
    padding: 0.7rem 0.85rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table th {
    font-weight: 600;
    color: var(--gray-600);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--gray-50);
    position: sticky;
    top: 0;
}

.table tbody tr:hover {
    background: var(--gray-50);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table .actions {
    white-space: nowrap;
    width: 1%;
}

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 999px;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.badge-primary {
    background: var(--primary-bg);
    color: var(--primary);
}

.badge-success {
    background: var(--success-bg);
    color: #065f46;
}

.badge-warning {
    background: var(--warning-bg);
    color: #92400e;
}

.badge-danger {
    background: var(--danger-bg);
    color: #991b1b;
}

.badge-info {
    background: var(--info-bg);
    color: #1e40af;
}

.badge-secondary {
    background: var(--gray-100);
    color: var(--gray-600);
}

/* ---------- Alerts / Flash Messages ---------- */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.88rem;
    margin-bottom: 1rem;
    border-left: 4px solid;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: slideDown 0.3s ease;
}

.alert-success {
    background: var(--success-bg);
    border-color: var(--success);
    color: #065f46;
}

.alert-error {
    background: var(--danger-bg);
    border-color: var(--danger);
    color: #991b1b;
}

.alert-warning {
    background: var(--warning-bg);
    border-color: var(--warning);
    color: #92400e;
}

.alert-info {
    background: var(--info-bg);
    border-color: var(--info);
    color: #1e40af;
}

@keyframes slideDown {
    from {
        transform: translateY(-10px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ---------- Tabs ---------- */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.25rem;
    gap: 0;
    overflow-x: auto;
}

.tab-link {
    padding: 0.65rem 1.1rem;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition);
    white-space: nowrap;
    cursor: pointer;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: var(--font);
}

.tab-link:hover {
    color: var(--text);
}

.tab-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ---------- Modal ---------- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 300;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 1.1rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gray-400);
    cursor: pointer;
    line-height: 1;
    padding: 0.25rem;
}

.modal-body {
    padding: 1.25rem;
}

.modal-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* ---------- Filter Bar ---------- */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-bar .form-group {
    margin-bottom: 0;
    min-width: 140px;
}

.filter-bar .form-control {
    font-size: 0.84rem;
    padding: 0.45rem 0.7rem;
}

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem 0;
    font-size: 0.88rem;
}

.pagination-info {
    color: var(--text-secondary);
    font-size: 0.82rem;
}

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 0.88rem;
    margin-bottom: 1rem;
}

/* ---------- Question Display ---------- */
.question-card {
    border: 1px solid var(--border);
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    border-left: 4px solid var(--primary-light);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    background: var(--surface);
    transition: transform var(--transition), box-shadow var(--transition);
}

.question-card:hover {
    transform: translateX(4px);
}

.question-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.question-number {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--primary);
}

.question-meta {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.question-statement {
    margin-bottom: 1rem;
    line-height: 1.7;
}

.question-statement img {
    max-width: 100%;
    border-radius: var(--radius);
    margin: 0.5rem 0;
}

/* Options */
.option-list {
    list-style: none;
}

.option-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all var(--transition);
}

.option-item:hover {
    border-color: var(--primary-light);
    background: var(--primary-bg);
}

.option-item.selected {
    border-color: var(--primary);
    background: var(--primary-bg);
}

.option-item.correct {
    border-color: var(--success);
    background: var(--success-bg);
}

.option-item.incorrect {
    border-color: var(--danger);
    background: var(--danger-bg);
}

.option-label {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.82rem;
    flex-shrink: 0;
    color: var(--gray-600);
}

.option-item.selected .option-label {
    background: var(--primary);
    color: #fff;
}

.option-content {
    flex: 1;
    padding-top: 0.2rem;
}

.option-content img {
    max-width: 100%;
    border-radius: var(--radius);
}

/* Essay textarea in execution */
.essay-area {
    width: 100%;
    min-height: 150px;
    padding: 0.75rem;
    font-family: var(--font);
    font-size: 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    resize: vertical;
    outline: none;
}

.essay-area:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

/* ---------- Progress / Timer ---------- */
.exam-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.75rem 1.25rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0.75rem;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.timer {
    font-size: 1.1rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--gray-700);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.timer.warning {
    color: var(--warning);
}

.timer.danger {
    color: var(--danger);
    animation: pulse 1s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.question-nav {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.question-nav-btn {
    width: 36px;
    height: 36px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    font-family: var(--font);
}

.question-nav-btn:hover {
    border-color: var(--primary);
}

.question-nav-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.question-nav-btn.answered {
    background: var(--primary-bg);
    border-color: var(--primary-light);
    color: var(--primary);
}

/* ---------- Login Page ---------- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 1rem;
}

.login-card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ---------- Rich Text Content ---------- */
.rich-content {
    line-height: 1.7;
}

.rich-content h1,
.rich-content h2,
.rich-content h3 {
    margin: 0.75rem 0 0.5rem;
}

.rich-content p {
    margin-bottom: 0.5rem;
}

.rich-content ul,
.rich-content ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.rich-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.5rem 0;
}

.rich-content table th,
.rich-content table td {
    border: 1px solid var(--border);
    padding: 0.5rem;
}

.rich-content img {
    max-width: 100%;
    border-radius: var(--radius);
    margin: 0.5rem 0;
}

.rich-content blockquote {
    border-left: 3px solid var(--primary);
    padding-left: 1rem;
    margin: 0.5rem 0;
    color: var(--text-secondary);
}

/* ---------- Drag & Drop ---------- */
.sortable-ghost {
    opacity: 0.4;
    background: var(--primary-bg) !important;
}

.sortable-drag {
    box-shadow: var(--shadow-lg) !important;
}

.drag-handle {
    cursor: grab;
    color: var(--gray-400);
    padding: 0.25rem;
}

.drag-handle:active {
    cursor: grabbing;
}

/* ---------- Utilities ---------- */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-small {
    font-size: 0.82rem;
}

.text-muted {
    color: var(--text-secondary);
}

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

.text-warning {
    color: var(--warning);
}

.text-primary {
    color: var(--primary);
}

.font-bold {
    font-weight: 700;
}

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mt-3 {
    margin-top: 1.5rem;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mb-3 {
    margin-bottom: 1.5rem;
}

.d-flex {
    display: flex;
}

.align-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-1 {
    gap: 0.5rem;
}

.gap-2 {
    gap: 1rem;
}

.flex-1 {
    flex: 1;
}

.hidden {
    display: none !important;
}

.w-full {
    width: 100%;
}

/* ---------- Confirmation Dialog ---------- */
.confirm-dialog .modal {
    max-width: 420px;
}

.confirm-dialog .modal-body {
    text-align: center;
    padding: 2rem 1.5rem;
}

.confirm-dialog .confirm-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* ---------- Custom Editor ---------- */
.ava-editor-container {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: visible;
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.ava-editor-container:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.ava-editor-compact .ava-editor-content {
    min-height: 60px;
    padding: 0.5rem 0.75rem;
    font-size: 0.88rem;
}

.ava-editor-compact .ava-editor-toolbar {
    padding: 0.25rem 0.4rem;
    gap: 0.15rem;
}

.ava-editor-compact .ava-editor-btn {
    padding: 0.15rem 0.35rem;
    font-size: 0.78rem;
}

.ava-editor-toolbar {
    background: var(--gray-50);
    border-bottom: 1px solid var(--border);
    padding: 0.4rem 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    align-items: center;
}

.ava-editor-btn {
    position: relative;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 0.3rem 0.45rem;
    cursor: pointer;
    font-size: 1rem;
    color: var(--gray-600);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    line-height: 1;
    min-width: 30px;
    min-height: 30px;
}

.ava-editor-btn:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

.ava-editor-btn.active {
    background: var(--primary-bg);
    color: var(--primary);
}

.ava-editor-separator {
    width: 1px;
    height: 1.25rem;
    background: var(--border);
    margin: 0 0.15rem;
    flex-shrink: 0;
}

.ava-editor-content {
    min-height: 200px;
    padding: 1rem;
    outline: none;
    line-height: 1.7;
    font-size: 0.92rem;
    color: var(--text);
}

.ava-editor-content img {
    max-width: 100%;
    border-radius: var(--radius);
    margin: 0.5rem 0;
    display: block;
}

.ava-editor-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.5rem 0;
}

.ava-editor-content table th,
.ava-editor-content table td {
    border: 1px solid var(--border);
    padding: 0.5rem;
    min-width: 40px;
}

.ava-editor-content table th {
    background: var(--gray-50);
    font-weight: 600;
}

.ava-editor-source {
    width: 100%;
    min-height: 200px;
    padding: 1rem;
    border: none;
    outline: none;
    font-family: 'Courier New', Consolas, monospace;
    font-size: 0.82rem;
    background: var(--gray-50);
    color: var(--gray-800);
    resize: vertical;
    line-height: 1.5;
}

/* Heading selector */
.ava-editor-heading-wrap {
    display: inline-flex;
    align-items: center;
}

.ava-editor-heading-select {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.2rem 0.4rem;
    font-size: 0.78rem;
    font-family: var(--font);
    color: var(--gray-700);
    cursor: pointer;
    outline: none;
    min-width: 100px;
    transition: border-color 0.15s ease;
}

.ava-editor-heading-select:hover {
    border-color: var(--gray-400);
}

.ava-editor-heading-select:focus {
    border-color: var(--primary);
}

/* ── Editor Dropdowns ── */
.ava-editor-dropdown {
    position: fixed;
    z-index: 1000;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 280px;
    max-height: 70vh;
    overflow-y: auto;
    padding: 0;
    animation: avaDropIn 0.15s ease;
}

@keyframes avaDropIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ava-dd-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.75rem 1rem 0.5rem;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}

.ava-dd-title i {
    font-size: 1rem;
    color: var(--primary);
}

.ava-dd-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-500);
    padding: 0.5rem 1rem 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.ava-dd-input {
    display: block;
    width: calc(100% - 2rem);
    margin: 0 1rem;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s ease;
}

.ava-dd-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

.ava-dd-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.4rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
}

.ava-dd-btn {
    padding: 0.35rem 0.8rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.15s ease;
}

.ava-dd-cancel {
    background: var(--gray-100);
    color: var(--gray-600);
}

.ava-dd-cancel:hover {
    background: var(--gray-200);
}

.ava-dd-confirm {
    background: var(--primary);
    color: #fff;
}

.ava-dd-confirm:hover {
    opacity: 0.9;
}

.ava-dd-confirm:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Tabs inside dropdown ── */
.ava-dd-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    padding: 0 1rem;
}

.ava-dd-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.45rem 0.8rem;
    font-size: 0.78rem;
    font-weight: 600;
    font-family: var(--font);
    color: var(--gray-500);
    cursor: pointer;
    margin-bottom: -1px;
    transition: all 0.15s ease;
}

.ava-dd-tab:hover {
    color: var(--text);
}

.ava-dd-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.ava-dd-tab-content {
    padding: 0.5rem 0;
}

/* ── Image dropzone ── */
.ava-dd-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 1.5rem 1rem;
    margin: 0.5rem 1rem;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--gray-500);
    transition: all 0.2s ease;
    text-align: center;
}

.ava-dd-dropzone i {
    font-size: 1.8rem;
    color: var(--gray-400);
    transition: color 0.2s ease;
}

.ava-dd-dropzone:hover,
.ava-dd-dropzone.dragover {
    border-color: var(--primary);
    background: var(--primary-bg);
    color: var(--primary);
}

.ava-dd-dropzone:hover i,
.ava-dd-dropzone.dragover i {
    color: var(--primary);
}

/* ── Progress bar ── */
.ava-dd-progress {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

.ava-dd-progress-bar {
    width: 100%;
    height: 6px;
    background: var(--gray-100);
    border-radius: 3px;
    overflow: hidden;
}

.ava-dd-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.2s ease;
}

.ava-dd-progress-text {
    font-size: 0.75rem;
    color: var(--gray-500);
    font-weight: 600;
}

/* ── Image preview ── */
.ava-dd-preview {
    padding: 0.5rem 1rem;
    text-align: center;
}

.ava-dd-preview img {
    max-width: 100%;
    max-height: 140px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    object-fit: contain;
}

/* ── Table picker grid ── */
.ava-dd-table-info {
    text-align: center;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--gray-600);
    padding: 0.4rem 0 0.2rem;
}

.ava-dd-table-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 3px;
    padding: 0.5rem 1rem;
}

.ava-dd-table-cell {
    width: 100%;
    aspect-ratio: 1;
    border: 1px solid var(--border);
    border-radius: 2px;
    background: var(--surface);
    cursor: pointer;
    transition: all 0.1s ease;
}

.ava-dd-table-cell:hover {
    border-color: var(--primary-light);
}

.ava-dd-table-cell.highlight {
    background: var(--primary-bg);
    border-color: var(--primary-light);
}

/* ── Image resize overlay ── */
.ava-editor-content {
    position: relative;
}

.ava-img-overlay {
    position: absolute;
    border: 2px solid var(--primary);
    pointer-events: none;
    z-index: 10;
    box-sizing: border-box;
}

.ava-img-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--primary);
    border: 2px solid #fff;
    border-radius: 2px;
    pointer-events: all;
    box-sizing: border-box;
}

.ava-img-handle-nw {
    top: -5px;
    left: -5px;
    cursor: nw-resize;
}

.ava-img-handle-n {
    top: -5px;
    left: calc(50% - 5px);
    cursor: n-resize;
}

.ava-img-handle-ne {
    top: -5px;
    right: -5px;
    cursor: ne-resize;
}

.ava-img-handle-w {
    top: calc(50% - 5px);
    left: -5px;
    cursor: w-resize;
}

.ava-img-handle-e {
    top: calc(50% - 5px);
    right: -5px;
    cursor: e-resize;
}

.ava-img-handle-sw {
    bottom: -5px;
    left: -5px;
    cursor: sw-resize;
}

.ava-img-handle-s {
    bottom: -5px;
    left: calc(50% - 5px);
    cursor: s-resize;
}

.ava-img-handle-se {
    bottom: -5px;
    right: -5px;
    cursor: se-resize;
}

.ava-img-align-bar {
    position: absolute;
    top: -36px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.15rem;
    padding: 0.2rem 0.4rem;
    pointer-events: all;
    white-space: nowrap;
}

.ava-img-align-bar button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.2rem 0.35rem;
    border-radius: var(--radius-sm);
    color: var(--gray-600);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    transition: all 0.1s ease;
}

.ava-img-align-bar button:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.ava-img-size-label {
    font-size: 0.68rem;
    color: var(--gray-400);
    padding: 0 0.3rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ---------- Print ---------- */
@media print {

    .sidebar,
    .sidebar-toggle,
    .exam-toolbar,
    .btn,
    .page-actions {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
        padding: 0;
    }

    .card {
        border: none;
        box-shadow: none;
    }
}