/* ============ TEACHER DASHBOARD REFINEMENTS ============ */

/* Action Bar Refinement */
.action-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
    align-items: center;
}

.action-bar .btn-primary,
.action-bar .btn-secondary,
.action-bar .btn-danger {
    padding: 8px 16px;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 38px;
}

.action-bar .btn-primary .material-icons-round,
.action-bar .btn-secondary .material-icons-round,
.action-bar .btn-danger .material-icons-round {
    font-size: 18px;
}

/* True/False UI */
.tf-item {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    background: #f8fafc;
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

.tf-item span:first-child {
    font-weight: 500;
    color: #64748b;
    min-width: 24px;
}

/* Short Answer 4-Box UI */
.sa-answer-grid {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.sa-box {
    width: 50px;
    height: 50px;
    text-align: center;
    font-size: 20px;
    font-weight: 600;
    border: 2px solid var(--border-light);
    border-radius: var(--radius-sm);
    text-transform: uppercase;
}

.sa-box:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(187, 38, 73, 0.1);
    background: #fff;
    outline: none;
    box-shadow: none;
}

/* WisGame Style Choice Buttons */
.wg-tf-btn-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1.5px solid #cbd5e1;
    font-size: 13px;
    font-weight: 700;
    color: #64748b;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
}

.wg-tf-btn-key:hover {
    border-color: #bb2649;
    background: #fff5f7;
    color: #bb2649;
}

.wg-tf-btn-key.selected {
    background: #bb2649;
    border-color: #bb2649;
    color: white;
    box-shadow: 0 4px 10px rgba(187, 38, 73, 0.2);
}

.wg-mcq-circle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1.5px solid #cbd5e1;
    background: white;
    font-size: 14px;
    font-weight: 700;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.wg-mcq-circle-btn:hover {
    border-color: #bb2649;
    color: #bb2649;
    background: #fff5f7;
}

.wg-mcq-circle-btn.selected {
    background: #bb2649;
    border-color: #bb2649;
    color: white;
    box-shadow: 0 4px 12px rgba(187, 38, 73, 0.25);
}

.wg-sa-input-key {
    width: 42px;
    height: 42px;
    text-align: center;
    border: 2px solid #cbd5e1;
    border-radius: 10px;
    font-size: 18px;
    font-weight: 800;
    outline: none;
    text-transform: uppercase;
    transition: all 0.2s;
    background: #f8fafc;
}

.wg-sa-input-key:focus {
    border-color: #bb2649;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(187, 38, 73, 0.1);
}

/* ============ ANSWER KEY V2 (2025 Structure) ============ */
.ak-main-container {
    margin: 20px 0;
    padding: 24px;
    background: #f8fafc;
    border: 2px dashed #e2e8f0;
    border-radius: 20px;
}

.ak-section {
    margin-bottom: 32px;
}

.ak-section:last-child {
    margin-bottom: 0;
}

.ak-section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-weight: 800;
    font-size: 15px;
    color: #bb2649;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-quick-input {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    text-transform: none;
    letter-spacing: normal;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-quick-input:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.btn-quick-input .material-icons-round {
    font-size: 16px;
}

.ak-grid {
    display: grid;
    gap: 16px;
}

/* Force 1-column for all parts as per user request */
.ak-grid.part1,
.ak-grid.part2,
.ak-grid.part3 {
    grid-template-columns: 1fr;
}

@media (max-width: 1024px) {

    .ak-grid.part1,
    .ak-grid.part2,
    .ak-grid.part3 {
        grid-template-columns: 1fr;
    }

    .ak-main-container {
        padding: 16px;
    }
}

.ak-card {
    background: white;
    border: 1.5px solid #e2e8f0;
    border-radius: 14px;
    padding: 14px 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
}

.ak-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.ak-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.ak-card-title {
    font-weight: 800;
    color: #1e293b;
    font-size: 14px;
}

/* Part 1 (MCQ) Buttons */
.ak-mcq-btns {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.ak-circle-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1.5px solid #cbd5e1;
    background: white;
    color: #64748b;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ak-circle-btn:hover {
    border-color: #bb2649;
    color: #bb2649;
    background: #fff5f7;
}

.ak-circle-btn.selected {
    background: #bb2649;
    border-color: #bb2649;
    color: white;
    box-shadow: 0 4px 10px rgba(187, 38, 73, 0.3);
}

/* Part 2 (True/False) Rows */
.ak-tf-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ak-tf-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #f1f5f9;
}

.ak-tf-row:last-child {
    border-bottom: none;
}

.ak-tf-label {
    font-weight: 600;
    color: #475569;
    font-size: 13px;
}

.ak-tf-btns {
    display: flex;
    gap: 8px;
}

.ak-rect-btn {
    width: 36px;
    height: 28px;
    border-radius: 6px;
    border: 1.5px solid #cbd5e1;
    background: white;
    color: #64748b;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ak-rect-btn:hover {
    border-color: #bb2649;
    color: #bb2649;
}

.ak-rect-btn.selected {
    background: #bb2649;
    border-color: #bb2649;
    color: white;
    box-shadow: 0 2px 6px rgba(187, 38, 73, 0.2);
}

/* Part 3 (Short Answer) Grid */
.ak-sa-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 4px;
}

.ak-sa-input {
    width: 100%;
    height: 44px;
    text-align: center;
    border: 2px solid #cbd5e1;
    border-radius: 10px;
    font-size: 18px;
    font-weight: 800;
    outline: none;
    text-transform: uppercase;
    transition: all 0.2s;
    background: #f8fafc;
}

.ak-sa-input:focus {
    border-color: #bb2649;
    background: white;
    box-shadow: 0 0 0 4px rgba(187, 38, 73, 0.1);
}

/* Teacher Table Styling */
.teacher-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 8px;
}

.teacher-table th {
    background: #f8fafc;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

.teacher-table td {
    padding: 16px;
    font-size: 14px;
    color: var(--text);
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.teacher-table tr:hover td {
    background: #fdf2f4;
}

.teacher-table tr:last-child td {
    border-bottom: none;
}

.teacher-table code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    background: #f1f5f9;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 13px;
    color: var(--primary);
}

/* =========================================================================
   Mobile Optimization for Action Buttons & Search (Added via Antigravity)
   ========================================================================= */
@media (max-width: 1024px) {

    /* Global scroll prevention */
    html,
    body {
        max-width: 100vw;
        overflow-x: hidden;
        position: relative;
    }

    /* Fix card padding and sizing for small screens */
    .ui-card {
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Sidebar/Navigation might cause overflow if not handled */
    #sidebar {
        z-index: 1000;
    }

    /* Hide text inside buttons */
    .btn-text-mobile {
        display: none !important;
    }

    /* Make buttons icon-only squares */
    .btn-mobile-icon-only {
        width: 42px !important;
        height: 42px !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex-shrink: 0 !important;
    }

    /* Fix the specific icon margin if they had default margin-right */
    .btn-mobile-icon-only .material-icons-round {
        margin-right: 0 !important;
    }

    /* Collapsible Search Bar - Expanding FULL WIDTH (Takeover) */
    .search-container-mobile {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        width: 42px;
        height: 42px;
        transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow: hidden;
        border-radius: 12px;
        margin-left: auto;
        border: 1px solid #e2e8f0;
        background: #f8fafc;
        cursor: pointer;
        z-index: 10;
    }

    /* Hide other buttons when search is active */
    .toolbar-container-mobile:focus-within .hide-on-search-mobile {
        display: none !important;
    }

    .search-container-mobile:focus-within,
    .search-container-mobile input:not(:placeholder-shown) {
        width: 100% !important;
        /* Full width takeover */
        background: white;
        cursor: default;
        position: relative;
        margin-left: 0;
    }

    .toolbar-search-input {
        width: 100% !important;
        height: 100% !important;
        padding: 8px 12px 8px 40px !important;
        opacity: 0;
        cursor: pointer;
        transition: opacity 0.3s;
        background: transparent;
        position: absolute;
        right: 0;
        border: none !important;
        outline: none !important;
    }

    .search-container-mobile:focus-within .toolbar-search-input,
    .search-container-mobile input:not(:placeholder-shown) {
        opacity: 1;
        cursor: text;
        position: relative;
    }

    .search-icon-mobile {
        position: absolute;
        left: 11px;
        top: 50%;
        transform: translateY(-50%);
        color: #64748b;
        font-size: 20px;
        pointer-events: none;
        z-index: 15;
    }

    /* Fix alignment for Dashboard Settings on Home Page (iPhone X specific) */
    .dashboard-settings-form>div {
        grid-template-columns: 1fr !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
    }

    /* =========================================================================
       QUESTION BANK (Theory & Exercise) MOBILE & IPAD ADJUSTMENTS (<= 1024px)
       ========================================================================= */

    /* Align checkbox horizontally with Title and pin to far right.
       CHỈ áp dụng cho thẻ câu hỏi CÓ ô tick (giao diện giáo viên).
       Trước đây rule này áp cho mọi thẻ nên ở giao diện học sinh (không có ô
       tick) phần ĐỀ BÀI bị đẩy sang cột thứ 2, nằm ngang hàng "Câu N:" và bị
       bóp hẹp. Sửa 2026-07-28. */
    .question-card-v2 .q-header-v2:has(> .q-checkbox-v2) {
        display: grid !important;
        grid-template-columns: 1fr auto !important;
        gap: 10px !important;
        align-items: start !important;
    }

    /* Target the main content div which is the first child or contains text */
    .question-card-v2 .q-header-v2:has(> .q-checkbox-v2)>div:first-child {
        grid-column: 1 !important;
        grid-row: 1 !important;
        padding-right: 0 !important;
        width: 100% !important;
    }

    /* Target the checkbox which is a child of the header */
    .question-card-v2 .q-checkbox-v2 {
        grid-column: 2 !important;
        grid-row: 1 !important;
        margin: 0 !important;
        margin-top: 5px !important;
        z-index: 2;
    }

    /* Handle images that are direct children or nested */
    .question-card-v2 .q-image-v2 {
        grid-column: 1 / span 2 !important;
        grid-row: 2 !important;
        width: 100% !important;
        max-width: 280px !important;
        margin-top: 15px !important;
        text-align: left !important;
    }

    /* Support nested image containers in Exercise Bank */
    .question-card-v2 .q-header-v2>div:first-child .q-image-v2 {
        display: block !important;
        margin-top: 15px !important;
    }

    .question-card-v2 .q-image-v2 img {
        width: 100% !important;
        height: auto !important;
    }

    /* Bulk Actions Row - Button on new line aligned to right */
    #bulk-actions-row,
    #theory-bulk-actions-row {
        flex-direction: column !important;
        align-items: flex-end !important;
        gap: 15px !important;
        padding: 16px !important;
    }

    #bulk-actions-row>div:first-child,
    #theory-bulk-actions-row>div:first-child {
        width: 100%;
        text-align: left;
    }

    #bulk-delete-btn,
    #theory-bulk-delete-btn {
        width: auto !important;
        margin-top: 5px;
    }

    /* Compact Upload & Icon Buttons (Global) */
    .upload-icon-btn {
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .upload-icon-btn:hover {
        transform: translateY(-2px);
        filter: brightness(0.95);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }

    .ui-icon-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
        filter: brightness(0.95);
    }

    /* Responsive Answer Key Grid */
    .answer-key-grid {
        display: grid;
        gap: 12px;
    }

    .answer-key-grid.part1 {
        grid-template-columns: repeat(3, 1fr);
    }

    .answer-key-grid.part2 {
        grid-template-columns: repeat(2, 1fr);
    }

    .answer-key-grid.part3 {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Mobile specific grid adjustments for Answer Key */
@media (max-width: 1024px) {
    .answer-key-grid.part1 {
        grid-template-columns: repeat(2, 1fr);
    }

    .answer-key-grid.part3 {
        grid-template-columns: repeat(2, 1fr);
    }

    .answer-key-main-container {
        padding: 16px !important;
    }
}

@media (max-width: 640px) {
    .answer-key-grid.part1 {
        grid-template-columns: 1fr;
    }

    .answer-key-grid.part2 {
        grid-template-columns: 1fr;
    }

    .answer-key-grid.part3 {
        grid-template-columns: 1fr;
    }

    .answer-key-main-container {
        padding: 12px !important;
        margin: 15px 0 !important;
    }
}

/* =========================================================================
   WEBSITE (DESKTOP) TOOLBAR UI REFINEMENTS (> 1024px)
   ========================================================================= */
@media (min-width: 1025px) {

    /* Align all toolbar elements horizontally */
    .toolbar-container-mobile {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        flex-wrap: nowrap !important;
        gap: 15px !important;
    }

    .toolbar-container-mobile>div {
        display: flex !important;
        align-items: center !important;
        gap: 12px !important;
    }

    /* Move search icon inside input on desktop */
    .search-container-mobile {
        display: flex !important;
        position: relative !important;
        width: 300px !important;
        /* Fixed width for desktop search */
        height: 42px !important;
        background: white !important;
        border-radius: 12px !important;
        overflow: visible !important;
        margin-left: 0 !important;
        opacity: 1 !important;
    }

    .search-icon-mobile {
        position: absolute !important;
        left: 12px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        z-index: 5 !important;
        pointer-events: none !important;
        opacity: 1 !important;
        display: block !important;
    }

    .toolbar-search-input {
        width: 100% !important;
        height: 100% !important;
        padding: 8px 12px 8px 42px !important;
        /* Extra padding-left for icon */
        opacity: 1 !important;
        position: relative !important;
        background: transparent !important;
        border: 1px solid #e2e8f0 !important;
        border-radius: 12px !important;
        cursor: text !important;
    }

    .toolbar-search-input:focus {
        border-color: var(--primary) !important;
        box-shadow: 0 0 0 3px rgba(187, 38, 73, 0.1) !important;
    }

    /* Ensure NB-VDC and other right-side elements align */
    .toolbar-container-mobile>div:last-child {
        margin-left: auto !important;
        gap: 12px !important;
    }
}

/* Specific grid for Exam List to handle iPad (2 columns) and Website (3 columns) */
.exam-list-grid {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)) !important;
    display: grid !important;
    gap: 20px !important;
}

@media (max-width: 1024px) {
    .exam-list-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 640px) {
    .exam-list-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Status Badge */
.status-badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
}

.status-badge.active {
    background: #dcfce7;
    color: #166534;
}

.status-badge.locked {
    background: #fee2e2;
    color: #991b1b;
}

/* ============ PROFESSIONAL UI REFINEMENTS ============ */

/* Modern Button Variations */
.btn-danger {
    background: #fef2f2;
    color: #ef4444;
    border: 1.5px solid #fecaca;
    padding: 8px 16px;
    border-radius: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-danger:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.1);
}

.btn-sm {
    padding: 6px 12px !important;
    font-size: 13px !important;
    min-height: 32px !important;
    border-radius: 8px !important;
}

/* Professional Close Button (X) */
.btn-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    background: #f1f5f9;
    color: #64748b;
    border: none;
    outline: none;
}

.btn-close:hover {
    background: #e2e8f0;
    color: #1e293b;
    transform: rotate(90deg);
}

/* Custom File Upload Area (Dashed Box) */
.custom-file-upload {
    border: 2px dashed #cbd5e1;
    border-radius: 16px;
    padding: 30px 20px;
    text-align: center;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    position: relative;
}

.custom-file-upload:hover {
    border-color: #bb2649;
    background: #fff5f7;
    box-shadow: 0 4px 20px rgba(187, 38, 73, 0.05);
}

.custom-file-upload .material-icons-round {
    font-size: 40px;
    color: #94a3b8;
    transition: color 0.2s;
}

.custom-file-upload:hover .material-icons-round {
    color: #bb2649;
}

.custom-file-upload span.file-name {
    font-size: 14px;
    font-weight: 600;
    color: #475569;
}

.custom-file-upload span.file-hint {
    font-size: 12px;
    color: #94a3b8;
}

.custom-file-upload input[type="file"] {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
}

.ls-form-group label {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 10px;
    display: block;
    color: var(--text);
}

.ls-form-input {
    font-size: 16px;
    padding: 14px 18px;
    border-radius: 10px;
    border: 2px solid var(--border-light);
    transition: all 0.2s;
    width: 100%;
    color: var(--text);
    background: #fdfdfd;
}

.ls-form-input:focus {
    border-color: #bb2649;
    box-shadow: 0 0 0 4px rgba(187, 38, 73, 0.1);
    background: #fff;
    outline: none;
}

.ls-form-row {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.ls-btn-submit {
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 600;
    background: #bb2649;
    border-color: #bb2649;
    color: white;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.ls-btn-submit:hover {
    background: #a01e3b;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(187, 38, 73, 0.2);
}

::placeholder {
    color: #aaa;
    opacity: 1;
}

/* New Question Item Designs (v2) */
.question-card-v2 {
    border: 1px solid #eceff3;
    border-radius: 16px;
    padding: 24px;
    background: #fff;
    margin-bottom: 16px;
    position: relative;
    transition: box-shadow 0.25s, transform 0.25s;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.07), 0 1px 3px rgba(15, 23, 42, 0.05);
}

.question-card-v2:hover {
    box-shadow: 0 14px 34px rgba(187, 38, 73, 0.12), 0 4px 12px rgba(15, 23, 42, 0.07);
    transform: translateY(-3px);
    border-color: #f6d0da;
}

.question-card-v2 .q-header-v2 {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.question-card-v2 .q-title-row-v2 {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.6;
    flex: 1;
}

.question-card-v2 .q-id-v2 {
    color: #bb2649;
    white-space: nowrap;
    text-decoration: underline;
    text-underline-offset: 4px;
    font-weight: 800;
}

.question-card-v2 .q-difficulty-container {
    position: relative;
    display: inline-flex;
    margin: 0 8px;
}

.question-card-v2 .q-difficulty-v2,
.theory-q-card .q-difficulty-v2 {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
    background: #f1f5f9;
    color: #64748b;
    transition: all 0.2s;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.q-difficulty-v2.nb {
    background: #dcfce7 !important;
    color: #15803d !important;
    border-color: #bbf7d0 !important;
}

.q-difficulty-v2.th {
    background: #e0f2fe !important;
    color: #0369a1 !important;
    border-color: #bae6fd !important;
}

.q-difficulty-v2.vd {
    background: #fef3c7 !important;
    color: #b45309 !important;
    border-color: #fde68a !important;
}

.q-difficulty-v2.vdc {
    background: #fee2e2 !important;
    color: #b91c1c !important;
    border-color: #fecaca !important;
}

.question-card-v2 .difficulty-menu {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    z-index: 100;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    display: none;
    min-width: 220px;
    overflow: visible;
    padding: 6px;
    gap: 6px;
}

/* Cầu nối để không bị mất hover khi di chuyển chuột */
.question-card-v2 .difficulty-menu::before {
    content: '';
    position: absolute;
    top: -15px;
    left: 0;
    right: 0;
    height: 20px;
    background: transparent;
}

.question-card-v2 .q-difficulty-container:hover .difficulty-menu {
    display: flex;
}

.question-card-v2 .difficulty-option {
    flex: 1;
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    border-radius: 8px;
}

.question-card-v2 .difficulty-option.opt-nb {
    background: #dcfce7;
    color: #15803d;
}

.question-card-v2 .difficulty-option.opt-th {
    background: #e0f2fe;
    color: #0369a1;
}

.question-card-v2 .difficulty-option.opt-vd {
    background: #fef3c7;
    color: #b45309;
}

.question-card-v2 .difficulty-option.opt-vdc {
    background: #fee2e2;
    color: #b91c1c;
}

.question-card-v2 .difficulty-option:hover {
    filter: brightness(0.95);
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.question-card-v2 .q-content-v2 {
    color: #1e293b;
    font-weight: 400;
}

.question-card-v2 .q-checkbox-v2 {
    margin-left: 20px;
    transform: scale(1.3);
    cursor: pointer;
    accent-color: #bb2649;
}

.question-card-v2 .q-main-v2 {
    display: flex;
    gap: 24px;
    margin-bottom: 12px;
}

.question-card-v2 .q-options-v2 {
    flex: 1;
}

.question-card-v2 .q-image-v2 {
    width: 200px;
    flex-shrink: 0;
    text-align: right;
}

.question-card-v2 .q-image-v2 img {
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid #f1f5f9;
}

.question-card-v2 .options-table-v2 {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #e2e8f0;
}

.question-card-v2 .options-table-v2 td {
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    font-size: 15px;
    vertical-align: middle;
}

.question-card-v2 .option-label-v2 {
    color: #bb2649;
    font-weight: 700;
    margin-right: 8px;
}

.question-card-v2 .q-answer-v2 {
    margin: 12px 0;
    font-size: 16px;
    color: #1e293b;
    font-weight: 600;
}

.question-card-v2 .q-answer-v2 .label {
    color: #bb2649;
    margin-right: 8px;
}

.question-card-v2 .q-actions-v2 {
    display: flex;
    gap: 8px;
}

.question-card-v2 .btn-action-v2 {
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: 0.2s;
}

.question-card-v2 .btn-edit-v2 {
    background: #f1f5f9;
    color: #475569;
}

.question-card-v2 .btn-edit-v2:hover {
    background: #e2e8f0;
}

.question-card-v2 .btn-delete-v2 {
    background: #fff1f2;
    color: #e11d48;
}

.question-card-v2 .btn-delete-v2:hover {
    background: #ffe4e6;
}

/* TF specific table */
.tf-table-v2 td.tf-btn-cell {
    width: 80px;
    text-align: center;
    padding: 8px;
}

.tf-btn-v2 {
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    background: #fff;
    font-weight: 600;
    font-size: 13px;
    width: 60px;
    display: inline-block;
}

.tf-btn-v2.active {
    border-color: #bb2649;
    color: #bb2649;
    background: #fff1f2;
}

/* Short answer specific */
.sa-answer-grid-v2 {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.sa-box-v2 {
    width: 40px;
    height: 40px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    background: #fff;

}

/* Teacher View Container & Spacing */
.teacher-view-container {
    padding: 24px 30px 40px !important;
}

.teacher-view-container .card {
    padding: 20px;
    border-radius: 14px;
    margin-bottom: 20px;
}

.teacher-view-container .form-group {
    margin-bottom: 16px;
}

.teacher-view-container label {
    font-size: 14px !important;
    margin-bottom: 6px !important;
}


/* Global Teacher Form Elements */
.input-field,
select,
textarea,
input[type="text"],
input[type="date"],
input[type="time"],
input[type="number"],
input[type="file"] {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px !important;
    border-radius: 8px !important;
    box-sizing: border-box !important;
}

.teacher-view-container h3 {
    font-size: 16px !important;
}

.teacher-view-container .btn-primary {
    padding: 10px 20px !important;
    font-size: 14px !important;
    border-radius: 8px !important;
}

.teacher-view-container .stat-card {
    padding: 16px;
    text-align: left;
}

.teacher-view-container .stat-card span {
    font-size: 28px;
    margin-bottom: 8px;
    color: var(--primary);
}

.teacher-view-container .stat-card h3 {
    margin: 4px 0 2px;
    font-size: 15px !important;
}

.teacher-view-container .stat-card p {
    font-size: 12px;
    margin: 0;
}

/* Student Interactive UI Styles (v2) */
.options-table-v2 .interactive:hover {
    background: #fdf2f4;
    cursor: pointer;
}

.options-table-v2 .interactive.selected {
    background: #fff1f2;
    border: 1.5px solid #bb2649 !important;
}

.options-table-v2 tr.correct-v2 td,
.options-table-v2 .option-item.correct-v2 {
    background: #ecfdf5 !important;
    border-color: #10b981 !important;
    color: #065f46 !important;
}

.options-table-v2 tr.correct-v2 .option-label-v2,
.options-table-v2 .option-item.correct-v2 .option-label-v2 {
    color: #059669 !important;
}

.options-table-v2 tr.incorrect-v2 td,
.options-table-v2 .option-item.incorrect-v2 {
    background: #fef2f2 !important;
    border-color: #ef4444 !important;
    color: #991b1b !important;
}

.options-table-v2 tr.incorrect-v2 .option-label-v2,
.options-table-v2 .option-item.incorrect-v2 .option-label-v2 {
    color: #dc2626 !important;
}

.tf-btn-v2.active {
    background: #bb2649 !important;
    color: white !important;
    border-color: #bb2649 !important;
}

.tf-btn-v2.correct-v2 {
    background: #10b981 !important;
    color: white !important;
    border-color: #059669 !important;
}

.tf-btn-v2.incorrect-v2 {
    background: #ef4444 !important;
    color: white !important;
    border-color: #b91c1c !important;
}

.sa-box-v2.correct-v2 {
    border-color: #10b981 !important;
    background: #ecfdf5 !important;
    color: #065f46 !important;
}

.sa-box-v2.incorrect-v2 {
    border-color: #ef4444 !important;
    background: #fef2f2 !important;
    color: #991b1b !important;
}

.selectable {
    cursor: pointer;
    transition: all 0.2s;
}

.selectable:hover {
    filter: brightness(0.95);
    background: #f8fafc;
}


.tf-btn-v2.correct {
    background: #10b981 !important;
    color: white !important;
    border-color: #059669 !important;
}

.tf-btn-v2.incorrect {
    background: #ef4444 !important;
    color: white !important;
    border-color: #b91c1c !important;
}

.sa-box-v2.correct {
    border-color: #10b981 !important;
    background: #ecfdf5 !important;
    color: #065f46 !important;
}

.sa-box-v2.incorrect {
    border-color: #ef4444 !important;
    background: #fef2f2 !important;
    color: #991b1b !important;
}

.selectable {
    cursor: pointer;
    transition: all 0.2s;
}

.selectable:hover {
    filter: brightness(0.95);
    background: #f8fafc;
}

/* === Responsive adjustments for QBank === */
@media (max-width: 1024px) {
    .question-card-v2 .q-main-v2 {
        flex-direction: column;
        gap: 16px;
    }

    .question-card-v2 .q-image-v2 {
        width: 100%;
        text-align: center;
    }

    .question-card-v2 .q-image-v2 img {
        max-width: 100%;
        height: auto;
    }

    /* Ensure action buttons wrap if needed */
    .question-card-v2 .q-actions-v2 {
        flex-wrap: wrap;
    }

    /* Wrap header infos */
    .question-card-v2>div[style*="justify-content:space-between"] {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px;
    }

    /* Prevent tables from breaking mobile viewport */
    .teacher-table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* === Student Accounts Dual-View Logic === */
    .hidden-mobile {
        display: none !important;
    }

    .hidden-desktop {
        display: block !important;
    }

    /* Convert student table to cards */
    table.student-table {
        border: none !important;
        background: transparent !important;
        padding: 0 !important;
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    table.student-table tbody,
    table.student-table tr {
        display: flex;
        flex-direction: column;
        width: 100%;
    }

    table.student-table tbody {
        gap: 16px;
    }

    table.student-table tr.student-row {
        background: white;
        border-radius: 16px;
        border: 1px solid #e2e8f0;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
        margin-bottom: 0;
        overflow: hidden;
    }

    table.student-table td {
        display: block;
        width: 100%;
        border: none !important;
        padding: 0 !important;
    }
}

/* Base styles for Dual View (showing desktop by default) */
@media (min-width: 1025px) {
    .hidden-desktop {
        display: none !important;
    }
}

/* Base styles for Notification Recipient Buttons (Desktop/iPad) */
.recipient-toggle-container {
    display: flex;
    position: relative;
    background: #f1f5f9;
    border-radius: 12px;
    padding: 4px;
    gap: 8px;
    margin-bottom: 0px;
}

.recipient-toggle-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    cursor: pointer;
    font-weight: 600;
    z-index: 2;
    transition: all 0.3s;
    border-radius: 8px;
    color: #64748b;
}

.recipient-toggle-btn.active {
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    color: var(--primary) !important;
}

.recipient-toggle-btn .material-icons-round {
    font-size: 18px;
}

/* PHONE ONLY: Compact layout for narrow screens */
@media (max-width: 600px) {
    .recipient-toggle-container {
        gap: 4px;
        padding: 4px;
    }

    .recipient-toggle-btn {
        padding: 10px 4px !important;
        gap: 4px !important;
        font-size: 12.5px !important;
    }

    .recipient-toggle-btn .material-icons-round {
        font-size: 17px !important;
    }
}

/* Virtual Lab Alignment Refinement */
.white-toolbar .toolbar-container {
    max-width: 1200px !important;
    margin: 0 auto !important;
    padding: 0 30px !important;
}

@media (max-width: 768px) {
    .white-toolbar .toolbar-container {
        padding: 0 15px !important;
    }
}

.content-page.animate-fade-in {
    max-width: 1200px;
    margin: 0 auto;
}

/* Mobile: align exam history score and icon button side-by-side */
@media (max-width: 1024px) {
    .history-card-right {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 10px !important;
        text-align: left !important;
    }

    .history-card-right .history-score {
        margin-bottom: 0 !important;
        white-space: nowrap;
    }
}

/* =========================================================================
   PHONE-ONLY REDESIGN: WRONG QUESTION STATISTICS (Antigravity)
   Targeting < 768px (Phones). iPad is typically >= 768px.
   ========================================================================= */
@media (max-width: 767px) {

    /* Exam List Card: Fullsize, no red border */
    .exam-card-phone {
        width: 100% !important;
        margin-bottom: 12px !important;
        border-left: none !important;
        border-radius: 16px !important;
        padding: 24px !important;
        background: #fff !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04) !important;
        cursor: pointer;
        display: block !important;
    }

    .exam-card-phone:active {
        background: #f8fafc !important;
        transform: scale(0.98);
    }

    .exam-card-phone h3 {
        margin: 0 !important;
        color: var(--primary) !important;
        font-size: 18px !important;
        font-weight: 700 !important;
        line-height: 1.4 !important;
    }

    .exam-card-phone .exam-meta {
        margin-top: 8px !important;
        font-size: 13px !important;
        color: #64748b !important;
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
    }

    /* Fullscreen Mobile View */
    .mobile-stats-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: #fff;
        z-index: 10000;
        display: flex;
        flex-direction: column;
        animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    @keyframes slideUp {
        from {
            transform: translateY(100%);
        }

        to {
            transform: translateY(0);
        }
    }

    .mobile-stats-header {
        background: #bb2649;
        color: #fff;
        padding: 16px 20px;
        position: relative;
        flex-shrink: 0;
        padding-top: calc(16px + env(safe-area-inset-top, 0px));
        box-shadow: 0 2px 10px rgba(187, 38, 73, 0.2);
    }

    .mobile-stats-header .title {
        font-size: 17px;
        font-weight: 800;
        margin-bottom: 4px;
        padding-right: 40px;
        line-height: 1.3;
    }

    .mobile-stats-header .sub {
        font-size: 13px;
        opacity: 0.9;
        display: flex;
        align-items: center;
        gap: 6px;
    }

    .mobile-stats-header .close-btn {
        position: absolute;
        top: calc(12px + env(safe-area-inset-top, 0px));
        right: 16px;
        color: #fff;
        font-size: 28px;
        background: none;
        border: none;
        padding: 4px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-stats-body {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    /* PDF Section - Zoomable */
    .mobile-pdf-container {
        height: 45vh;
        background: #525659;
        position: relative;
        overflow: hidden;
        border-bottom: 2px solid #e2e8f0;
    }

    .mobile-pdf-container iframe {
        width: 100%;
        height: 100%;
        border: none;
    }

    /* Stats Section */
    .mobile-stats-list {
        flex: 1;
        overflow-y: auto;
        padding: 20px;
        background: #fff;
        padding-bottom: env(safe-area-inset-bottom, 20px);
    }

    .mobile-stat-item {
        margin-bottom: 12px;
        padding: 14px;
        background: #f8fafc;
        border-radius: 12px;
        border: 1px solid #e2e8f0;
    }

    .mobile-stat-item .q-label {
        font-weight: 700;
        font-size: 14px;
        color: #1e293b;
        margin-bottom: 6px;
    }

    .mobile-stat-item .q-percent {
        color: #ef4444;
        font-size: 12px;
        font-weight: 700;
        margin-bottom: 8px;
        display: block;
    }

    .mobile-stat-item .progress-bg {
        width: 100%;
        height: 6px;
        background: #e2e8f0;
        border-radius: 3px;
        overflow: hidden;
    }

    .mobile-stat-item .progress-fill {
        height: 100%;
        background: #ef4444;
        transition: width 0.5s ease-out;
    }

    .section-label-mobile {
        font-weight: 800;
        color: var(--primary);
        font-size: 15px;
        margin: 20px 0 10px;
        padding-bottom: 4px;
        border-bottom: 1.5px solid #f1f5f9;
        display: block;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .section-label-mobile:first-child {
        margin-top: 0;
    }

    /* Average Score Box in Header */
    .avg-score-box-mobile {
        position: absolute;
        right: 56px;
        /* Space for close button */
        top: calc(12px + env(safe-area-inset-top, 0px));
        background: rgba(255, 255, 255, 0.15);
        border: 1px solid rgba(255, 255, 255, 0.3);
        border-radius: 12px;
        padding: 4px 12px;
        text-align: center;
        min-width: 60px;
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }

    .avg-score-box-mobile .label {
        font-size: 10px;
        text-transform: uppercase;
        font-weight: 700;
        opacity: 0.8;
        display: block;
        margin-bottom: -2px;
    }

    .avg-score-box-mobile .value {
        font-size: 18px;
        font-weight: 900;
        color: #fff;
    }

    /* Mobile Student Scores Modal */
    .mobile-score-modal {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 10100;
        display: flex;
        align-items: flex-end;
        animation: fadeIn 0.2s ease-out;
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
        }

        to {
            opacity: 1;
        }
    }

    .mobile-score-content {
        width: 100%;
        max-height: 80vh;
        background: #fff;
        border-radius: 24px 24px 0 0;
        display: flex;
        flex-direction: column;
        animation: slideUpModal 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        padding-bottom: env(safe-area-inset-bottom, 20px);
    }

    @keyframes slideUpModal {
        from {
            transform: translateY(100%);
        }

        to {
            transform: translateY(0);
        }
    }

    .mobile-score-header {
        padding: 20px;
        border-bottom: 1px solid #f1f5f9;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .mobile-score-header h3 {
        margin: 0;
        font-size: 17px;
        font-weight: 800;
        color: #1e293b;
    }

    .mobile-score-list {
        flex: 1;
        overflow-y: auto;
        padding: 10px 20px;
    }

    .score-row-mobile {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px 0;
        border-bottom: 1px solid #f8fafc;
    }

    .score-row-mobile:last-child {
        border-bottom: none;
    }

    .score-row-mobile .info {
        display: flex;
        flex-direction: column;
    }

    .score-row-mobile .name {
        font-weight: 700;
        font-size: 14px;
        color: #1e293b;
    }

    .score-row-mobile .user {
        font-size: 12px;
        color: #64748b;
    }

    .score-row-mobile .score-val {
        background: #fdf2f4;
        color: var(--primary);
        font-weight: 800;
        padding: 4px 12px;
        border-radius: 8px;
        font-size: 15px;
    }
}
/* ============================================================
   TRÌNH SOẠN THẢO CÓ ĐỊNH DẠNG (Tuyển sinh / Tin tức) — 2026-07-27
   Dùng cho ô "Tiêu đề bài đăng" và "Nội dung chi tiết".
   ============================================================ */
.rte-box {
    margin-top: 8px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
    overflow: hidden;
    transition: border-color .15s;
}

.rte-box:focus-within {
    border-color: #bb2649;
    background: #fff;
}

.rte-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 10px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
}

.rte-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    background: #fff;
    color: #334155;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: .15s;
}

.rte-btn:hover {
    background: #fff1f2;
    border-color: #fecdd3;
    color: #bb2649;
}

.rte-btn:active {
    transform: translateY(1px);
}

/* Đang bật chế độ này tại vị trí con trỏ */
.rte-btn.active {
    background: #bb2649;
    border-color: #bb2649;
    color: #fff;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.18);
}

.rte-btn.active:hover {
    background: #a01f3e;
    border-color: #a01f3e;
    color: #fff;
}

.rte-select {
    height: 32px;
    max-width: 140px;
    padding: 0 6px;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    background: #fff;
    color: #334155;
    font-size: 12.5px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    outline: none;
}

.rte-select.active {
    background: #bb2649;
    border-color: #bb2649;
    color: #fff;
    font-weight: 700;
}

.rte-sep {
    width: 1px;
    height: 20px;
    background: #e2e8f0;
    margin: 0 2px;
}

.rte-input {
    padding: 12px 14px;
    outline: none;
    color: #1e293b;
    font-size: 15px;
    line-height: 1.6;
    overflow-y: auto;
    word-break: break-word;
}

.rte-input-title {
    min-height: 46px;
    font-weight: 600;
    white-space: nowrap;
    overflow-x: auto;
}

.rte-input-body {
    min-height: 140px;
    max-height: 420px;
}

/* Chữ gợi ý khi ô còn trống */
.rte-input:empty::before {
    content: attr(data-placeholder);
    color: #94a3b8;
    font-weight: 400;
    pointer-events: none;
}

/* Nội dung bài đăng đã soạn: giữ định dạng nhưng không phá bố cục thẻ */
.ep-rich img {
    max-width: 100%;
    height: auto;
}

.ep-rich p,
.ep-rich div {
    margin: 0;
}

.ep-rich font[size="6"],
.ep-rich font[size="7"] {
    line-height: 1.3;
}

/* Điện thoại: thanh công cụ gọn lại cho vừa màn hình */
@media (max-width: 640px) {
    .rte-toolbar {
        gap: 5px;
        padding: 7px 8px;
    }

    .rte-btn {
        min-width: 30px;
        height: 30px;
        padding: 0 6px;
        font-size: 13px;
    }

    .rte-select {
        height: 30px;
        max-width: 104px;
        font-size: 11.5px;
    }

    .rte-input {
        font-size: 14px;
        padding: 10px 12px;
    }

    .rte-input-body {
        min-height: 120px;
    }
}

/* ============================================================
   RTE — MÀU CHỮ + CÔNG THỨC LATEX (Bổ trợ kiến thức) — 2026-07-30
   ============================================================ */
/* Bảng màu là popup thả xuống -> khung ngoài không được cắt (overflow:hidden) */
.rte-box { overflow: visible; }
.rte-toolbar { border-radius: 9px 9px 0 0; position: relative; z-index: 2; }
.rte-box > .rte-input:last-child,
.rte-box > .rte-preview:last-child { border-radius: 0 0 9px 9px; }
/* Khung Xem trước đang tắt -> ô soạn thảo là phần cuối nhìn thấy được */
.rte-box > .rte-preview:not(.open) { display: none; }
.rte-box:has(> .rte-preview:not(.open)) > .rte-input { border-radius: 0 0 9px 9px; }

.rte-hint {
    margin-top: 6px;
    font-size: 12.5px;
    color: #64748b;
    line-height: 1.5;
}

.rte-hint code {
    background: #fff1f2;
    color: #bb2649;
    border: 1px solid #fecdd3;
    border-radius: 5px;
    padding: 1px 5px;
    font-size: 12px;
    font-family: 'Courier New', monospace;
}

/* ---- Màu chữ ---- */
.rte-color-wrap { position: relative; display: inline-flex; }

.rte-color-btn { gap: 3px; padding: 0 6px; }

.rte-color-chip {
    display: block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, .18);
}

.rte-color-pop {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 30;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, .18);
    padding: 8px;
    width: 168px;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.rte-color-pop.open { display: grid; }

.rte-swatch {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, .12);
    cursor: pointer;
    padding: 0;
    transition: transform .12s;
}

.rte-swatch:hover { transform: scale(1.15); }

.rte-swatch-custom {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 1px dashed #cbd5e1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.rte-swatch-custom input[type="color"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    border: none;
    padding: 0;
}

/* ---- LaTeX ---- */
.rte-btn-latex { gap: 5px; padding: 0 10px; }
.rte-btn-txt { font-size: 12px; font-weight: 700; }

.rte-preview {
    display: none;
    border-top: 1px dashed #cbd5e1;
    background: #f8fafc;
    padding: 10px 14px 14px;
}

.rte-preview.open { display: block; }

.rte-preview-head {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    font-weight: 800;
    letter-spacing: .4px;
    text-transform: uppercase;
    color: #94a3b8;
    margin-bottom: 8px;
}

.rte-preview-body {
    font-size: 15px;
    line-height: 1.75;
    color: #1e293b;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 14px;
    min-height: 44px;
    max-height: 260px;
    overflow: auto;
    word-break: break-word;
}

.rte-preview-body img { max-width: 100%; height: auto; }

/* Điện thoại: thanh công cụ gọn, ẩn chữ trên nút */
@media (max-width: 640px) {
    .rte-btn-txt { display: none; }
    .rte-btn-latex { padding: 0 8px; }
    .rte-color-pop { width: 152px; grid-template-columns: repeat(4, 1fr); }
    .rte-preview-body { font-size: 14px; max-height: 200px; }
}
