/************************************************* spreadsheet.css ***************************************************/
/***************************************************************************************************************************/

/* Screen reader only utility class for ARIA content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.frozen-spreadsheet-container {
    width: 100%;
    /* Allow height to be controlled by inline style (from renderer). Provide a sensible minimum. */
    min-height: 400px;
    background: white;
    border: 1px solid #ccc;
    position: relative;
    overflow: hidden;
    margin-bottom: 0;
    margin-top: 12px;
    /* One standard row height for every spreadsheet on the site (header, data, row-header,
       select, row-group cells) -- previously varied between the 50px default here and a 20px
       override duplicated across 9 junction/matrix pages. Rows no longer grow with wrapped
       text; overflowing text truncates with an ellipsis and the full value is available via
       the cell's title attribute (native tooltip) -- the row's job is to indicate what's there,
       not display it in full. */
    --fs-row-height: 36px;
    /* Alternating row colors (zebra striping), both light so the standard text/hover/selection
       colors stay legible on top of either. */
    --fs-row-bg-odd: #ffffff;
    --fs-row-bg-even: #f6f8fa;
}

/* Utility: full-bleed element that cancels out container gutters so
   components can span the full viewport width while remaining responsive.
   Uses Bootstrap's --bs-gutter-x variable when available, falls back to 15px. */
.full-bleed {
    margin-left: calc(-1 * var(--bs-gutter-x, 15px));
    margin-right: calc(-1 * var(--bs-gutter-x, 15px));
    width: calc(100% + 2 * var(--bs-gutter-x, 15px));
    /* Keep content from touching the viewport edges */
    padding-left: 24px;
    padding-right: 24px;
    box-sizing: border-box;
}

/* Admin CRUD pages (main.php, identified by the frozen spreadsheet's .full-bleed wrapper):
   pull the footer element up via margin rather than touching .site-footer's own padding-top
   (that padding is shared with marketing/landing pages and should stay untouched there).
   The frozen spreadsheet's height is set by SpreadsheetActions.js's fitFrozenSpreadsheetHeight()
   to fill exactly the remaining viewport space below it, so the natural (margin:0) gap to the
   footer is already only a few pixels -- pulling it up further by as much as 24px overlapped
   the footer directly onto the spreadsheet's bottom row on every admin CRUD page (reported on
   4a-attributes.php and others).
   NOTE: this margin is the only lever that actually changes the visible gap -- the spreadsheet's
   own height (fsHeight / fitFrozenSpreadsheetHeight's fill calc) does NOT, because the footer
   immediately follows it in normal document flow: shrinking the spreadsheet moves its own bottom
   edge up, but that also moves the footer's un-margined position up by the same amount, so the
   gap between them is unaffected. Verified empirically -- a JS-side height buffer had zero effect
   on the measured gap, while adjusting this margin moved it 1:1. -6px still measured as a ~2px
   overlap in practice (reported again on 4a-attributes.php), so bumped by 50px to 44px for a
   comfortable margin of safety against overlap across viewport sizes / zoom levels.
   Reduced by 20px (to 24px) per task request to visually tighten the gap between the
   spreadsheet's bottom border and the footer -- still comfortably clear of the ~2px
   overlap measured at -6px below the original 44px baseline. */
body:has(.full-bleed) > footer {
    margin-top: 24px;
}

.frozen-spreadsheet-wrapper {
    display: grid;
    grid-template-areas: 
        "corner header"
        "sidebar content";
    grid-template-columns: 280px 1fr;
    grid-template-rows: auto 1fr;
    width: 100%;
    height: 100%;
}

.fs-corner-cell {
    grid-area: corner;
    background-color: #e8e8e8;
    border-right: 1px solid #aaa;
    border-bottom: 1px solid #aaa;
    font-weight: bold;
    display: flex;
    align-items: center;
    padding: 0 10px;
    position: relative;
    z-index: 4;
}

.fs-header-row {
    grid-area: header;
    background-color: #e8e8e8;
    border-bottom: 1px solid #aaa;
    overflow-x: auto;
    overflow-y: hidden;
    position: relative;
    z-index: 2;
}

.fs-header-content {
    display: flex;
    width: max-content;
    min-width: 100%;
    height: var(--fs-row-height);
}

.fs-header-cell {
    width: 100px;
    min-width: 100px;
    flex-shrink: 0;
    height: var(--fs-row-height);
    padding: 3px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-right: 1px solid #ccc;
    text-align: center;
    font-size: 12px;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    position: relative;
}

/* Column resize handle: a thin invisible-until-hover strip on a header cell's right edge.
   Dragging it resizes this column everywhere it appears (header + every row's data cell +
   any header-group cell spanning it) via SpreadsheetActions.js's initResizeHandles(). */
.fs-col-resize-handle {
    position: absolute;
    top: 0;
    /* Fully inside the cell's own box (not straddling the edge) -- the header cell has
       overflow: hidden for text-ellipsis truncation, which would clip/hit-test-block
       any part of the handle sticking outside its bounds. */
    right: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    z-index: 6;
    background: transparent;
}

.fs-col-resize-handle:hover,
.fs-col-resize-handle.resizing {
    background: rgba(13, 110, 253, 0.35);
}

/* Grouped header band support */
.fs-header-group-row { display: flex; width: max-content; min-width: 100%; }
.fs-group-cell { flex-shrink: 0; text-align: center; font-weight: 600; font-size: 12px; border-right: 1px solid #ccc; padding: 6px 8px; background: #ddd; }

/* Rotated attribute group labels */
.fs-header-group-row.rotate-groups { min-height: 120px; }
.fs-header-group-row.rotate-groups .fs-group-cell { display: flex; align-items: center; justify-content: flex-end; }
.fs-header-group-row.rotate-groups .fs-group-cell .group-label { transform: rotate(-90deg); transform-origin: bottom left; white-space: nowrap; display: inline-block; }

.fs-header-cell .header-main,
.fs-header-cell .header-sub {
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fs-header-cell .header-main {
    font-size: 12px;
    line-height: 1.2;
    margin-bottom: 1px;
}

.fs-header-cell .header-sub {
    font-size: 9px;
    line-height: 1.2;
    color: #666;
    font-weight: normal;
}

.fs-first-column {
    grid-area: sidebar;
    border-right: 1px solid #aaa;
    overflow-y: scroll;
    overflow-x: hidden;
    position: relative;
    z-index: 3;
    scrollbar-width: none;
}

.fs-first-column::-webkit-scrollbar {
    display: none;
}

.fs-first-column-content {
    display: flex;
    flex-direction: column;
}

.fs-row-header {
    height: var(--fs-row-height);
    padding: 3px 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    border-bottom: 1px solid #aaa;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    box-sizing: border-box;
    position: relative;
    /* Zebra striping: alternates with .fs-data-row (same row order, separate DOM tree) */
    background-color: var(--fs-row-bg-odd);
}

.fs-row-header:nth-child(even) {
    background-color: var(--fs-row-bg-even);
}

.fs-row-header .row-main,
.fs-row-header .row-sub {
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fs-row-header .row-main {
    font-weight: bold;
    font-size: 12px;
    color: #333;
}

.fs-row-header .row-sub {
    font-size: 10px;
    color: #666;
    margin-top: 1px;
}

/* Row resize handle: a thin invisible-until-hover strip on a row header's bottom edge.
   Dragging it resizes this single row everywhere it appears (row header + data row + select
   cell) via SpreadsheetActions.js's initResizeHandles(). */
.fs-row-resize-handle {
    position: absolute;
    left: 0;
    /* Fully inside the row header's own box -- it has overflow: hidden for text-ellipsis
       truncation, which would clip/hit-test-block any part of the handle sticking outside
       its bounds. */
    bottom: 0;
    width: 100%;
    height: 6px;
    cursor: row-resize;
    z-index: 6;
    background: transparent;
}

.fs-row-resize-handle:hover,
.fs-row-resize-handle.resizing {
    background: rgba(13, 110, 253, 0.35);
}

/* Floating badge shown while dragging a column/row resize handle, tracking the cursor and
   reporting the live pixel size (SpreadsheetActions.js creates/positions/removes this). */
.fs-resize-tooltip {
    position: fixed;
    z-index: 10000;
    background: #212529;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.fs-content-area {
    grid-area: content;
    /* Horizontal scroll lives on .fs-header-row only (the single "top" scrollbar) --
       content is kept in sync via scrollLeft from JS (syncFrozenScroll), which works
       fine on an overflow:hidden axis since scrollLeft/scrollTo remain scriptable even
       when the axis isn't user-scrollable. Previously this was overflow-x:auto with its
       horizontal scrollbar hidden via ::-webkit-scrollbar, but that only works in WebKit --
       Firefox has no per-axis scrollbar-hiding, so it showed a second horizontal scrollbar
       here in addition to the header's. overflow-x:hidden removes it in every browser. */
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
    z-index: 1;
}

/* Standalone junction pages (13-17, see SpreadsheetActions.js's fitFrozenSpreadsheetHeight /
   fillFrozenSpreadsheetGap) fill the container to a full viewport-minus-chrome height rather
   than shrinking to the real row count, so the page footer always sits flush below one
   viewport. The empty tail under short tables is padded with a single flat grey block (class
   .fs-fill-spacer, one appended to the content area and one to the row-header sidebar) rather
   than simulated rows/gridlines -- a repeating CSS background and per-row filler elements were
   both tried and dropped because they can drift out of alignment with real row borders (a
   background pattern at a fixed interval once a row wraps to multiple lines; filler rows once
   the sidebar and content columns' real content doesn't already end at the same height, as
   happens on program-performance.php's separately-appended Ind Avg / Attr Avg summary rows). A
   single block has nothing internal to misalign. */
.fs-fill-spacer {
    background: #f3f3f3;
    border-top: 1px solid #ccc;
}

.fs-content-grid {
    display: flex;
    flex-direction: column;
    width: max-content;
    min-width: 100%;
}

.fs-data-row {
    display: flex;
    height: var(--fs-row-height);
    border-bottom: 1px solid #aaa;
    /* Zebra striping: alternates with .fs-row-header (same row order, separate DOM tree) */
    background-color: var(--fs-row-bg-odd);
}

.fs-data-row:nth-child(even) {
    background-color: var(--fs-row-bg-even);
}

.fs-data-cell {
    width: 100px;
    min-width: 100px;
    flex-shrink: 0;
    padding: 3px 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid #ccc;
    font-weight: normal;
    font-size: 13px;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    text-align: center;
}

/* The cell's text lives in this inner span rather than directly in the flex container so
   text-overflow: ellipsis actually applies. As a flex item, a bare text node defaults to
   min-width: auto, which keeps it at its full intrinsic width and lets it silently overflow
   the (overflow: hidden) parent with no "..." -- unlike the header/row-header cells, whose
   text already lives in a non-flex-item child (.header-main / .row-main) and truncates
   correctly. min-width: 0 here lets the span actually shrink to the cell's width. */
.fs-data-cell .cell-value {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fs-data-cell.clickable {
    cursor: pointer;
    transition: background-color 0.2s;
}

.fs-data-cell.clickable:hover {
    background-color: #f0f0f0;
}

/* ARIA: Focus indicators for keyboard navigation */
.fs-data-row:focus,
.fs-row-header:focus,
.fs-data-cell:focus {
    outline: 2px solid #0d6efd;
    outline-offset: -2px;
}

.fs-data-row:focus {
    background-color: rgba(13, 110, 253, 0.1);
}

/* Color coding for levels */
.fs-data-cell.level-I { color: #2196F3; }
.fs-data-cell.level-D { color: #FF9800; }
.fs-data-cell.level-A { color: #4CAF50; }

/* Data cell styling for course-indicator mapping */
#fs_course_indicators_table_content .fs-data-cell {
    text-align: center;
    font-weight: bold;
    user-select: none;
}

#fs_course_indicators_table_content .fs-data-cell:hover {
    background-color: #fffacd;
    cursor: pointer;
}

.level-I { color: #2196F3; }
.level-D { color: #FF9800; }
.level-A { color: #4CAF50; }

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}


/* ── Selectable (checkbox) column ── */
.frozen-spreadsheet-wrapper.has-selection {
    grid-template-areas:
        "select-corner corner header"
        "select-col sidebar content";
}

/* Selection + row groups combined */
.frozen-spreadsheet-wrapper.has-selection.has-row-groups {
    grid-template-areas:
        "select-corner rowgroup-corner corner header"
        "select-col rowgroups sidebar content";
}

.fs-select-corner {
    grid-area: select-corner;
    background-color: #e8e8e8;
    border-right: 1px solid #aaa;
    border-bottom: 1px solid #aaa;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 5;
}

.fs-select-corner input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #0d6efd;
}

.fs-select-column {
    grid-area: select-col;
    border-right: 1px solid #aaa;
    overflow-y: scroll;
    overflow-x: hidden;
    position: relative;
    z-index: 3;
    scrollbar-width: none;
}

.fs-select-column::-webkit-scrollbar {
    display: none;
}

.fs-select-column-content {
    display: flex;
    flex-direction: column;
}

.fs-select-cell {
    height: var(--fs-row-height);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #aaa;
    box-sizing: border-box;
    /* Zebra striping: alternates with .fs-data-row / .fs-row-header (same row order) */
    background-color: var(--fs-row-bg-odd);
}

.fs-select-cell:nth-child(even) {
    background-color: var(--fs-row-bg-even);
}

.fs-select-cell input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #0d6efd;
}

/* Highlight row when checked */
.fs-select-cell.fs-row-checked {
    background-color: #e7f1ff;
}

/* Selected row highlight applied to row header and data row */
.fs-row-header.fs-row-selected {
    background-color: rgba(231, 241, 255, 0.6) !important;
}

.fs-data-row.fs-row-selected {
    background-color: rgba(231, 241, 255, 0.6) !important;
}

/* ── Row group column (vertical equivalent of header groups) ── */
.frozen-spreadsheet-wrapper.has-row-groups {
    grid-template-areas:
        "rowgroup-corner corner header"
        "rowgroups sidebar content";
}

.fs-row-group-corner {
    grid-area: rowgroup-corner;
    background-color: #e8e8e8;
    border-right: 1px solid #aaa;
    border-bottom: 1px solid #aaa;
    position: relative;
    z-index: 5;
}

.fs-row-group-column {
    grid-area: rowgroups;
    background-color: #f0f0f0;
    border-right: 1px solid #aaa;
    overflow-y: scroll;
    overflow-x: hidden;
    position: relative;
    z-index: 4;
    scrollbar-width: none;
}

.fs-row-group-column::-webkit-scrollbar {
    display: none;
}

.fs-row-group-content {
    display: flex;
    flex-direction: column;
}

.fs-row-group-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-weight: normal;
    font-size: 14px;
    padding: 4px 2px;
    border-bottom: 1px solid #aaa;
    background: #e2e6ea;
    box-sizing: border-box;
    overflow: hidden;
    line-height: 1.3;
}

.fs-row-group-cell .rg-label {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    white-space: normal;
    text-align: center;
    line-height: 1.3;
}