/* ============================================================================
 * history-dashboard.css   —   Tổng quan & biểu đồ
 * ----------------------------------------------------------------------------
 * 🔴 LÁT CẮT CỦA style.css. 11 lát PHẢI nạp ĐÚNG THỨ TỰ trong index.html.
 *    Đổi thứ tự = đổi kết quả đè = lệch giao diện, KHÔNG có lỗi nào báo.
 *    Nối cả 11 lát (bỏ banner này) = style.css gốc TỪNG BYTE.
 *    Kiểm:  node scripts/cut-css.js --verify
 *
 * MỤC LỤC — 660 dòng · 94 rule · 15.7 KB
 *   dòng    15–659    Tổng quan & biểu đồ  (94 rule)
 *
 * Bảng tra đầy đủ mọi miền:      docs/BANDO-CSS.md
 * Vì sao cắt kiểu này:           docs/kien-truc/K6-1-so-do-tach-css.md
 * ========================================================================== */
.dash-root {
    font-family: 'Nunito', 'Segoe UI', Arial, sans-serif;
    color: var(--text-strong);
    max-width: 1100px;
    margin: 0 auto;
}

/* Mọi phần tử trong dashboard dùng border-box → bề rộng đã gồm padding+viền,
   nhờ vậy ô "Gần nhất" và cặp nút bên dưới khít đúng 2 lề trái/phải. */
.dash-root,
.dash-root * {
    box-sizing: border-box;
}

.dash-loading,
.dash-empty {
    padding: 28px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 16px;
}

/* --- Thanh đầu --- */
.dash-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    background: var(--surface-white);
    border: 1px solid var(--border-card);
    border-radius: 16px;
    padding: 16px 18px;
    margin-bottom: 14px;
    box-shadow: 0 2px 10px rgba(var(--shadow-rgb), 0.06);
}

.dash-header-main {
    flex: 1 1 240px;
    min-width: 0;
}

.dash-greet {
    font-size: 18px;
}

.dash-greet strong {
    color: var(--text-strong);
}

.dash-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.dash-contact {
    margin-top: 6px;
    font-size: 14px;
    color: var(--text-muted);
}

.dash-header-actions {
    flex: 0 0 auto;
}

.dash-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #eef7ff;
    border: 1px solid var(--border-card);
    color: var(--text-strong);
    border-radius: var(--radius-pill);
    padding: 4px 12px;
    font-size: 13px;
    font-weight: 700;
}

.dash-chip-ok {
    background: var(--green-soft);
    border-color: var(--border-success);
    color: var(--text-success);
}

.dash-chip-warn {
    background: var(--surface-warning);
    border-color: var(--border-warning);
    color: var(--text-warning);
}

.dash-chip-danger {
    background: var(--surface-danger);
    border-color: var(--border-danger);
    color: var(--accent-danger);
}

/* --- Dải Cần chú ý --- */
.dash-attention {
    border-radius: 14px;
    padding: 12px 16px;
    margin-bottom: 14px;
    font-size: 15px;
    font-weight: 700;
}

.dash-attention-warn {
    background: var(--surface-warning);
    border: 1px solid var(--border-warning);
    color: var(--text-warning);
}

.dash-attention-danger {
    background: var(--surface-danger);
    border: 1px solid var(--border-danger);
    color: var(--accent-danger);
}

/* --- Tiêu đề màn (gọn) --- */
.dash-titlebar {
    margin-bottom: 14px;
}

.dash-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-strong);
}

.dash-titlebar-house .dash-title {
    margin-top: 4px;
}

.dash-house-sub {
    margin-top: 6px;
    font-size: 14px;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

/* --- Lưới thẻ con: GIÃN ĐỀU hết chiều ngang (auto-fit gom track trống) --- */
.dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    align-items: stretch;
}

.dash-card {
    background: linear-gradient(180deg, var(--surface-white), var(--surface-white));
    border: 1px solid var(--border-card);
    border-radius: 16px;
    padding: var(--space-8);
    box-shadow: 0 2px 10px rgba(var(--shadow-rgb), 0.06);
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: transform .15s ease, box-shadow .15s ease;
}

/* [M4.2 lô 1e] bọc chống HOVER DÍNH trên màn cảm ứng */
@media (hover: hover) {
.dash-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(var(--shadow-rgb), 0.12);
}
}

.dash-card-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dash-avatar {
    width: 54px;
    height: 54px;
    border-radius: var(--radius-circle);
    object-fit: cover;
    border: 2px solid var(--border-card);
    background: #eef7ff;
    flex: 0 0 auto;
}

.dash-avatar-letter {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 800;
    color: var(--accent-secondary);
}

.dash-card-id {
    flex: 1 1 auto;
    min-width: 0;
}

.dash-card-name {
    font-size: 17px;
    font-weight: 800;
    color: var(--text-strong);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dash-card-grade {
    font-size: 13px;
    color: var(--text-muted);
}

.dash-level {
    /* [DANH HIỆU] Nhãn dài hơn ("Danh hiệu · Huy hiệu") → cho co + 1 dòng + ellipsis,
       tránh tràn/vỡ đầu thẻ; tên con (dash-card-id) co trước nếu chật. */
    flex: 0 1 auto;
    min-width: 0;
    max-width: 62%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: var(--radius-pill);
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 800;
}

.dash-card-err {
    background: var(--surface-danger);
    border: 1px solid var(--border-danger);
    color: var(--accent-danger);
    border-radius: var(--radius-md);
    padding: 6px 10px;
    font-size: 13px;
}

.dash-card-score {
    font-size: 15px;
    color: var(--text-muted);
    font-weight: 700;
}

.dash-score-num {
    font-size: 26px;
    font-weight: 900;
    color: var(--accent-secondary);
}

.dash-activity {
    font-size: 13.5px;
    color: var(--text-muted);
    background: var(--surface-tint-blue);
    border: 1px dashed var(--border-card);
    border-radius: var(--radius-md);
    padding: 8px 10px;
    line-height: 1.4;
}

.dash-activity-label {
    font-weight: 800;
    color: var(--text-strong);
}

.dash-activity-when {
    color: var(--text-muted);
    font-size: 12.5px;
    white-space: nowrap;
}

.dash-activity-empty {
    color: var(--ink-300);
    font-style: italic;
}

.dash-card-actions {
    display: flex;
    gap: 8px;
    margin-top: auto;
}

/* --- Nút chung của dashboard --- */
.dash-btn {
    /* flex-basis 0 → 2 nút CHIA ĐÔI ĐỀU (không chạy theo độ dài chữ) nên mép ngoài
       của cặp nút khít đúng 2 lề trái/phải của ô "Gần nhất" ngay bên trên. */
    flex: 1 1 0;
    min-width: 0;
    cursor: pointer;
    border: 1px solid var(--blue-200);
    background: #eef7ff;
    color: var(--text-strong);
    border-radius: var(--btn-radius);
    padding: 9px 12px;
    min-height: var(--btn-min-h);
    font-family: inherit;
    font-weight: 700;
    font-size: 14px;
    transition: var(--btn-transition);
}

.dash-btn:hover {
    background: var(--surface-subtle);
}

.dash-btn-primary {
    background: var(--accent-secondary);
    border-color: var(--accent-secondary);
    color: var(--text-inverse);
}

.dash-btn-primary:hover {
    background: var(--accent-secondary-hover);
}

.dash-btn-ghost {
    background: var(--surface-white);
    border-color: var(--border-card);
}

.dash-btn-ghost:hover {
    background: var(--surface-subtle);
}

/* --- Lối tắt --- */
.dash-shortcuts {
    margin-top: 18px;
}

.dash-shortcuts-title {
    font-size: 13px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 8px;
}

.dash-shortcuts-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.dash-shortcut {
    cursor: pointer;
    border: 1px solid var(--border-card);
    background: var(--surface-white);
    color: var(--text-strong);
    border-radius: var(--radius-lg);
    padding: 10px 16px;
    font-family: inherit;
    font-weight: 700;
    font-size: 14px;
    transition: var(--btn-transition);
}

/* [M4.2 lô 1e] bọc chống HOVER DÍNH trên màn cảm ứng */
@media (hover: hover) {
.dash-shortcut:hover {
    background: #eef7ff;
    transform: translateY(-1px);
}
}

/* --- Nút quay lại / tiêu đề chi tiết --- */
.dash-back {
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--accent-secondary);
    font-family: inherit;
    font-weight: 800;
    font-size: 15px;
    padding: 4px 0;
    margin-bottom: 8px;
}

.dash-back:hover {
    text-decoration: underline;
}

.dash-detail-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-strong);
    margin-bottom: 14px;
}

.dash-detail-section-title {
    font-size: 15px;
    font-weight: 800;
    color: var(--text-strong);
    margin: 16px 0 8px;
}

/* --- Biểu đồ --- */
.dash-chart-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin: 16px 0 8px;
}

.dash-chart-head .dash-chart-title {
    margin: 0;
}

/* Selectbox phạm vi: cỡ chữ ≥16px để điện thoại KHÔNG auto-zoom. */
.dash-chart-select {
    font-family: 'Nunito', 'Segoe UI', Arial, sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-strong);
    background: var(--surface-white);
    border: 1.5px solid var(--border-card);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    min-height: 40px;
    cursor: pointer;
}

.dash-chart-select:focus {
    outline: none;
    border-color: var(--accent-secondary);
    box-shadow: var(--shadow-focus);
}

.dash-chart-box {
    position: relative;
    /* mốc định vị cho tooltip */
    background: var(--surface-white);
    border: 1px solid var(--border-card);
    border-radius: 14px;
    padding: 12px;
    box-shadow: 0 2px 10px rgba(var(--shadow-rgb), 0.06);
}

.dash-chart {
    width: 100%;
    height: 180px;
    display: block;
}

/* Tooltip nổi — không chặn chạm (pointer-events:none) để chạm xuyên xuống canvas. */
.dash-chart-tooltip {
    position: absolute;
    transform: translate(-50%, -115%);
    pointer-events: none;
    background: var(--blue-800);
    color: var(--text-inverse);
    border-radius: var(--radius-sm);
    padding: 5px 9px;
    font-size: 12.5px;
    line-height: 1.25;
    text-align: center;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(var(--shadow-rgb), 0.25);
    z-index: 5;
}

.dash-chart-tooltip strong {
    display: block;
    font-size: 13.5px;
}

.dash-chart-tooltip span {
    display: block;
    opacity: 0.85;
    font-size: 11.5px;
}

.dash-chart-empty {
    background: var(--surface-tint-blue);
    border: 1px dashed var(--border-card);
    border-radius: 14px;
    padding: 22px;
    text-align: center;
    color: var(--text-muted);
}

/* --- [TIẾN TRÌNH 15 DẠNG BÀI] Biểu đồ cột trong màn chi tiết con --- */
.dash-mathbars-sub {
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.4;
    margin: -2px 0 10px;
}
.dash-mathbars-box {
    background: var(--surface-white);
    border: 1px solid var(--border-card);
    border-radius: 14px;
    padding: 12px;
    box-shadow: 0 2px 10px rgba(var(--shadow-rgb), 0.06);
}
.dash-mathbars-chart {
    display: flex;
    align-items: stretch;
    gap: 6px;
    padding-top: 16px;   /* chừa chỗ cho số streak + mũi tên trên đỉnh cột cao (giai đoạn 8) */
}
.dash-mathbars-yaxis {
    position: relative;
    flex: 0 0 66px;
    width: 66px;
    height: 200px;
}
.dash-mathbars-ylabel {
    position: absolute;
    right: 4px;
    transform: translateY(50%);
    font-size: 10.5px;
    color: var(--text-muted);
    white-space: nowrap;
    line-height: 1;
}
.dash-mathbars-plot {
    position: relative;
    flex: 1 1 auto;
    height: 200px;
    min-width: 0;
    border-left: 1px solid var(--border-card);
    border-bottom: 1px solid var(--border-card);
}
/* 8 đường "Giai đoạn" — GIỮ ĐÚNG NÉT ĐỨT (dashed) theo yêu cầu */
.dash-mathbars-gline {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 0.5px dashed var(--border, var(--border-card));
    pointer-events: none;
}
.dash-mathbars-bars {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    gap: 4px;
    padding: 0 4px;
}
.dash-mathbar-col {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    height: 100%;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: block;
}
.dash-mathbar-col:focus-visible { outline: 2px solid var(--accent-secondary); outline-offset: 1px; border-radius: 3px; }
.dash-mathbar {
    position: absolute;
    left: 12%;
    right: 12%;
    bottom: 0;
    min-height: 2px;
    border-radius: 4px 4px 0 0;
    display: block;
}
.dash-mathbar-cap {
    position: absolute;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
    pointer-events: none;
}
.dash-mathbar-arrow { font-size: 11px; font-weight: 900; color: var(--ink-700); }
.dash-mathbar-streak {
    font-size: 11px;
    font-weight: 800;
    color: var(--text-secondary, var(--text-muted));
    margin-bottom: 1px;
}
.dash-mathbars-tooltip {
    position: absolute;
    top: 4px;
    z-index: 6;
    pointer-events: none;
    background: var(--blue-800);
    color: var(--text-inverse);
    font-size: 12px;
    line-height: 1.5;
    padding: 6px 9px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    box-shadow: 0 4px 14px rgba(var(--shadow-rgb), 0.28);
}
.dash-mathbars-tooltip b { font-weight: 800; }
.dash-mathbars-xaxis { display: flex; gap: 6px; margin-top: 4px; }
.dash-mathbars-xspacer { flex: 0 0 66px; width: 66px; }
.dash-mathbars-xlabels {
    flex: 1 1 auto;
    display: flex;
    gap: 4px;
    padding: 0 4px;
    min-width: 0;
}
.dash-mathbar-xlabel {
    flex: 1 1 0;
    min-width: 0;
    text-align: center;
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
}
.dash-mathbars-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed var(--border-card);
}
.dash-mathbars-leg {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--ink-700);
}
.dash-mathbars-leg i {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex: 0 0 auto;
    display: inline-block;
}

@media (max-width: 640px) {
    .dash-mathbars-yaxis, .dash-mathbars-xspacer { flex-basis: 46px; width: 46px; }
    .dash-mathbars-ylabel { font-size: 9px; }
    .dash-mathbar-streak { display: none; }   /* điện thoại: 15 cột quá hẹp → ẩn số đỉnh, dùng tooltip khi chạm */
    .dash-mathbars-bars, .dash-mathbars-xlabels { gap: 2px; padding: 0 2px; }
    .dash-mathbar { left: 8%; right: 8%; }
    .dash-mathbar-xlabel { font-size: 8.5px; }
    .dash-mathbars-tooltip { font-size: 11.5px; padding: 5px 8px; }
}