/* --- 1. SETUP VARIABLES & THEME --- */
:root {
    /* Light Mode */
    --bg-color: #f2f2f2;
    --text-color: #515151;
    --primary-color: #1f5ca9;
    --border-color: #c4c4c4;
    --card-bg: #ffffff;
    --nav-bg: rgba(255, 255, 255, 0.55);
    --btn-hover-bg: #eaeaea;
    --shadow-soft: 0 4px 12px rgba(0, 0, 0, 0.05);
    --card-bg-glass: rgba(255, 255, 255, 0.7);
    --border-color-glass: rgba(255, 255, 255, 0.3);
}

[data-theme="dark"] {
    /* Dark Mode */
    --bg-color: #29292e;
    --text-color: #e5e5e5;
    --primary-color: #3b82f6;
    --border-color: #3a3a3e;
    --card-bg: #18181a;
    --nav-bg: rgba(24, 24, 26, 0.65);
    --btn-hover-bg: #27272a;
    --shadow-soft: 0 4px 12px rgba(0, 0, 0, 0.3);
    --card-bg-glass: rgba(24, 24, 26, 0.7);
    --border-color-glass: rgba(255, 255, 255, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    transition: background-color 0.4s ease, color 0.4s ease;
}

.tkb-container, .card, .input-panel, .tab-pane, .modal-content {
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

button, input, select, .tab-btn, .file-upload-btn {
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

body {
    font-family: "Be Vietnam Pro", "TikTok Sans", sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

img {
    max-width: 100%;
    display: block;
}


/* --- BASIC LAYOUT --- */
.page-section {
    max-width: 1300px;
    margin: 40px auto;
    padding: 0 20px;
    min-height: 80vh;
}
.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 24px;
    border-left: 4px solid var(--primary-color);
    padding-left: 12px;
}
/* =========================================
   CORE & VARIABLES
   ========================================= */
.tkb-container {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-soft);
    max-width: 1200px;
    margin: 0 auto;
}

/* Common Utilities */
.text-sm {
    font-size: 16px;
}

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

.font-bold {
    font-weight: bold;
}

.note-text {
    font-size: 0.9em;
    opacity: 0.8;
    margin-top: 10px;
}

.divider {
    opacity: 0.3;
}

/* Transitions */
input,
select,
button,
.file-upload-btn,
.tab-btn,
.course-filter-row {
    transition: all 0.2s ease;
}

/* =========================================
   TAB NAVIGATION
   ========================================= */
.input-panel {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 20px;
    overflow: hidden;
    background: var(--bg-color);
}

.tab-header {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background: var(--card-bg);
}

.tab-btn {
    flex: 1;
    border: none;
    background: transparent;
    padding: 15px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-bottom: 3px solid transparent;
}

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

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background-color: rgba(var(--primary-rgb), 0.05);
}

.tab-content-container {
    padding: 20px;
    background: var(--card-bg);
}

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

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

/* =========================================
   FORMS & INPUTS (Manual & Excel)
   ========================================= */
.file-upload-section {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.file-name-display {
    font-style: italic;
    opacity: 0.7;
}

.file-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #107c41;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
}

.file-upload-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

input[type="file"] {
    display: none;
}

/* Manual Input Grid */
.manual-group-box {
    border: 1px dashed var(--border-color);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    background: var(--bg-color);
}

.manual-label {
    font-size: 0.9em;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.manual-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.manual-row input,
.manual-row select {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-color);
}

.manual-row input:focus,
.manual-row select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(31, 92, 169, 0.15);
}

/* Input Sizes */
.input-xs {
    width: 80px;
    flex-grow: 1;
}

.input-sm {
    width: 120px;
    flex-grow: 1;
}

.input-md {
    width: 200px;
    flex-grow: 2;
}

.manual-status-msg {
    margin-top: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    min-height: 24px;
    color: #43a047;
    transition: opacity 0.5s ease;
    opacity: 0;
}

/* =========================================
   BUTTONS
   ========================================= */
.btn-primary,
.btn-secondary,
.action-btn,
.btn-confirm,
.btn-export {
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
    justify-content: center;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    min-width: 100px;
}

.btn-secondary {
    background: #666;
    color: white;
    font-size: 0.9em;
    min-width: 100px;
}

.action-btn {
    background: var(--primary-color);
    color: white;
    padding: 12px 30px;
    border-radius: 8px;
    font-size: 1rem;
    margin: 20px auto 0;
    box-shadow: 0 4px 10px rgba(31, 92, 169, 0.3);
}

.action-btn:hover,
.btn-primary:hover {
    transform: translateY(-2px);
}

.btn-export {
    background: var(--primary-color);
    color: white;
}

/* Icon-only Buttons */
.btn-copy,
.btn-del-course {
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-copy {
    padding: 2px;
    border-radius: 4px;
    color: var(--text-color);
}

.btn-copy:hover {
    background-color: rgba(var(--primary-rgb), 0.1);
    color: var(--primary-color);
}

.btn-del-course {
    color: #e53935;
    padding: 6px;
    border-radius: 50%;
}

.btn-del-course:hover {
    background: rgba(229, 57, 53, 0.1);
}

.btn-del-group {
    background: #ffebee;
    border: 1px solid #ffcdd2;
    color: #c62828;
    border-radius: 4px;
    width: 32px;
    height: 32px;
    display: none;
    /* JS toggles this */
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.btn-del-group:hover {
    background: #ef5350;
    color: white;
    border-color: #ef5350;
}

.btn-clear {
    background: transparent;
    border: 1px solid #e53935;
    color: #e53935;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

/* =========================================
   HELPER TOOLS (Download / CMD)
   ========================================= */
.tool-download-group {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
}

.download-link {
    color: var(--primary-color);
    font-size: 0.9em;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.cmd-box-container {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 0.9em;
}

.cmd-box {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: 6px;
    font-family: "Consolas", "Monaco", monospace;
    font-size: 0.85rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* =========================================
   SETTINGS & FILTERS
   ========================================= */
.control-panel {
    border-top: 2px solid var(--border-color);
    padding-top: 10px;
    display: none;
    /* JS toggles this */
}

.control-panel h4 {
    margin-bottom: 15px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.setting-item label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.setting-item select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-color);
    color: var(--text-color);
}

.setting-item select:hover {
    border-color: var(--primary-color);
}

.day-checkboxes {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.day-opt {
    position: relative;
    cursor: pointer;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    text-align: center;
}

.day-opt input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.day-opt:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.day-opt:has(input:checked) {
    background-color: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

/* Course Filter List */
.course-list-area {
    margin: 15px 0;
    padding: 15px;
    background: var(--bg-color);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.course-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.filter-header-row {
    display: flex;
    gap: 10px;
    padding: 0 10px 10px;
    font-weight: bold;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 10px;
}

.col-course {
    flex: 2;
}

.col-slot {
    width: 100px;
    text-align: center;
}

.col-detail {
    flex: 3;
}

.course-filter-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.course-filter-row {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border-color);
}

.course-info-col {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 2;
    min-width: 150px;
}

.course-check-label {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    margin: 0;
}

.course-text-info .c-id {
    font-weight: bold;
    color: var(--primary-color);
}

.course-text-info .c-name {
    font-size: 0.9em;
    opacity: 0.8;
}

.course-opt-col {
    width: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.all-slots-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85em;
    cursor: pointer;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 4px 8px;
    border-radius: 4px;
}

.all-slots-label:hover {
    border-color: var(--primary-color);
}

.course-detail-col {
    flex: 3;
    display: flex;
    gap: 10px;
}

.course-detail-col select {
    padding: 6px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--card-bg);
    color: var(--text-color);
    flex: 1;
}

.group-select-wrapper {
    flex: 1;
    display: flex;
    gap: 5px;
}

/* =========================================
   RESULT SECTION (Calendar)
   ========================================= */
.result-section {
    display: none;
    margin-top: 50px;
    animation: fadeIn 0.5s ease;
}

.schedule-wrapper {
    position: relative;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-color);
    overflow: hidden;
    height: 720px;
    display: flex;
    flex-direction: column;
    overflow-x: auto;
}

/* Calendar Header */
.calendar-header {
    display: flex;
    background: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
    height: 40px;
    flex-shrink: 0;
    min-width: 800px;
}

.time-header-cell {
    width: 60px;
    border-right: 1px solid var(--border-color);
}

.day-header-cell {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border-right: 1px solid var(--border-color);
    background: var(--primary-color);
    color: white;
    font-size: 0.9em;
}

.day-header-cell:last-child {
    border-right: none;
}

/* Calendar Body */
.calendar-body {
    flex: 1;
    display: flex;
    position: relative;
    overflow-y: hidden;
    background: var(--bg-color);
    padding: 12px 0;
    min-width: 800px;
}

.time-column {
    width: 60px;
    border-right: 1px solid var(--border-color);
    position: relative;
}

.time-marker {
    position: absolute;
    width: 100%;
    text-align: right;
    padding-right: 5px;
    transform: translateY(-50%);
    font-size: 0.75em;
    opacity: 0.7;
}

.time-marker span {
    background: var(--bg-color);
    padding: 0 2px;
}

.days-column-container {
    flex: 1;
    display: flex;
    position: relative;
}

.day-column {
    flex: 1;
    border-right: 1px solid var(--border-color);
    position: relative;
}

.day-column:last-child {
    border-right: none;
}

.grid-line {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 1px dashed var(--border-color);
    opacity: 0.3;
}

/* Event Blocks */
.event-block {
    position: absolute;
    left: 2px;
    right: 2px;
    border-radius: 4px;
    padding: 4px 6px;
    color: white;
    overflow: hidden;
    font-size: 0.75em;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: z-index 0.2s, filter 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.event-block div {
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.25;
}

.event-block:hover {
    z-index: 5;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    filter: brightness(1.1);
}

/* Event Details Internal Text (Classes used by JS) */
.evt-code {
    font-weight: 700;
    opacity: 0.9;
}

.evt-group-inline {
    font-weight: 500;
    font-size: 0.9em;
    opacity: 0.8;
}

.evt-name {
    font-weight: 600;
    font-size: 1.05em;
}

.evt-teacher,
.evt-room,
.evt-time {
    opacity: 0.95;
}

/* Result Controls */
.result-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin: 20px auto 0;
    background: var(--bg-color);
    padding: 10px 20px;
    border-radius: 50px;
    border: 1px solid var(--border-color);
    width: fit-content;
}

.nav-arrow {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-color);
}

.nav-arrow:hover {
    background: var(--border-color);
}

.result-info {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

#schedule-index-input {
    width: 50px;
    text-align: center;
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    font-weight: bold;
    padding: 4px;
}

.badge-score {
    font-size: 0.75rem;
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 10px;
}

.result-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.btn-like {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.btn-like:hover {
    border-color: #e91e63;
    color: #e91e63;
    background: rgba(233, 30, 99, 0.05);
}

.btn-like.active {
    background: #e91e63;
    color: white;
    border-color: #e91e63;
}

.schedule-details {
    margin-top: 20px;
    padding: 15px;
    background: var(--bg-color);
    border-radius: 8px;
    font-size: 0.9em;
    border: 1px solid var(--border-color);
}

.schedule-details ul {
    padding-left: 20px;
    list-style-type: square;
}

/* =========================================
   GROUP MERGE SECTION
   ========================================= */
.group-merge-section {
    padding-top: 20px;
    text-align: center;
}

.group-merge-section h4 {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.description-text {
    opacity: 0.8;
    font-size: 0.9em;
    margin-bottom: 15px;
}

.group-merge-box {
    border: none;
    padding: 10px 0;
    display: flex;
    justify-content: center;
    width: 100%;
}

.btn-merge {
    background: #e91e63;
}

.group-result-container {
    margin-top: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
    max-height: 600px;
    overflow-y: auto;
    padding: 5px;
}

/* Mode for single result (full width) */
.group-result-container.single-result-mode {
    display: block;
}

.group-result-container.single-result-mode .mini-course-card {
    flex: 0 0 calc(25% - 15px);
    max-width: 400px;
}

.group-result-title {
    grid-column: 1 / -1;
    text-align: center;
    color: #43a047;
    margin-bottom: 10px;
}

/* Merge Plan Cards */
.merge-plan-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 10px;
    padding: 12px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    animation: fadeIn 0.3s ease;
    display: flex;
    flex-direction: column;
    font-size: 0.85rem;
}

.merge-plan-header {
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 8px;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 5px;
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
}

.merge-courses-grid {
    display: grid;
    /* Dùng Grid để chia cột đều tăm tắp */
    grid-template-columns: repeat(2, 1fr);
    /* Mặc định Mobile: 2 cột bằng nhau */
    gap: 8px;
    /* Khoảng cách giữa các ô */
}

/* Mini Course Card */
.mini-course-card {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px;
    /* Đã xóa dòng flex để Grid tự điều chỉnh */
    min-width: 0;
    /* Cho phép co nhỏ nếu cần thiết để tránh vỡ layout */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-size: 0.85rem;
}

.mini-course-card:hover {
    border-color: var(--primary-color);
}

.mc-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-weight: 700;
}

.mc-id {
    color: var(--text-color);
    opacity: 0.8;
}

.mc-group {
    color: #fb3778;
    background: rgba(233, 30, 99, 0.1);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.85em;
    white-space: nowrap;
}

.mc-name {
    font-weight: 500;
    font-size: 15px;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--primary-color);
}

.m-list {
    font-size: 0.75em;
    padding-top: 4px;
    border-top: 1px dashed var(--border-color);
    font-weight: bold;
}

.m-list.part {
    color: var(--text-color);
}

/* =========================================
   MODALS
   ========================================= */
.modal,
.donate-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

.donate-overlay {
    display: none;
    backdrop-filter: blur(4px);
    opacity: 1;
    visibility: visible;
}

/* Donate uses display property in JS */

.modal-content,
.donate-content {
    background: var(--card-bg);
    width: 90%;
    max-width: 400px;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    position: relative;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

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

.modal-content {
    text-align: center;
}

.modal-sm {
    max-width: 320px;
    text-align: left;
}

.close-modal,
.donate-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-color);
    background: transparent;
    border: none;
}

.donate-close {
    top: 10px;
    right: 10px;
    padding: 5px;
    border-radius: 50%;
}

.donate-close:hover {
    background: var(--btn-hover-bg);
}

.modal-header span {
    font-size: 48px;
    margin-bottom: 10px;
    display: block;
}

.modal-header-row {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 10px;
}

.modal-body {
    margin: 15px 0 25px;
    line-height: 1.5;
}

.input-modal-body {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 20px 0;
}

.input-modal-body input {
    padding: 12px 15px;
    background: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 100%;
    box-sizing: border-box;
    font-size: 1rem;
}

.input-modal-body input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.modal-btn-group {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-modal-ok {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 30px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
}

.btn-cancel {
    background: transparent;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}

.btn-cancel:hover {
    background: rgba(128, 128, 128, 0.1);
}

/* Source Modal */
.btn-text-link {
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
    font-size: inherit;
    color: var(--text-color);
    opacity: 0.8;
}

.btn-text-link:hover {
    opacity: 1;
    color: var(--primary-color);
}

.source-modal-body {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 15px;
}

.btn-modal-link {
    margin: 0;
    text-decoration: none;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
}

/* Donate Specifics */
.donate-content {
    text-align: center;
    border: 1px solid var(--border-color);
    animation: zoomIn 0.3s;
}

.donate-title {
    color: var(--primary-color);
    margin-bottom: 10px;
}

.donate-msg {
    margin-bottom: 15px;
    font-size: 0.9rem;
}

.qr-container {
    width: 100%;
    aspect-ratio: 1/1;
    background: #fbfbfb;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.qr-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.donate-info {
    margin-top: 15px;
    font-weight: 600;
}

/* =========================================
   ANIMATIONS & MEDIA QUERIES
   ========================================= */
@keyframes zoomIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .tkb-container {
        padding: 15px;
    }

    /* Filters break to stack */
    .course-filter-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 10px 0;
    }

    .course-info-col {
        border-bottom: 1px dashed var(--border-color);
        padding-bottom: 8px;
        width: 100%;
    }

    .course-opt-col {
        width: 100%;
        justify-content: flex-start;
    }

    .course-detail-col {
        flex-direction: column;
        width: 100%;
    }

    .course-detail-col select {
        width: 100%;
    }

    /* Manual Input stack */
    .manual-row {
        flex-direction: column;
        align-items: stretch;
    }

    .manual-row input,
    .manual-row select,
    .manual-row button {
        width: 100%;
    }

    .result-controls {
        width: 100%;
        justify-content: space-between;
        padding: 10px;
    }

    .group-result-container.single-result-mode .mini-course-card {
        flex: 0 0 calc(50% - 10px);
        max-width: none;
    }
}

@media (min-width: 768px) {

    /* Thay đổi số cột của Grid cha thay vì sửa width của con */
    .merge-courses-grid {
        grid-template-columns: repeat(4, 1fr);
        /* Desktop: 3 cột đều nhau */
    }
}

/* =========================================
   SLOT BLOCKER GRID
   ========================================= */
.setting-item-full {
    grid-column: 1 / -1;
}

.slot-blocker-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    margin-top: 5px;
    overflow-x: auto;
    user-select: none;
}

.slot-header-row,
.slot-row {
    display: grid;
    grid-template-columns: 50px repeat(6, 1fr);
    gap: 4px;
    min-width: 280px;
}

.slot-label {
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    opacity: 0.8;
}

.slot-day-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-align: center;
    padding: 4px 0;
    color: var(--primary-color);
}

.slot-cell {
    height: 30px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.slot-cell:hover {
    background: var(--primary-color-alpha, rgba(37, 99, 235, 0.15));
    border-color: var(--primary-color);
    transform: scale(1.02);
}

.slot-label {
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    opacity: 0.8;
    height: 30px;
}

.slot-cell.blocked {
    background: #ef4444;
    border-color: #dc2626;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .slot-cell.blocked {
    background: #dc2626;
    border-color: #b91c1c;
}

/* =========================================
   TODAY HIGHLIGHT
   ========================================= */
.day-header-cell.today {
    background: #10b981 !important;
    position: relative;
    font-weight: 800;
}

.day-header-cell.today::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.8);
}

/* =========================================
   LOADING SPINNER
   ========================================= */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
}

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

.action-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none !important;
}

/* =========================================
   SCREENSHOT BUTTON
   ========================================= */
.btn-screenshot {
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    background: #10b981;
    color: white;
    transition: all 0.2s ease;
}

.btn-screenshot:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
}

/* =========================================
   KEYBOARD HINTS
   ========================================= */
.result-controls {
    position: relative;
    margin-bottom: 10px;
}

.keyboard-hint {
    text-align: center;
    font-size: 0.7rem;
    opacity: 0.5;
    margin-top: 4px;
}

/* =========================================
   MOBILE RESPONSIVE TWEAKS
   ========================================= */
@media (max-width: 768px) {
    body {
        padding: 10px 10px 20px;
    }
    .page-section {
        margin: 15px auto;
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
    }

    /* Course Filtering List Mobile */
    .filter-header-row {
        display: none; /* Hide header row on mobile, elements stack instead */
    }

    .course-filter-row {
        flex-direction: column;
        align-items: stretch;
        background: var(--card-bg);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        padding: 12px;
        margin-bottom: 10px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    }
    
    .course-info-col {
        margin-bottom: 8px;
        border-bottom: 1px dashed var(--border-color);
        padding-bottom: 8px;
    }
    
    .course-opt-col {
        justify-content: flex-start;
        margin-bottom: 8px;
    }

    .course-detail-col {
        flex-direction: column;
        gap: 8px;
    }

    /* Slot blocker logic */
    .slot-blocker-grid {
        padding: 6px;
    }
    
    /* Result Actions bottom */
    .result-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .result-actions button {
        justify-content: center;
        width: 100%;
    }
    
    .calendar-wrapper {
        margin: 0 -10px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    /* Input section mobile optimizations */
    .tab-header {
        flex-direction: column;
    }
    .tab-btn {
        width: 100%;
        text-align: left;
        border-bottom: 2px solid var(--border-color);
        border-left: 3px solid transparent;
        justify-content: flex-start;
    }
    .tab-btn.active {
        border-bottom-color: var(--border-color);
        border-left-color: var(--primary-color);
    }
    .tool-download-group {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
        text-align: left;
        padding-top: 15px;
        border-top: 1px dotted var(--border-color);
    }
    .tool-download-group .divider {
        display: none;
    }
    .cmd-box-container {
        flex-direction: column;
        gap: 8px;
    }
    .manual-row {
        flex-direction: column;
        align-items: stretch;
    }
    .manual-row input, .manual-row select, .manual-row button {
        width: 100% !important;
        flex: none;
    }

    .file-upload-section {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .file-name-display {
        background-color: var(--btn-hover-bg);
        padding: 8px;
        border-radius: 8px;
        font-size: 0.9rem;
    }

    .note-text {
        font-size: 0.85rem;
        background-color: rgba(var(--primary-rgb), 0.05);
        padding: 12px;
        border-radius: 8px;
        border-left: 3px solid var(--primary-color);
    }
}
/* --- DONATE MODAL --- */

            .donate-modal-overlay {
                position: fixed;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
                background: rgba(0, 0, 0, 0.5);
                z-index: 2000;
                display: none;
                align-items: center;
                justify-content: center;
                backdrop-filter: blur(4px);
                animation: donateFadeIn 0.3s ease;
            }
            .donate-modal-content {
                background: var(--card-bg-glass, rgba(255, 255, 255, 0.7));
                padding: 30px;
                border-radius: 1rem;
                width: 90%;
                max-width: 400px;
                text-align: center;
                position: relative;
                box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
                border: 1px solid var(--border-color-glass, rgba(255, 255, 255, 0.2));
                backdrop-filter: blur(10px);
                -webkit-backdrop-filter: blur(10px);
                animation: donateZoomIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
                color: var(--text-color, #333);
            }
            .donate-modal-close {
                position: absolute;
                top: 10px;
                right: 10px;
                background: transparent;
                border: none;
                color: var(--text-color, #333);
                cursor: pointer;
                padding: 5px;
                border-radius: 50%;
                display: flex;
                align-items: center;
                justify-content: center;
                z-index: 1;
            }
            .donate-modal-close:hover {
                background: var(--btn-hover-bg, #f0f0f0);
            }

            /* Tab buttons */
            .donate-tab-header {
                display: flex;
                gap: 5px;
                margin-bottom: 15px;
                background: var(--border-color-glass, rgba(0, 0, 0, 0.05));
                border-radius: 10px;
                padding: 4px;
            }
            .donate-tab-btn {
                flex: 1;
                padding: 8px 12px;
                border: none;
                background: transparent;
                color: var(--text-color, #333);
                cursor: pointer;
                border-radius: 8px;
                font-size: 0.85rem;
                font-weight: 500;
                transition: all 0.25s ease;
            }
            .donate-tab-btn.active {
                background: var(--primary-color, #6c63ff);
                color: #fff;
                box-shadow: 0 2px 8px rgba(108, 99, 255, 0.3);
            }
            .donate-tab-btn:not(.active):hover {
                background: rgba(108, 99, 255, 0.1);
            }

            /* Tab body — cố định kích thước */
            .donate-tab-body {
                position: relative;
                width: 100%;
                aspect-ratio: 1 / 1.15;
            }
            .donate-tab-panel {
                display: flex;
                flex-direction: column;
                align-items: center;
                justify-content: center;
                width: 100%;
                height: 100%;
                position: absolute;
                top: 0;
                left: 0;
            }

            /* Tab 1 - Shopee */
            .donate-shopee-icon {
                font-size: 3.5rem;
                margin-bottom: 15px;
                color: var(--primary-color, #6c63ff);
            }
            .donate-shopee-msg {
                font-size: 0.95rem;
                line-height: 1.6;
                margin-bottom: 25px;
                padding: 0 5px;
            }
            .donate-shopee-btn {
                display: inline-flex;
                align-items: center;
                gap: 8px;
                padding: 12px 28px;
                background: var(--primary-color, #6c63ff);
                color: #fff;
                border: none;
                border-radius: 10px;
                font-size: 0.95rem;
                font-weight: 600;
                cursor: pointer;
                transition: all 0.25s ease;
                box-shadow: 0 4px 15px rgba(108, 99, 255, 0.3);
            }
            .donate-shopee-btn:hover {
                transform: translateY(-2px);
                box-shadow: 0 6px 20px rgba(108, 99, 255, 0.45);
            }
            .donate-shopee-btn:active {
                transform: translateY(0);
            }

            /* Tab 2 - QR */
            .donate-qr-container {
                width: 100%;
                aspect-ratio: 1/1;
                background: #fbfbfb;
                padding: 10px;
                border-radius: 8px;
                border: 1px solid var(--border-color, #eee);
                display: flex;
                align-items: center;
                justify-content: center;
                margin: 0 auto;
            }
            .donate-qr-container img {
                width: 100%;
                height: 100%;
                object-fit: contain;
            }
            .donate-bank-info {
                margin-top: 15px;
                font-weight: 600;
            }

            @keyframes donateFadeIn {
                from { opacity: 0; }
                to { opacity: 1; }
            }
            @keyframes donateZoomIn {
                from {
                    transform: scale(0.8);
                    opacity: 0;
                }
                to {
                    transform: scale(1);
                    opacity: 1;
                }
            }

/* --- THEME TRANSITION RIPPLE (WAVY) --- */
::view-transition-group(root) {
    animation-duration: 0.9s;
    animation-timing-function: cubic-bezier(0.65, 0, 0.35, 1);
}

::view-transition-old(root),
::view-transition-new(root) {
    animation: none;
    mix-blend-mode: normal;
    display: block;
    unicode-bidi: isolate;
    height: 100%;
}

::view-transition-old(root) {
    z-index: 1;
}

::view-transition-new(root) {
    z-index: 9999;
    animation: ripple-wave 0.9s cubic-bezier(0.65, 0, 0.35, 1) forwards;
    clip-path: circle(0% at var(--ripple-x, 50%) var(--ripple-y, 50%));
}

@keyframes ripple-wave {
    0% {
        clip-path: circle(0% at var(--ripple-x, 50%) var(--ripple-y, 50%));
        opacity: 0.8;
    }
    15% {
        opacity: 1;
    }
    100% {
        clip-path: circle(150% at var(--ripple-x, 50%) var(--ripple-y, 50%));
    }
}




        