/* =============================================================================
   APP SHELL CSS — TABLER UI SPLIT-SCREEN EDTECH WORKSPACE + ALPINE.JS STATES
   -----------------------------------------------------------------------------
   - Phục vụ RIÊNG khung điều khiển SaaS bên ngoài (Navbar, Sidebar 32%, Canvas 68%).
   - Bảo vệ tuyệt đối vùng tờ giấy `.sheet` khỏi CSS reset của Tabler/Bootstrap.
   ============================================================================= */

:root {
    --ed-ui-font: 'Plus Jakarta Sans', 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    --ed-sheet-font: 'Lexend', 'Be Vietnam Pro', 'Noto Sans SC', 'Noto Sans JP', 'Noto Sans KR', sans-serif;
    --ed-sidebar-w: 400px;
    --ed-navbar-h: 62px;
    --ed-canvas-bg: #e2e8f0;
}

[x-cloak] {
    display: none !important;
}

body.A4 {
    font-family: var(--ed-ui-font);
    background-color: var(--ed-canvas-bg) !important;
    color: #0f172a;
    margin: 0;
    padding: 0;
}

/* --- 1. TOP NAVBAR (TABLER LIGHT SAAS HEADER) --- */
.edtech-navbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    min-height: var(--ed-navbar-h);
    background: rgba(255, 255, 255, 0.96) !important;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #cbd5e1 !important;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
    padding: 6px 16px;
}

.edtech-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none !important;
    color: #0f172a !important;
    font-weight: 800;
    font-size: 1.08rem;
    letter-spacing: -0.01em;
}

.edtech-brand-badge {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #2563eb, #0284c7);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 3px 8px rgba(37, 99, 235, 0.28);
}

.edtech-navbar-tools {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.edtech-pill-box {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #1e293b;
}

.edtech-font-btn {
    border: none;
    background: transparent;
    color: #475569;
    font-weight: 800;
    font-size: 0.82rem;
    padding: 3px 9px;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.edtech-font-btn.is-on {
    background: #2563eb;
    color: #ffffff;
    box-shadow: 0 1px 4px rgba(37, 99, 235, 0.3);
}

.edtech-font-btn:disabled,
.ta-code-btn:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.ta-font-scale {
    min-width: 38px;
    color: #475569;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 800;
}

/* --- 2. SPLIT-SCREEN WORKSPACE (SIDEBAR TRÁI 32% + BÀN GIẤY A4 PHẢI 68%) --- */
.edtech-split-shell {
    display: grid;
    grid-template-columns: minmax(320px, var(--ed-sidebar-w)) minmax(0, 1fr);
    align-items: start;
    min-height: calc(100vh - var(--ed-navbar-h));
}
@media (min-width: 1280px) and (max-width: 1479px) {
    :root { --ed-sidebar-w: 340px; }
}

.edtech-sidebar {
    position: sticky;
    top: var(--ed-navbar-h);
    height: calc(100vh - var(--ed-navbar-h));
    overflow-y: auto;
    background: #f8fafc;
    border-right: 1px solid #cbd5e1;
    padding: 14px 14px 28px 14px;
    scrollbar-width: thin;
}

.edtech-sidebar .card {
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
    background: #ffffff;
    margin-bottom: 12px;
}

.edtech-sidebar .card-body {
    padding: 14px;
}

.edtech-step-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-weight: 800;
    font-size: 0.86rem;
    color: #0f172a;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* Form controls rõ nét, tương phản cao cho giáo viên lớn tuổi */
.edtech-sidebar .form-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.edtech-sidebar .form-select,
.edtech-sidebar .form-control {
    font-size: 1rem !important;
    font-weight: 700;
    color: #0f172a !important;
    background-color: #ffffff !important;
    border: 1.5px solid #94a3b8;
    border-radius: 9px;
    min-height: 46px;
    padding: 8px 34px 8px 12px;
}

.edtech-sidebar .form-select {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    line-height: 1.5;
    height: auto;
}

.edtech-sidebar .form-select::picker-icon {
    display: none;
}

.subject-pill-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.subject-pill-btn {
    border: 1.5px solid #cbd5e1; background: #ffffff; color: #1e293b;
    border-radius: 9px; padding: 6px 10px; font-size: 0.84rem; font-weight: 700;
    cursor: pointer; transition: all 0.15s ease; flex: 1 1 auto; text-align: center;
}
.subject-pill-btn:hover { border-color: #2563eb; background: #eff6ff; color: #1d4ed8; }
.subject-pill-btn.is-active { background: #2563eb; border-color: #2563eb; color: #ffffff; box-shadow: 0 2px 8px rgba(37, 99, 235, 0.28); }

.edtech-sidebar .form-select:focus,
.edtech-sidebar .form-control:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.edtech-sidebar .form-select.style-highlight {
    background-color: #eff6ff !important;
    border-color: #2563eb;
    color: #1e3a8a !important;
}

.edtech-code-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.edtech-print-grid {
    display: grid;
    grid-template-columns: auto 1fr 1.15fr;
    gap: 6px;
    margin-top: 8px;
}

/* --- 3. BÀN LÀM VIỆC PHẢI (LIVE PREVIEW CANVAS) --- */
.edtech-canvas-area {
    background: var(--ed-canvas-bg);
    min-height: calc(100vh - var(--ed-navbar-h));
    padding: 16px 12px 44px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
}

/* --- 4. LÁ CHẮN CÔ LẬP CSS BÊN TRONG TỜ GIẤY A4 (.sheet) ---
   Ngăn chặn Tabler/Bootstrap làm lệch bảng, danh sách, đoạn văn trong đề thi */
.sheet {
    font-family: var(--ed-sheet-font);
    color: #111827;
    line-height: 1.45;
}

.sheet p,
.sheet ul,
.sheet ol,
.sheet table,
.sheet h1,
.sheet h2,
.sheet h3,
.sheet h4 {
    margin-top: 0;
    margin-bottom: 0;
    color: inherit;
}

.sheet ul {
    padding-left: 18px;
}

/* Hiển thị nhãn đáp án trực tiếp trên đề (chỉ trên màn hình khi GV bật xem nhanh) */
body.show-inline-answers .sheet:not(#answer-key-sheet) [data-ans]::after {
    content: " ✓ " attr(data-ans);
    display: inline-block;
    margin-left: 6px;
    padding: 0 5px;
    border-radius: 4px;
    background: #dcfce7;
    border: 1px solid #86efac;
    color: #166534;
    font-size: 11px;
    font-weight: 800;
}

/* Đồng bộ nút Giọng đọc trong Sidebar sáng của Tabler */
.edtech-sidebar .vc-panel > summary {
    background: #f8fafc;
    color: #1e293b;
    border: 1.5px solid #cbd5e1;
    width: 100%;
    justify-content: center;
}

@media print {
    body.show-inline-answers .sheet:not(#answer-key-sheet) [data-ans]::after {
        display: none !important;
    }
}
