/* css/batch-calendar.css - the DLE batch calendar on the student Batches page (js/batch-calendar-view.js).
 * Colors come from css/tokens.css. Each batch is one bar that spans its days; the four statuses have their own fill (and are named in the
 * legend, in each bar's accessible label and in the list under the calendar, so color is never the only signal). */

.view-switch { display: inline-flex; gap: 0; margin: 0 0 1rem; border: 1px solid var(--c-border-strong, #c9d2dc); border-radius: var(--r-md, 10px); overflow: hidden; background: var(--c-surface, #fff); }
.view-switch button { appearance: none; border: 0; background: transparent; padding: .55rem 1.1rem; min-height: 40px; font: inherit; font-weight: 600; color: var(--c-text-secondary, #4b5a6b); cursor: pointer; }
.view-switch button + button { border-left: 1px solid var(--c-border-strong, #c9d2dc); }
.view-switch button[aria-pressed="true"] { background: var(--c-primary, #0b5d75); color: var(--c-text-on-primary, #fff); }
.view-switch button:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--c-focus, #1a8fb0); }

.batch-calendar[hidden], #batchesList[hidden] { display: none; }
.batch-calendar { background: var(--c-surface, #fff); border: 1px solid var(--c-border, #e3e8ee); border-radius: var(--r-lg, 16px); padding: 1rem; margin-bottom: 1.25rem; min-width: 0; }

.cal-head { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; margin-bottom: .75rem; }
.cal-title { flex: 1 1 auto; margin: 0; font-size: 1.15rem; text-align: center; color: var(--c-text, #0f1b2a); }
.cal-nav, .cal-mode { display: inline-flex; gap: .35rem; }
.cal-btn { appearance: none; min-width: 40px; min-height: 40px; padding: 0 .85rem; border: 1px solid var(--c-border-strong, #c9d2dc); border-radius: var(--r-md, 10px); background: var(--c-surface, #fff); font: inherit; font-weight: 600; color: var(--c-text, #0f1b2a); cursor: pointer; }
.cal-btn:hover { background: var(--c-primary-soft, #e5f3f7); }
.cal-btn[aria-pressed="true"] { background: var(--c-primary, #0b5d75); border-color: var(--c-primary, #0b5d75); color: var(--c-text-on-primary, #fff); }
.cal-btn:focus-visible, .cal-event:focus-visible, .cal-list-item:focus-visible { outline: none; box-shadow: var(--focus-ring, 0 0 0 2px #fff, 0 0 0 4px #1a8fb0); }

.cal-legend { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin: 0 0 .75rem; padding: 0; list-style: none; font-size: .85rem; color: var(--c-text-secondary, #4b5a6b); }
.cal-legend li { display: inline-flex; align-items: center; gap: .4rem; }
.cal-chip { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex: none; }

/* the statuses: one place, used by the bars, the legend and the list */
/* Coming Soon: not open for enrollment yet - a light, dashed outline rather than a solid fill, so it reads as "scheduled, not yet available" */
.s-soon { background: var(--c-primary-soft, #e5f3f7); color: var(--c-primary, #0b5d75); border: 1.5px dashed var(--c-primary, #0b5d75); }
.cal-event.s-soon { box-sizing: border-box; border: 1.5px dashed var(--c-primary, #0b5d75); box-shadow: none; color: var(--c-primary, #0b5d75); }
.cal-chip.s-soon { width: 12px; height: 12px; box-sizing: border-box; }
.batch-status-chip.s-soon { color: var(--c-primary, #0b5d75); }
.s-open { background: var(--c-primary, #0b5d75); }
.s-full { background: var(--c-warning, #8a5a00); }
.s-ongoing { background: var(--c-success, #157347); }
.s-completed { background: var(--c-text-muted, #5f6e7e); }
.s-draft { background: #7c6f9b; }                 /* staff calendar only */
.s-cancelled { background: var(--c-danger, #b42318); }

.cal-scroll { min-width: 0; border: 1px solid var(--c-border, #e3e8ee); border-radius: var(--r-md, 10px); overflow: hidden; }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--c-bg, #f6f8fa); border-bottom: 1px solid var(--c-border, #e3e8ee); }
.cal-weekdays span { padding: .4rem .25rem; text-align: center; font-size: .78rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--c-text-muted, #5f6e7e); }

/* a week: row 1 holds the day numbers, then one row per lane of batches; the day cells span all rows so their borders run full height */
.cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-template-rows: 28px repeat(var(--lanes, 0), 24px) minmax(8px, 1fr); row-gap: 3px; min-height: 92px; position: relative; }
.cal-week + .cal-week { border-top: 1px solid var(--c-border, #e3e8ee); }
.cal-week.is-week-view { min-height: 200px; }
.cal-day { border-left: 1px solid var(--c-border, #e3e8ee); padding: 4px 6px; min-width: 0; }
.cal-day:first-child { border-left: 0; }
.cal-day.is-outside { background: var(--c-bg, #f6f8fa); }
.cal-day.is-outside .cal-num { color: var(--c-text-muted, #5f6e7e); opacity: .7; }
.cal-num { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; border-radius: 999px; font-size: .82rem; font-weight: 600; color: var(--c-text, #0f1b2a); }
.cal-day.is-today .cal-num { background: var(--c-secondary, #042940); color: #fff; }

.cal-event { appearance: none; border: 0; min-width: 0; margin: 0 2px; padding: 0 8px; display: flex; align-items: center; height: 24px; border-radius: 6px; color: #fff; font: inherit; font-size: .76rem; font-weight: 700; letter-spacing: .02em; text-align: left; cursor: pointer; z-index: 1; box-shadow: 0 1px 2px rgba(4, 41, 64, .25); }
.cal-event:hover { filter: brightness(1.1); }
.cal-event-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* a batch that goes on past the week's edge keeps square ends and an arrow */
.cal-event.cont-before { margin-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.cal-event.cont-after { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.cal-event.cont-before::before { content: "\25C0"; font-size: .6rem; margin-right: 5px; opacity: .85; }
.cal-event.cont-after::after { content: "\25B6"; font-size: .6rem; margin-left: auto; padding-left: 5px; opacity: .85; }

.cal-list { list-style: none; margin: .9rem 0 0; padding: 0; display: grid; gap: .45rem; }
.cal-list-item { appearance: none; width: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .6rem; min-height: 44px; padding: .5rem .75rem; border: 1px solid var(--c-border, #e3e8ee); border-radius: var(--r-md, 10px); background: var(--c-surface, #fff); font: inherit; text-align: left; color: var(--c-text, #0f1b2a); cursor: pointer; }
.cal-list-item:hover { background: var(--c-primary-soft, #e5f3f7); }
.cal-list-status { font-size: .8rem; font-weight: 700; color: var(--c-text-secondary, #4b5a6b); }
.cal-list-dates { margin-left: auto; font-size: .85rem; color: var(--c-text-secondary, #4b5a6b); }
.cal-none { margin: .9rem 0 0; color: var(--c-text-muted, #5f6e7e); }

/* the details of one batch */
.batch-dialog { margin: auto; inset: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 0; border-radius: var(--r-lg, 16px); box-shadow: 0 24px 60px rgba(4, 41, 64, .35); overflow: auto; color: var(--c-text, #0f1b2a); }
.batch-dialog::backdrop { background: rgba(4, 41, 64, .55); }
.batch-dialog-inner { padding: 1.25rem; }
.batch-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.batch-dialog-head h2 { margin: 0; font-size: 1.2rem; }
.batch-dialog-close { appearance: none; flex: none; width: 40px; height: 40px; border: 1px solid var(--c-border-strong, #c9d2dc); border-radius: 999px; background: var(--c-surface, #fff); font-size: 1.1rem; line-height: 1; cursor: pointer; }
.batch-dialog-close:focus-visible { outline: none; box-shadow: var(--focus-ring, 0 0 0 2px #fff, 0 0 0 4px #1a8fb0); }
.batch-status-chip { display: inline-block; margin-top: .4rem; padding: .15rem .7rem; border-radius: 999px; color: #fff; font-size: .8rem; font-weight: 700; }
.batch-dates { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; margin: 1rem 0; }
.batch-dates div { padding: .6rem .8rem; border-radius: var(--r-md, 10px); background: var(--c-bg, #f6f8fa); }
.batch-dates dt { font-size: .75rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--c-text-muted, #5f6e7e); }
.batch-dates dd { margin: .15rem 0 0; font-weight: 600; }
.batch-dialog-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.batch-dialog-actions .btn { display: inline-flex; align-items: center; gap: .4rem; min-height: 40px; text-decoration: none; cursor: pointer; }
#batchesTableView[hidden] { display: none; }

@media (max-width: 640px) {
    .batch-calendar { padding: .6rem; border-radius: var(--r-md, 10px); }
    .cal-title { order: -1; flex-basis: 100%; }
    .cal-head { justify-content: space-between; }
    .cal-week { grid-template-rows: 26px repeat(var(--lanes, 0), 20px) minmax(6px, 1fr); min-height: 78px; }
    .cal-day { padding: 3px 2px; }
    .cal-num { font-size: .72rem; min-width: 20px; height: 20px; }
    .cal-event { height: 20px; margin: 0 1px; padding: 0 4px; font-size: .62rem; letter-spacing: 0; }
    .cal-event.cont-before::before, .cal-event.cont-after::after { font-size: .5rem; }
    .cal-weekdays span { font-size: .66rem; letter-spacing: 0; padding: .3rem 0; }
    .cal-list-dates { margin-left: 0; flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) { .cal-event, .cal-btn { transition: none; } }

/* ---------------------------------------------------------------- the student page: the calendar BESIDE the batch cards (app/student/batches) */
/* Desktop: about 55% for the cards and 45% for the calendar. The calendar column sticks to the top while the cards scroll; it is sized to fit the screen, so it
   has no scrollbar of its own. Below 1240px (tablets, phones) the calendar is stacked ABOVE the cards, full width. */
.batches-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.batches-main, .batches-side { min-width: 0; }
.batches-side { order: -1; }
@media (min-width: 1240px) {
    .batches-layout { grid-template-columns: minmax(0, 11fr) minmax(0, 9fr); gap: 1.5rem; }
    .batches-side { order: 0; position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow-y: auto; overscroll-behavior: contain; }   /* the scroll is only a safety net for very short screens */
}

/* the summary of the picked batch, above the calendar: always in view, always the same height class so the calendar does not jump */
.batch-panel { background: var(--c-surface, #fff); border: 1px solid var(--c-border, #e3e8ee); border-radius: var(--r-lg, 16px); padding: .65rem 1rem; margin-bottom: .6rem; min-height: 4.2rem; display: flex; flex-direction: column; justify-content: center; gap: .15rem; }
.batch-panel.has-batch { border-color: var(--c-primary, #0b5d75); box-shadow: 0 0 0 3px var(--c-primary-soft, #e5f3f7); }
.bp-empty { margin: 0; color: var(--c-text-muted, #5f6e7e); font-size: .92rem; }
.bp-top { display: flex; align-items: center; gap: .6rem; }
.bp-title { margin: 0; font-size: 1.25rem; letter-spacing: -.01em; color: var(--c-text, #0f1b2a); }
.bp-top .batch-status-chip { margin: 0; }
.batch-panel-close { appearance: none; margin-left: auto; flex: none; width: 30px; height: 30px; border: 1px solid var(--c-border-strong, #c9d2dc); border-radius: 999px; background: var(--c-surface, #fff); cursor: pointer; }
.batch-panel-close:focus-visible { outline: none; box-shadow: var(--focus-ring, 0 0 0 2px #fff, 0 0 0 4px #1a8fb0); }
.bp-range { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .5rem; font-size: 1.02rem; font-weight: 600; color: var(--c-text, #0f1b2a); }
.bp-days { padding: .05rem .5rem; border-radius: 999px; background: var(--c-primary-soft, #e5f3f7); color: var(--c-primary, #0b5d75); font-size: .82rem; }
.bp-meta { margin: 0; display: flex; flex-wrap: wrap; gap: .1rem .9rem; font-size: .88rem; color: var(--c-text-secondary, #4b5a6b); }
.bp-meta b { color: var(--c-text, #0f1b2a); }
.bp-program { font-weight: 600; }
.bp-note { margin: .1rem 0 0; font-size: .82rem; color: var(--c-text-muted, #5f6e7e); }

/* the calendar: roomy day cells so the multi-day bars read clearly */
.batch-calendar--compact { padding: .8rem; border-radius: var(--r-lg, 16px); margin-bottom: 0; }
.batch-calendar--compact .cal-head { gap: .4rem; justify-content: space-between; margin-bottom: .5rem; }
.batch-calendar--compact .cal-title { order: -1; flex-basis: 100%; font-size: 1.2rem; letter-spacing: -.01em; }
.batch-calendar--compact .cal-btn { min-width: 38px; min-height: 38px; font-size: .88rem; }
.batch-calendar--compact .cal-legend { gap: .2rem .9rem; font-size: .8rem; margin-bottom: .5rem; }
.batch-calendar--compact .cal-weekdays span { font-size: .7rem; padding: .4rem 0; }
.batch-calendar--compact .cal-week { grid-template-rows: 26px repeat(var(--lanes, 0), 22px) minmax(4px, 1fr); row-gap: 2px; min-height: 62px; }
.batch-calendar--compact .cal-week.is-week-view { min-height: 170px; }
.batch-calendar--compact .cal-day { padding: 4px 5px; }
.batch-calendar--compact .cal-num { font-size: .8rem; min-width: 22px; height: 22px; }
.batch-calendar--compact .cal-event { height: 22px; margin: 0 2px; padding: 0 6px; font-size: .72rem; letter-spacing: .01em; }
.batch-calendar--compact .cal-event.cont-before::before, .batch-calendar--compact .cal-event.cont-after::after { font-size: .55rem; }
.batch-calendar--compact .cal-none { margin-top: .6rem; font-size: .9rem; }

/* the picked batch: its bars stand out (the others stay visible, just quieter), every day of its range is tinted, and its first and last day are flagged */
.cal-scroll.has-selection .cal-event:not(.is-selected) { opacity: .5; }
.cal-event.is-selected { outline: 2px solid var(--c-secondary, #042940); outline-offset: 1px; z-index: 2; filter: brightness(1.1); box-shadow: 0 2px 6px rgba(4, 41, 64, .35); }
.cal-day.is-in-selection { background: var(--c-primary-soft, #e5f3f7); }
.cal-day.is-in-selection.is-outside { background: #d8ecf2; }
.cal-flag { position: absolute; top: 7px; right: 3px; padding: 0 4px; border-radius: 999px; font-size: .56rem; font-weight: 800; letter-spacing: 0; line-height: 1.5; color: #fff; }
.cal-flag-start { background: var(--c-primary, #0b5d75); }
.cal-flag-end { background: var(--c-secondary, #042940); }
.cal-day { position: relative; }
.cal-list-item.is-selected { border-color: var(--c-primary, #0b5d75); background: var(--c-primary-soft, #e5f3f7); }

.batch-card[data-batch-card] { cursor: pointer; transition: box-shadow var(--t-base, 200ms) var(--ease, ease), border-color var(--t-base, 200ms) var(--ease, ease); scroll-margin-top: 90px; }
.batch-card.is-selected { border-color: var(--c-primary, #0b5d75); box-shadow: 0 0 0 3px var(--c-primary-soft, #e5f3f7), 0 4px 14px rgba(4, 41, 64, .12); }
.batch-card:focus-visible { outline: none; box-shadow: var(--focus-ring, 0 0 0 2px #fff, 0 0 0 4px #1a8fb0); }

@media (max-width: 640px) {
    .batch-panel { padding: .7rem .8rem; min-height: 4.2rem; }
    .bp-title { font-size: 1.1rem; }
    .bp-range { font-size: .95rem; }
    .batch-calendar--compact { padding: .6rem; }
    .batch-calendar--compact .cal-title { font-size: 1.05rem; }
    .batch-calendar--compact .cal-week { grid-template-rows: 26px repeat(var(--lanes, 0), 21px) minmax(6px, 1fr); min-height: 64px; }
    .batch-calendar--compact .cal-event { height: 21px; font-size: .62rem; padding: 0 3px; margin: 0 1px; }
    .batch-calendar--compact .cal-num { font-size: .72rem; min-width: 0; padding: 0 3px; height: 20px; }
    .cal-flag { top: 6px; right: 1px; font-size: .46rem; padding: 0 2px; }
}
@media (prefers-reduced-motion: reduce) { .batch-card[data-batch-card] { transition: none; } }

/* Back to batch, Previous / Next batch and the card's status chip exist for phones only (the calendar is far above the cards there); desktop and tablet are unchanged */
.bp-back, .bp-nav, .bc-chip, .n-short { display: none; }

/* ---------------------------------------------------------------- phones: a calendar made for a small screen */
@media (max-width: 640px) {
    .batch-card[data-batch-card] { scroll-margin-top: 72px; }
    .bp-back { display: inline-flex; align-items: center; gap: .35rem; margin-left: auto; min-height: 32px; padding: .15rem .7rem; border: 1px solid var(--c-primary, #0b5d75); border-radius: 999px; background: var(--c-surface, #fff); color: var(--c-primary, #0b5d75); font: inherit; font-size: .78rem; font-weight: 700; cursor: pointer; }
    .bp-back:focus-visible { outline: none; box-shadow: var(--focus-ring, 0 0 0 2px #fff, 0 0 0 4px #1a8fb0); }
    .bp-meta { align-items: center; }

    /* the calendar uses the whole screen width: edge to edge, with a compact two-row toolbar */
    .batch-calendar--compact { margin-inline: -1rem; padding: .5rem .35rem .6rem; border-radius: 0; border-left: 0; border-right: 0; }
    .batch-calendar--compact .cal-head { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "prev title next" "today mode mode"; gap: .35rem .4rem; align-items: center; margin-bottom: .4rem; padding-inline: .15rem; }
    .batch-calendar--compact .cal-nav { display: contents; }
    .batch-calendar--compact .cal-nav .cal-btn:first-child { grid-area: prev; }
    .batch-calendar--compact .cal-nav .cal-today { grid-area: today; }
    .batch-calendar--compact .cal-nav .cal-btn:last-child { grid-area: next; }
    .batch-calendar--compact .cal-title { grid-area: title; order: 0; text-align: center; font-size: 1.05rem; }
    .batch-calendar--compact .cal-mode { grid-area: mode; justify-self: end; }
    .batch-calendar--compact .cal-btn { min-height: 36px; min-width: 36px; padding: 0 .7rem; font-size: .85rem; }
    .batch-calendar--compact .cal-legend { gap: .1rem .6rem; font-size: .7rem; margin-bottom: .4rem; padding-inline: .2rem; }
    .batch-calendar--compact .cal-chip { width: 9px; height: 9px; }
    .batch-calendar--compact .cal-scroll { border-radius: 8px; }
    .batch-panel { margin-bottom: .5rem; }

    /* Previous / Next batch: browse every schedule from the calendar, no scrolling through the cards */
    .bp-nav { display: flex; align-items: center; gap: .4rem; margin: -.1rem 0 .35rem; }
    .bp-step { appearance: none; flex: none; display: inline-flex; align-items: center; gap: .35rem; min-height: 36px; padding: 0 .75rem; border: 1px solid var(--c-border-strong, #c9d2dc); border-radius: 999px; background: var(--c-surface, #fff); color: var(--c-primary, #0b5d75); font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer; }
    .bp-step:disabled { opacity: .4; cursor: default; }
    .bp-step:not(:disabled):active { background: var(--c-primary-soft, #e5f3f7); }
    .bp-step:focus-visible { outline: none; box-shadow: var(--focus-ring, 0 0 0 2px #fff, 0 0 0 4px #1a8fb0); }
    .bp-pos { flex: 1; text-align: center; font-size: .85rem; font-weight: 700; color: var(--c-text-secondary, #4b5a6b); white-space: nowrap; }
    .sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

    /* compact batch cards: the facts first (number, status, dates, tuition / downpayment / balance), a quiet one-line notice, an easy Claim Seat */
    .batches-main .batch-card { padding: .7rem .8rem; margin-bottom: .6rem; border-radius: 12px; }
    .batches-main .batch-card .bc-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
    .batches-main .batch-card h2 { margin: 0; font-size: 1.02rem; }
    .bc-chip { display: inline-block; margin: 0; flex: none; font-size: .72rem; padding: .1rem .55rem; }
    .batches-main .batch-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .3rem .5rem; margin: .4rem 0 .5rem; font-size: .85rem; }
    .batches-main .batch-meta > span:first-child { grid-column: 1 / -1; color: var(--c-text-secondary, #4b5a6b); }
    .batches-main .batch-meta > span:not(:first-child) { display: flex; flex-direction: column; gap: .05rem; font-size: .7rem; color: var(--c-text-muted, #5f6e7e); text-transform: uppercase; letter-spacing: .03em; }
    .batches-main .batch-meta > span:not(:first-child) b { font-size: .88rem; letter-spacing: 0; text-transform: none; color: var(--c-text, #0f1b2a); }
    .batches-main .status-box.notice { margin: .3rem 0 .45rem; padding: 0; border-left: 0; background: transparent; font-size: .78rem; color: var(--c-text-muted, #5f6e7e); }
    .batches-main .status-box.notice p { margin: 0; }
    .batches-main .status-box.notice b { color: var(--c-text-secondary, #4b5a6b); }
    .n-full { display: none; }
    .n-short { display: inline; }
    .batches-main .batch-card .card-actions { margin-top: .35rem; gap: .5rem; }
    .batches-main .batch-card .btn-save, .batches-main .batch-card .btn-danger-outline { min-height: 44px; padding: .55rem 1.3rem; font-weight: 700; }
}
/* the narrowest phones: day cells are about 43px wide, so the flags and numbers get a little tighter */
@media (max-width: 360px) {
    .bp-step { padding: 0 .6rem; font-size: .8rem; gap: .25rem; }
    .bp-pos { font-size: .78rem; }
    .batch-calendar--compact .cal-num { padding: 0 1px; }
    .cal-flag { font-size: .42rem; padding: 0 1px; }
}
