/* static/css/style.css */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: "Segoe UI", sans-serif;
    background: #f4f6f9;
    color: #333;
}

header {
    background: #1a73e8;
    color: white;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

header h1 { font-size: 1.4rem; }

header nav a {
    color: white;
    text-decoration: none;
    margin-left: 1.5rem;
    font-size: 0.95rem;
}

header nav a:hover { text-decoration: underline; }

main {
    max-width: 960px;
    margin: 2rem auto;
    padding: 0 1rem;
}

main h2 { margin-bottom: 1.5rem; color: #1a73e8; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,.08);
    padding: 1.5rem 1rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

.stat-number { font-size: 2.2rem; font-weight: 700; color: #1a73e8; }
.stat-label  { font-size: .85rem; color: #666; }

footer {
    text-align: center;
    padding: 1.5rem;
    color: #999;
    font-size: .85rem;
}

/* ============================================================
   SHARED COMPONENTS
   ============================================================ */

/* Alert messages */
.alert {
    padding: .75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: .9rem;
}
.alert-success { background: #e6f4ea; border-left: 4px solid #34a853; color: #1e7e34; }
.alert-error   { background: #fce8e6; border-left: 4px solid #ea4335; color: #c5221f; }
.alert-warning { background: #fef7e0; border-left: 4px solid #fbbc04; color: #8a6000; }
.alert-info    { background: #e8f0fe; border-left: 4px solid #4285f4; color: #1a4ea8; }

/* Card */
.card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,.07);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.card h3 { color: #1a73e8; margin-bottom: 1rem; font-size: 1.05rem; }

.card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 1rem;
    flex-wrap: wrap;
}
.card-header-actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }

/* Info bar */
.info-bar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    padding: .75rem 1.25rem;
    background: #f0f4ff;
    border-left: 4px solid #4285f4;
}

/* Badges */
.badge {
    display: inline-block;
    padding: .15rem .5rem;
    border-radius: 12px;
    font-size: .75rem;
    font-weight: 600;
}
.badge-success  { background: #e6f4ea; color: #34a853; }
.badge-warning  { background: #fef7e0; color: #8a6000; }
.badge-error    { background: #fce8e6; color: #c5221f; }
.badge-ref      { background: #e8f0fe; color: #4285f4; }
.stat-badge     { background: #f1f3f4; color: #555; padding: .25rem .7rem;
                  border-radius: 12px; font-size: .8rem; }

/* Buttons */
.btn {
    display: inline-block;
    padding: .55rem 1.2rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: .9rem;
    font-weight: 600;
    text-decoration: none;
    transition: opacity .15s;
}
.btn:hover { opacity: .85; }
.btn-primary  { background: #1a73e8; color: white; }
.btn-outline  { background: white; color: #1a73e8; border: 1.5px solid #1a73e8; }
.btn-sm       { padding: .3rem .75rem; font-size: .82rem; }
.btn-danger-outline { color: #ea4335; border-color: #ea4335; }

/* Forms */
.import-form { display: flex; flex-direction: column; gap: 1rem; }
.form-row    { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.form-group  { display: flex; flex-direction: column; gap: .3rem; flex: 1; min-width: 160px; }
.form-group label { font-weight: 600; font-size: .88rem; color: #444; }
.file-input  { border: 1.5px dashed #ccc; border-radius: 6px; padding: .5rem; cursor: pointer; }
.input-sm    { width: 90px; padding: .45rem .6rem; border: 1.5px solid #ddd;
               border-radius: 6px; font-size: .9rem; }
.select-col  { padding: .45rem .6rem; border: 1.5px solid #ddd; border-radius: 6px;
               font-size: .88rem; min-width: 200px; }
.form-actions { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-top: .5rem; }
.form-info    { background: #f8f9ff; border-radius: 6px; padding: .75rem 1rem;
                font-size: .88rem; line-height: 1.6; }
.form-info ul { margin-left: 1.2rem; margin-top: .35rem; }
.hint      { font-size: .8rem; color: #888; }
.hint.warn { color: #b87000; }
.hint-cell { font-size: .8rem; color: #777; }
.required  { color: #ea4335; }

/* Tables — scrollable wrapper */
.table-scroll { overflow-x: auto; }

/* Map table */
.map-table { width: 100%; border-collapse: collapse; }
.map-table th, .map-table td {
    padding: .65rem .85rem;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}
.map-table th { background: #f8f9fa; font-size: .85rem; color: #555; text-align: left; }

/* Preview table */
.preview-table { border-collapse: collapse; font-size: .85rem; min-width: 100%; }
.preview-table th, .preview-table td {
    padding: .4rem .7rem;
    border: 1px solid #e0e0e0;
    white-space: nowrap;
}
.preview-table th  { background: #f1f3f4; color: #444; text-align: center; }
.preview-table .row-num { color: #999; font-size: .78rem; text-align: center; }
.preview-table .empty   { text-align: center; color: #aaa; padding: 1rem; }
.hl-class     { background: #e8f5e9 !important; }
.hl-elective  { background: #fff3e0 !important; }

/* ============================================================
   CLASS × SUBJECTS TABLE
   ============================================================ */
.cs-table { border-collapse: collapse; font-size: .82rem; }
.cs-table th, .cs-table td { border: 1px solid #e0e0e0; padding: 0; }

.cs-table .col-class {
    min-width: 90px;
    padding: .4rem .65rem;
    background: #f8f9fa;
    font-size: .83rem;
    position: sticky;
    left: 0;
    z-index: 2;
    white-space: nowrap;
}
.cs-table thead .col-class { z-index: 3; background: #f1f3f4; }

.cs-table .col-subject {
    min-width: 56px;
    max-width: 70px;
    text-align: center;
    padding: .3rem .2rem;
    background: #f1f3f4;
    vertical-align: middle;
}
.subj-header { display: flex; flex-direction: column; align-items: center; gap: .15rem; }
.subj-code   { font-size: .73rem; font-weight: 700; color: #333; }

.cs-table .col-check {
    text-align: center;
    padding: .3rem;
    vertical-align: middle;
}
.subj-check { width: 16px; height: 16px; cursor: pointer; accent-color: #1a73e8; }
.col-toggle { width: 14px; height: 14px; cursor: pointer; accent-color: #888; }

/* Nguồn màu trong bảng preview */
.src-default  { background: #e3f2fd; }
.src-excel    { background: #e8f5e9; }
.src-both     { background: #f3e5f5; }

/* Grade badge trong tên lớp */
.grade-badge { font-size: .72rem; color: #888; margin-left: .3rem; }

/* Chú giải màu */
.legend-bar {
    display: flex; gap: 1.25rem; flex-wrap: wrap;
    margin-bottom: 1rem; font-size: .83rem; align-items: center;
}
.legend-item { display: flex; align-items: center; gap: .35rem; }
.dot { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.dot-default { background: #e3f2fd; border: 1px solid #90caf9; }
.dot-excel   { background: #e8f5e9; border: 1px solid #a5d6a7; }
.dot-both    { background: #f3e5f5; border: 1px solid #ce93d8; }
.dot-none    { background: #f5f5f5; border: 1px solid #ddd; }

/* ============================================================
   IMPORT PANEL (details/summary)
   ============================================================ */
.import-panel { margin-bottom: 1.5rem; }
.import-panel[open] { padding-bottom: 1.5rem; }
.import-summary {
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    color: #1a73e8;
    padding: .5rem 0;
    user-select: none;
    list-style: none;
}
.import-summary::-webkit-details-marker { display: none; }
.import-summary::before { content: "▶ "; font-size: .8rem; }
details[open] .import-summary::before { content: "▼ "; }

/* ============================================================
   SUBJECT CHECKBOXES GRID (trang map)
   ============================================================ */
.subject-checkboxes {
    display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem;
}
.subj-checkbox-label {
    display: flex; align-items: center; gap: .4rem;
    padding: .35rem .75rem;
    border: 1.5px solid #ddd;
    border-radius: 20px;
    cursor: pointer;
    font-size: .88rem;
    transition: border-color .15s, background .15s;
    user-select: none;
}
.subj-checkbox-label:hover { border-color: #1a73e8; background: #f0f6ff; }
.subj-checkbox-label input[type=checkbox]:checked ~ .subj-name { font-weight: 700; }
.subj-checkbox-label.is-default { border-color: #4285f4; background: #e8f0fe; }
.subj-code-tag {
    font-size: .72rem; color: #999; background: #f1f3f4;
    padding: .1rem .35rem; border-radius: 8px;
}

/* ============================================================
   IMPORT RESULT TABLE
   ============================================================ */
.result-summary {
    display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem;
}
.summary-card {
    flex: 1; min-width: 130px;
    background: white; border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,.07);
    padding: 1.2rem 1rem; text-align: center;
    display: flex; flex-direction: column; gap: .3rem;
}
.summary-num  { font-size: 2rem; font-weight: 700; }
.summary-lbl  { font-size: .83rem; color: #666; }
.summary-total   .summary-num { color: #333; }
.summary-success .summary-num { color: #34a853; }
.summary-error   .summary-num { color: #ea4335; }
.summary-warn    .summary-num { color: #fbbc04; }

.result-tabs { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tab-btn {
    padding: .4rem 1rem; border: 1.5px solid #ddd; border-radius: 20px;
    background: white; cursor: pointer; font-size: .88rem;
    transition: border-color .15s, background .15s;
}
.tab-btn.active   { border-color: #1a73e8; background: #e8f0fe; color: #1a73e8; font-weight: 700; }
.tab-btn:hover    { border-color: #1a73e8; }

.result-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.result-table th, .result-table td {
    padding: .55rem .85rem; border-bottom: 1px solid #f0f0f0; vertical-align: middle;
}
.result-table th { background: #f8f9fa; color: #444; text-align: left; }
.result-table .row-num { color: #aaa; font-size: .78rem; text-align: center; }
.result-table .empty   { text-align: center; color: #aaa; }
.result-table .msg-cell { max-width: 300px; font-size: .82rem; color: #555; }
.row-success { background: #fafff9; }
.row-warning { background: #fffdf0; }
.row-error   { background: #fff8f8; }

.check-all-label { display: flex; align-items: center; gap: .4rem; cursor: pointer; font-size: .88rem; }

/* ============================================================
   DATA TABLE (danh sách giáo viên, học sinh…)
   ============================================================ */
.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.data-table th, .data-table td {
    padding: .55rem .85rem;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
    white-space: nowrap;
}
.data-table th    { background: #f8f9fa; color: #444; text-align: left; position: sticky; top: 0; }
.data-table .empty { text-align: center; color: #aaa; padding: 2rem; white-space: normal; }
.data-table .row-num   { color: #bbb; font-size: .78rem; text-align: center; }
.data-table .hint-cell { max-width: 260px; white-space: normal; font-size: .82rem; color: #666; }
.data-table .text-center { text-align: center; }
.row-insert  { background: #f8fbff; }
.row-update  { background: #f0faf4; }
.row-error   { background: #fff8f8; }
.row-inserted{ background: #f8fbff; }
.row-updated { background: #f0faf4; }
.row-skip    { background: #fafafa; }

/* Extra badges */
.badge-info { background: #e8f0fe; color: #1a73e8; }
.badge-pink { background: #fce8f3; color: #c0185d; }

/* Search bar */
.search-bar {
    display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
}
.search-input {
    flex: 1; min-width: 220px;
    padding: .5rem .85rem;
    border: 1.5px solid #ddd; border-radius: 6px;
    font-size: .9rem;
}
.search-input:focus { outline: none; border-color: #1a73e8; }

/* Pagination */
.pagination {
    display: flex; align-items: center; gap: .4rem; flex-wrap: wrap;
    padding: .85rem 1.25rem;
    border-top: 1px solid #f0f0f0;
}


/* ================================================================
   SHARED COMPONENTS
   ================================================================ */

.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,.08);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card h3 {
    font-size: 1.05rem;
    color: #1a73e8;
    margin-bottom: 1rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid #e8eaed;
}

.hint {
    font-size: .8rem;
    color: #888;
    display: block;
    margin-top: .25rem;
}

.hint.warn { color: #e65100; }

.required { color: #d32f2f; margin-left: 2px; }

.empty { color: #aaa; font-style: italic; }

/* Alerts */
.alert {
    padding: .75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: .9rem;
}
.alert-error   { background: #fdecea; color: #c62828; border-left: 4px solid #ef5350; }
.alert-success { background: #e8f5e9; color: #2e7d32; border-left: 4px solid #66bb6a; }
.alert-warning { background: #fff8e1; color: #e65100; border-left: 4px solid #ffa726; }

/* Buttons */
.btn {
    display: inline-block;
    padding: .55rem 1.25rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: .9rem;
    text-decoration: none;
    transition: background .15s, box-shadow .15s;
}
.btn-primary { background: #1a73e8; color: white; }
.btn-primary:hover { background: #1558b0; box-shadow: 0 2px 6px rgba(21,88,176,.35); }
.btn-outline { background: white; color: #1a73e8; border: 1px solid #1a73e8; }
.btn-outline:hover { background: #e8f0fe; }
.btn-sm { padding: .3rem .75rem; font-size: .82rem; }

.form-actions {
    display: flex;
    gap: .75rem;
    align-items: center;
    margin-top: 1.25rem;
}

/* Badges */
.badge {
    display: inline-block;
    padding: .15rem .45rem;
    border-radius: 4px;
    font-size: .75rem;
    font-weight: 600;
    vertical-align: middle;
}
.badge-ref     { background: #e3f2fd; color: #1565c0; }
.badge-success { background: #e8f5e9; color: #2e7d32; }
.badge-warning { background: #fff8e1; color: #e65100; }
.badge-error   { background: #fdecea; color: #c62828; }

/* ================================================================
   IMPORT FORM (Bước 1)
   ================================================================ */

.import-form .form-group {
    margin-bottom: 1.25rem;
}

.import-form label {
    display: block;
    font-weight: 600;
    margin-bottom: .35rem;
    font-size: .9rem;
}

.file-input {
    display: block;
    padding: .5rem;
    border: 2px dashed #1a73e8;
    border-radius: 6px;
    background: #f8f9ff;
    cursor: pointer;
    width: 100%;
    max-width: 480px;
}

.form-row {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.input-sm {
    width: 80px;
    padding: .4rem .6rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: .9rem;
}

.form-info {
    background: #f0f7ff;
    border-left: 4px solid #1a73e8;
    padding: .85rem 1rem;
    border-radius: 0 6px 6px 0;
    margin: 1.25rem 0;
    font-size: .88rem;
}

.form-info ul {
    margin-top: .4rem;
    padding-left: 1.25rem;
    line-height: 1.8;
}

/* ================================================================
   MAP COLUMNS (Bước 2)
   ================================================================ */

.info-bar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: .85rem 1.25rem;
    flex-wrap: wrap;
    font-size: .9rem;
}

.map-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}

.map-table th {
    background: #f1f3f4;
    padding: .65rem .9rem;
    text-align: left;
    font-weight: 600;
    color: #444;
    border-bottom: 2px solid #e0e0e0;
}

.map-table td {
    padding: .55rem .9rem;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.map-table tr:hover td { background: #fafafa; }

.map-table .row-ref td    { background: #fff8e1; }
.map-table .row-ref-sub td { background: #fffde7; font-size: .85rem; }

.select-col {
    padding: .38rem .6rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    min-width: 220px;
    font-size: .85rem;
    background: white;
}

.select-col:focus { border-color: #1a73e8; outline: none; box-shadow: 0 0 0 2px rgba(26,115,232,.2); }

.hint-cell { color: #888; font-size: .8rem; max-width: 220px; }

/* ================================================================
   PREVIEW TABLE (Bước 2)
   ================================================================ */

.table-scroll { overflow-x: auto; }

.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .82rem;
    white-space: nowrap;
}

.preview-table th {
    background: #e8f0fe;
    padding: .5rem .75rem;
    text-align: center;
    border: 1px solid #c5d8fb;
    font-size: .78rem;
    color: #333;
}

.preview-table td {
    padding: .4rem .75rem;
    border: 1px solid #f0f0f0;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ================================================================
   BREADCRUMB
================================================================ */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .88rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.breadcrumb .crumb {
    padding: .25rem .7rem;
    border-radius: 20px;
    background: #f0f0f0;
    color: #666;
}
.breadcrumb .crumb.active {
    background: #3498db;
    color: #fff;
    font-weight: 600;
}
.breadcrumb .crumb.done {
    background: #d4edda;
    color: #155724;
}
.breadcrumb .sep { color: #aaa; }

/* ================================================================
   RADIO ROW / CHECKBOX ROW
================================================================ */
.radio-row, .checkbox-row {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem .25rem;
    cursor: pointer;
    border-radius: 6px;
}
.radio-row:hover, .checkbox-row:hover { background: #f5f5f5; }

/* ================================================================
   ASSIGNMENTS — danh sách phân công
================================================================ */
.assign-list {
    display: flex;
    flex-direction: column;
    gap: .35rem;
}
.assign-item {
    display: block;
    font-size: .88rem;
    line-height: 1.5;
}
.assign-subj {
    font-weight: 600;
    color: #2c3e50;
}
.assign-subj.specialist {
    color: #8e44ad;
    font-style: italic;
}
.assign-cls {
    display: inline-block;
    background: #eaf4fb;
    color: #1a6090;
    border-radius: 4px;
    padding: 0 5px;
    font-size: .8rem;
    font-weight: 600;
    margin: 1px;
}
.badge-cd {
    background: #9b59b6;
    color: #fff;
    font-size: .65rem;
    padding: 1px 5px;
    border-radius: 3px;
    vertical-align: middle;
}
.muted { color: #aaa; font-style: italic; font-size: .88rem; }

/* result-stat (assignments import result) */
.result-stat {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: .75rem 1.5rem;
    border-radius: 10px;
    border: 1px solid #e0e0e0;
    background: #f8f9fa;
    min-width: 110px;
    margin: .3rem;
}
.result-stat .num { font-size: 2rem; font-weight: 700; }
.result-stat .lbl { font-size: .78rem; color: #666; }
.result-stat.inserted { border-color: #27ae60; }
.result-stat.inserted .num { color: #27ae60; }
.result-stat.updated  { border-color: #2980b9; }
.result-stat.updated  .num { color: #2980b9; }
.result-stat.error    { border-color: #e74c3c; }
.result-stat.error    .num { color: #e74c3c; }
.result-stat.ok       { border-color: #27ae60; }
.result-stat.ok       .num { color: #27ae60; }
.result-stat.skipped  { border-color: #f39c12; }
.result-stat.skipped  .num { color: #f39c12; }
.preview-table .row-num {
    background: #f8f9fa;
    color: #888;
    text-align: center;
    font-size: .78rem;
    font-weight: 600;
}

/* ================================================================
   IMPORT RESULT (Bước 3)
   ================================================================ */

.result-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.summary-card {
    border-radius: 8px;
    padding: 1.25rem 1rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: .3rem;
    box-shadow: 0 2px 6px rgba(0,0,0,.07);
}

.summary-num { font-size: 2rem; font-weight: 700; }
.summary-lbl { font-size: .82rem; }

.summary-total   { background: #e8eaf6; color: #3949ab; }
.summary-success { background: #e8f5e9; color: #2e7d32; }
.summary-error   { background: #fdecea; color: #c62828; }
.summary-warn    { background: #fff8e1; color: #e65100; }

/* Tabs */
.result-tabs {
    display: flex;
    gap: .5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.tab-btn {
    padding: .4rem .9rem;
    border-radius: 20px;
    border: 1px solid #ccc;
    background: white;
    cursor: pointer;
    font-size: .85rem;
    color: #555;
    transition: background .15s;
}

.tab-btn:hover  { background: #e8f0fe; border-color: #1a73e8; color: #1a73e8; }
.tab-btn.active { background: #1a73e8; color: white; border-color: #1a73e8; }

/* Result table */
.result-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .87rem;
}

.result-table th {
    background: #f1f3f4;
    padding: .6rem .9rem;
    text-align: left;
    font-weight: 600;
    color: #444;
    border-bottom: 2px solid #e0e0e0;
    white-space: nowrap;
}

.result-table td {
    padding: .5rem .9rem;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.result-table .row-num { color: #999; text-align: center; width: 50px; }
.result-table .msg-cell { color: #555; font-size: .82rem; }

.row-success td { background: #f9fff9; }
.row-warning td { background: #fffdf2; }
.row-error   td { background: #fff8f8; }

