/* attendance.css — Matrix heatmap, side drawer, and two-rate attendance chips */

/* ── View wrapper (class set by mountAttendanceMatrix) ───────────── */
.att-matrix-root {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-4);
    height: 100%;
    box-sizing: border-box;
}

/* ── Controls bar ────────────────────────────────────────────────── */
.att-controls {
    display: flex;
    align-items: stretch; /* all controls fill the height of the tallest (nav group with icons) */
    gap: var(--space-3);
    flex-wrap: wrap;
    flex-shrink: 0;
}

.att-search {
    flex: 0 1 220px;
    font-size: var(--text-sm); /* match btn font-size so height aligns */
    box-sizing: border-box;
}

.att-nav-group {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-surface-alt);
}

.att-nav-group .btn {
    border-radius: 0;
    border: none;
    border-right: 1px solid var(--border-default);
    background: transparent;
    color: var(--fg-secondary);
}

.att-nav-group .btn:last-child { border-right: none; }

.att-month-label {
    min-width: 148px;
    text-align: center;
    font-weight: var(--weight-semibold);
    font-size: var(--text-sm);
    color: var(--fg-primary);
    padding: 0 var(--space-2);
    border-right: 1px solid var(--border-default);
    line-height: 1;
}

.att-nav-btn,
.att-today-btn { font-size: var(--text-sm); }

.att-export-btn { margin-left: auto; }

/* ── Scroll wrapper ──────────────────────────────────────────────── */
.att-scroll-wrap {
    overflow: auto;
    flex: 1;
    min-height: 0;
    /* No card — the grid provides its own outer border */
}

/* ── Grid ────────────────────────────────────────────────────────── */
.att-grid {
    display: grid;
    min-width: 1200px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    overflow: clip; /* clips at border-radius without creating a scroll container (overflow:hidden would break position:sticky) */
}

/* ── Cells (base) ────────────────────────────────────────────────── */
.att-cell {
    padding: var(--space-1);
    border-right: 1px solid var(--color-neutral-100);
    border-bottom: 1px solid var(--color-neutral-100);
    font-size: var(--text-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
}

/* ── Header row ──────────────────────────────────────────────────── */
.att-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--bg-surface);
    font-weight: var(--weight-semibold);
    font-size: var(--text-xs);
    color: var(--fg-secondary);
    flex-direction: column;
    gap: 2px;
    min-height: 40px;
    border-bottom: 2px solid var(--border-default);
}

.att-name-header {
    position: sticky;
    left: 0;
    z-index: 30;
    background: var(--bg-surface);
    padding-left: var(--space-3);
    color: var(--fg-tertiary);
    font-size: var(--text-micro);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-wider);
    text-transform: uppercase;
}

.att-header--holiday { background: var(--color-neutral-100); }

.att-day-num { font-weight: var(--weight-semibold); color: var(--fg-secondary); }
.att-day-name { color: var(--fg-tertiary); font-size: var(--text-micro); }

/* ── Today column highlight ──────────────────────────────────────── */
.att-header[data-today] {
    background: var(--color-primary-50);
    border-bottom: 2px solid var(--color-primary-600);
}

.att-header[data-today] .att-day-num { color: var(--color-primary-700); }
.att-header[data-today] .att-day-name { color: var(--color-primary-400); }

.att-status-cell[data-today] {
    background: var(--color-primary-50);
}

/* ── Weekend column tint ─────────────────────────────────────────── */
.att-header[data-weekend] {
    background: var(--color-neutral-50);
    border-bottom-color: var(--color-neutral-200);
}

.att-header[data-weekend] .att-day-num { color: var(--fg-tertiary); }

.att-cell--noclass[data-weekend] { background: var(--color-neutral-50); }

/* ── Classroom group header ──────────────────────────────────────── */
.att-group-header {
    position: sticky;
    left: 0;
    z-index: 12;
    justify-content: flex-start;
    align-items: center;
    gap: var(--space-2);
    padding: 0 var(--space-3);
    background: var(--color-neutral-50);
    font-weight: var(--weight-semibold);
    color: var(--fg-primary);
    font-size: var(--text-sm);
    border-top: 1px solid var(--border-default);
    border-bottom: 1px solid var(--border-default);
    border-left: 3px solid var(--color-neutral-300);
    min-height: 34px;
}

/* Dept accent — border-left is cleanest on a sticky grid item */
.att-group-header[data-dept="math"]     { border-left-color: var(--color-dept-math); }
.att-group-header[data-dept="chinese"]  { border-left-color: var(--color-dept-arts); }
.att-group-header[data-dept="english"]  { border-left-color: var(--color-dept-humanities); }
.att-group-header[data-dept="science"]  { border-left-color: var(--color-dept-science); }
.att-group-header[data-dept="physics"]  { border-left-color: var(--color-dept-physics); }

.att-group-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.att-group-badge {
    font-size: var(--text-micro);
    font-weight: var(--weight-semibold);
    color: var(--color-primary-700);
    background: var(--color-primary-light);
    border-radius: var(--radius-full);
    padding: 2px var(--space-2);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Name column ─────────────────────────────────────────────────── */
.att-name-cell {
    position: sticky;
    left: 0;
    z-index: 10;
    background: var(--bg-surface);
    justify-content: space-between;
    padding: var(--space-1) var(--space-2);
    text-align: left;
    cursor: pointer;
    transition: background var(--transition-fast);
    gap: var(--space-1);
    border: none;
}

.att-name-cell:hover { background: var(--color-neutral-50); }

.att-name-cell--pinned { background: var(--color-primary-50); }
.att-name-cell--pinned:hover { background: var(--color-primary-100); }

.att-name-text {
    flex: 1;
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--fg-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.att-pin-icon {
    font-size: 14px;
    color: var(--fg-tertiary);
    flex-shrink: 0;
}

/* ── Status cells ────────────────────────────────────────────────── */
.att-status-cell {
    cursor: default;
    background: var(--bg-surface);
}

/* Small rounded indicator centred in the transparent cell */
.att-status-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: var(--radius-sm);
    font-size: var(--text-micro);
    font-weight: var(--weight-semibold);
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.att-cell--present .att-status-dot,
.att-legend-dot--present   { background: var(--color-success-light);  color: var(--color-success); }

.att-cell--absent .att-status-dot,
.att-legend-dot--absent    { background: var(--color-danger-light);   color: var(--color-danger); }


.att-cell--pending .att-status-dot,
.att-legend-dot--pending   { background: var(--color-neutral-100);    color: var(--color-neutral-400); }

.att-cell--unmarked .att-status-dot,
.att-legend-dot--unmarked  {
    background: var(--color-warning-light);
    color: var(--color-warning-dark);
    box-shadow: inset 0 0 0 1px var(--color-warning);
}

.att-cell--holiday .att-status-dot,
.att-legend-dot--holiday   { background: var(--color-neutral-200);    color: var(--color-neutral-600); }

.att-cell--cancelled .att-status-dot,
.att-legend-dot--cancelled { background: var(--color-neutral-100);    color: var(--color-neutral-400); text-decoration: line-through; }

.att-cell--noclass         { background: var(--bg-surface); }

/* ── Status legend ───────────────────────────────────────────────── */
.att-legend {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex-wrap: wrap;
    flex-shrink: 0;
}

.att-legend-label {
    font-size: var(--text-micro);
    font-weight: var(--weight-semibold);
    color: var(--fg-tertiary);
    letter-spacing: var(--tracking-wider);
    text-transform: uppercase;
    flex-shrink: 0;
}

.att-legend-item {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-size: var(--text-xs);
    color: var(--fg-secondary);
    white-space: nowrap;
}

.att-legend-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: var(--weight-semibold);
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

/* ── Empty / status messages ─────────────────────────────────────── */
.att-status-msg { color: var(--fg-secondary); font-size: var(--text-sm); min-height: 1.5rem; }
.att-status-msg:empty { display: none; }
.att-empty { color: var(--fg-secondary); font-size: var(--text-sm); padding: var(--space-4); }

/* ── Backdrop ────────────────────────────────────────────────────── */
.att-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.3);
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
}

.att-backdrop--open { opacity: 1; pointer-events: auto; }

/* ── Side drawer ─────────────────────────────────────────────────── */
.att-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 380px;
    max-width: 100vw;
    background: var(--bg-surface);
    z-index: 50;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform var(--transition-slow);
    box-shadow: var(--shadow-xl);
}

.att-drawer--open { transform: translateX(0); }

/* ── Drawer header ───────────────────────────────────────────────── */
.att-drawer-header {
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-default);
    /* default top accent; overridden per dept below */
    border-top: 4px solid var(--color-neutral-300);
}

.att-drawer[data-dept="math"]    .att-drawer-header { border-top-color: var(--color-dept-math); }
.att-drawer[data-dept="chinese"] .att-drawer-header { border-top-color: var(--color-dept-arts); }
.att-drawer[data-dept="english"] .att-drawer-header { border-top-color: var(--color-dept-humanities); }
.att-drawer[data-dept="science"] .att-drawer-header { border-top-color: var(--color-dept-science); }
.att-drawer[data-dept="physics"] .att-drawer-header { border-top-color: var(--color-dept-physics); }

.att-drawer-header-inner {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: var(--space-4);
    gap: var(--space-3);
}

.att-drawer-title { flex: 1; min-width: 0; }

.att-drawer-eyebrow {
    font-size: var(--text-micro);
    font-weight: var(--weight-semibold);
    color: var(--fg-tertiary);
    letter-spacing: var(--tracking-wider);
    text-transform: uppercase;
    margin: 0 0 var(--space-1);
}

.att-drawer-student-name {
    font-size: var(--text-h3);
    font-weight: var(--weight-semibold);
    color: var(--fg-primary);
    letter-spacing: var(--tracking-normal);
    line-height: var(--leading-snug);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.att-drawer-close { flex-shrink: 0; }

/* ── Drawer body ─────────────────────────────────────────────────── */
.att-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.att-drawer-loading,
.att-drawer-empty,
.att-drawer-error { color: var(--fg-secondary); font-size: var(--text-sm); }

/* ── Drawer summary stat block ───────────────────────────────────── */
.att-drawer-summary {
    background: var(--color-neutral-50);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    flex-shrink: 0;
}

.att-drawer-summary-stats {
    display: flex;
    gap: var(--space-6);
}

.att-drawer-summary-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.att-drawer-summary-value {
    font-size: var(--text-h2);
    font-weight: var(--weight-bold);
    color: var(--fg-primary);
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-tight);
}

.att-drawer-summary-value small {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--fg-secondary);
    letter-spacing: 0;
}

.att-drawer-summary-label {
    font-size: var(--text-micro);
    font-weight: var(--weight-medium);
    color: var(--fg-tertiary);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
}

/* ── Timeline ────────────────────────────────────────────────────── */
.att-timeline-wrap {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.att-timeline-month {
    font-size: var(--text-micro);
    font-weight: var(--weight-semibold);
    color: var(--fg-tertiary);
    letter-spacing: var(--tracking-wider);
    text-transform: uppercase;
    padding-bottom: var(--space-1);
    border-bottom: 1px solid var(--border-default);
}

.att-timeline {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.att-timeline-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.att-timeline-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.att-timeline-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
    gap: var(--space-2);
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border-default);
}

.att-timeline-item:last-child .att-timeline-content { border-bottom: none; }

.att-timeline-date {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--fg-primary);
}

.att-timeline-chip {
    font-size: var(--text-micro);
    font-weight: var(--weight-semibold);
    padding: 2px var(--space-2);
    border-radius: var(--radius-full);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    white-space: nowrap;
}

/* ── Two-rate attendance (student card) ──────────────────────────── */
.student-card-metric-item--attendance { align-items: flex-start; }

.student-card-att-rates {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.student-card-att-rate-block {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.student-card-att-rate-sep {
    font-size: var(--text-xs);
    color: var(--fg-subtle);
    padding: 0 2px;
    align-self: flex-start;
    margin-top: 2px;
}

.student-card-att-rate-value {
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--fg-default);
}

.student-card-att-rate-label {
    font-size: 10px;
    color: var(--fg-muted);
    white-space: nowrap;
}

/* ── Two-rate attendance (student profile chip) ───────────────────── */

