/* =================================================================== */
/* ===                  FILE CSS CHÍNH (styleV3.css)               === */
/* ===                   DÀNH CHO DỰ ÁN LATEX IDE                  === */
/* =================================================================== */

/* --- BIẾN MÀU SẮC TOÀN CỤC (TÙY CHỌN) --- */
:root {
    --color-primary: #3498db;
    --color-success: #2ecc71;
    --color-warning: #f1c40f;
    --color-danger: #e74c3c;
    --color-purple: #9b59b6;
    --color-teal: #16a085;
    --color-dark-bg: #2c3e50;
    --color-light-text: #ecf0f1;
}


/* ================================================= */
/* === STYLE CHUNG CHO CÁC NÚT TRÊN TOOLBAR      === */
/* ================================================= */

/* --- 1. Class nền tảng cho tất cả các nút --- */
.toolbar-btn {
    color: white;
    border: none;
    padding: 6px 12px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    font-weight: bold;
    border-radius: 4px;
    margin-left: 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.toolbar-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toolbar-btn:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
    opacity: 0.65;
    transform: none;
    box-shadow: none;
}

.toolbar-btn i {
    margin-right: 6px;
}

/* --- 2. Áp dụng màu sắc riêng cho từng nút bằng ID --- */

/* Nút Tools */
#latex-tools-btn {
    background-color: var(--color-purple);
}

#latex-tools-btn:hover {
    background-color: #8e44ad;
}

#latex-tools-btn i {
    animation: magic-sparkle 2s infinite;
}

@keyframes magic-sparkle {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.2);
        opacity: 0.7;
    }
}

/* Nút QR Đáp án */
#generate-qr-btn {
    background-color: var(--color-teal);
}

#generate-qr-btn:hover {
    background-color: #1abc9c;
}

/* Các nút gập hàng loạt */
.fold-button {
    background-color: #555;
    font-family: monospace;
}

.fold-button:hover {
    background-color: #777;
}

/* Cụm nút Google Drive */
.drive-buttons-group {
    display: flex;
    border: 1px solid #3e8e41;
    border-radius: 5px;
    overflow: hidden;
    margin: 0 5px;
}

.drive-buttons-group button {
    background-color: var(--color-success);
    color: white;
    border: none;
    padding: 6px 10px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.drive-buttons-group button:first-child {
    border-right: 1px solid #27ae60;
}

.drive-buttons-group button:hover {
    background-color: #27ae60;
}


/* ================================================= */
/* === CÁC TIỆN ÍCH KHÁC TRÊN TOOLBAR            === */
/* ================================================= */

/* Cụm điều khiển cỡ chữ */
.font-size-controls {
    display: flex;
    align-items: center;
    background-color: #333;
    border-radius: 4px;
    margin-left: 10px;
    border: 1px solid #555;
}

.font-size-controls button {
    background-color: transparent;
    border: none;
    color: white;
    padding: 6px 8px;
    cursor: pointer;
    font-size: 0.9em;
}

.font-size-controls button:hover {
    background-color: #555;
}

.font-size-controls #current-font-size {
    padding: 0 8px;
    font-weight: bold;
    color: var(--color-warning);
    min-width: 40px;
    text-align: center;
    border-left: 1px solid #555;
    border-right: 1px solid #555;
}


/* ================================================= */
/* === CÁC THÀNH PHẦN GIAO DIỆN KHÁC             === */
/* ================================================= */

/* Tooltip xem trước công thức toán */
#math-tooltip {
    position: absolute;
    display: none;
    padding: 12px 15px;
    background-color: var(--color-dark-bg);
    color: var(--color-light-text);
    border: 1px solid #34495e;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    z-index: 10000;
    font-size: 1.2em;
    user-select: none;
    -webkit-user-select: none;
    transition: opacity 0.1s ease-in-out;
}


/* ================================================= */
/* === TÙY BIẾN GIAO DIỆN CHO SWEETALERT2 MODAL   === */
/* ================================================= */

/* --- Modal của "Latex Tools" --- */
#latex-tools-form {
    text-align: left;
    font-size: 1em;
}

#latex-tools-form hr {
    margin: 1.5rem 0;
    border-top: 1px solid #e0e0e0;
}

#latex-tools-form .form-check {
    padding-left: 0;
    margin-bottom: 15px;
}

#latex-tools-form .form-check-label {
    cursor: pointer;
    display: flex;
    align-items: center;
    font-size: 1.05em;
}

#latex-tools-form .form-check-input {
    display: none;
    /* Ẩn checkbox mặc định */
}

#latex-tools-form .form-check-label::before {
    content: '';
    display: inline-block;
    width: 22px;
    height: 22px;
    margin-right: 12px;
    border: 2px solid #bdc3c7;
    border-radius: 4px;
    background-color: #fff;
    transition: all 0.2s;
    flex-shrink: 0;
}

#latex-tools-form .form-check-input:checked+.form-check-label::before {
    background-color: var(--color-primary);
    border-color: #2980b9;
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    color: white;
    text-align: center;
    line-height: 18px;
    font-size: 14px;
}

#latex-tools-form .form-check-label:hover::before {
    border-color: var(--color-primary);
}

#numbering-options {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 5px;
    padding: 15px;
    padding-left: 25px;
    margin-top: 10px;
    display: none;
}

#numbering-options .form-label {
    font-size: 0.9em;
    font-weight: 500;
    color: #495057;
}

/* --- Modal của "QR Code" --- */
.swal2-popup.qr-modal-wide {
    width: 700px !important;
}

.swal2-popup #qr-result-textarea {
    width: 95% !important;
    height: 180px !important;
    margin: 10px auto;
    font-size: 1em;
    font-family: monospace;
}

/* --- Style chung cho nút bấm trong các modal --- */
.swal2-styled.swal2-confirm {
    background-color: var(--color-success) !important;
    font-size: 1.1em !important;
}

/* ================================================= */
/* === MODERN PDF VIEWER STYLES (Colorful & Pro) === */
/* ================================================= */
.pdf-viewer-app {
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: #525659;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.pdf-toolbar {
    display: flex;
    align-items: center;
    padding: 8px 15px;
    /* Gradient Background for "Colorful" look */
    background: linear-gradient(90deg, #2c3e50 0%, #4ca1af 100%);
    color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.pdf-toolbar button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    cursor: pointer;
    padding: 6px 12px;
    font-size: 14px;
    border-radius: 4px;
    margin-right: 5px;
    transition: all 0.2s;
}

.pdf-toolbar button:hover {
    background-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.pdf-toolbar button:active {
    transform: translateY(0);
}

.pdf-toolbar .spacer {
    flex: 1;
}

/* Search Box Style */
.pdf-search-box {
    position: relative;
    margin-left: 10px;
    margin-right: 10px;
}

.pdf-search-input {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    padding: 6px 15px 6px 35px;
    color: white;
    outline: none;
    width: 150px;
    transition: all 0.3s;
}

.pdf-search-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.pdf-search-input:focus {
    background: rgba(255, 255, 255, 0.25);
    width: 200px;
    border-color: rgba(255, 255, 255, 0.6);
}

.pdf-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.7);
    pointer-events: none;
}

.pdf-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

.pdf-sidebar {
    width: 250px;
    background-color: #f8f9fa;
    border-right: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

.pdf-sidebar.collapsed {
    margin-left: -250px;
}

.pdf-sidebar-header {
    padding: 12px;
    font-weight: bold;
    background-color: #e9ecef;
    border-bottom: 1px solid #dee2e6;
    color: #495057;
    text-transform: uppercase;
    font-size: 0.85em;
    letter-spacing: 0.5px;
}

.pdf-sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.pdf-outline-item {
    padding: 8px 10px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    border-radius: 4px;
    margin-bottom: 2px;
    transition: background-color 0.2s;
}

.pdf-outline-item:hover {
    background-color: #e2e6ea;
    color: var(--color-primary);
}

.pdf-outline-children {
    margin-left: 15px;
    border-left: 1px solid #dee2e6;
}

.pdf-main-view {
    flex: 1;
    overflow: auto;
    padding: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #525659;
}

.pdf-page-container {
    margin-bottom: 30px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    /* Deep shadow for depth */
    background-color: white;
    position: relative;
    /* For TextLayer */
}

.pdf-page-canvas {
    display: block;
}

/* --- TEXT LAYER (CRITICAL FOR SEARCH) --- */
.textLayer {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    opacity: 0.2;
    /* Make text selectable but invisible-ish */
    line-height: 1.0;
}

.textLayer>span {
    color: transparent;
    position: absolute;
    white-space: pre;
    cursor: text;
    transform-origin: 0% 0%;
}

/* Highlight for search results (if we implement custom highlighting) */
.textLayer .highlight {
    background-color: rgba(255, 255, 0, 0.5);
    border-radius: 2px;
}

::selection {
    background: rgba(0, 0, 255, 0.3);
}