/* Portal styles — student booking and admin roster pages.
   Layers on top of styles.css; reuses .container, .btn, .btn-primary and the
   site palette (#0066cc primary, #003366 deep, #333 text). */

/* --- Portal navbar ------------------------------------------------------ */

/* styles.css hides .lang-toggle below 1100px, because the marketing site moves
   language switching into the hamburger menu as #mobile-lang-toggle. The portal
   pages have no hamburger, so without this override the toggle simply vanishes
   on every phone and tablet — leaving a Chinese-speaking parent no way to
   switch language on the one page they actually need to use. */
@media (max-width: 1100px) {
    .portal-nav .lang-toggle {
        display: inline-block;
        margin-left: 0;
    }
}

.portal-nav .nav-container {
    gap: 0.5rem;
}

.portal-nav .lang-toggle {
    margin-left: 0;
}

/* Below this width the logo, title, "Back to site" and the toggle stop fitting
   on one line. The logo already identifies the page, so the title gives way. */
@media (max-width: 560px) {
    .portal-nav .nav-logo h2 { display: none; }
    .portal-nav .nav-logo-img { height: 46px; }
    .portal-nav .nav-link { font-size: 0.9rem; }
    .portal-nav .lang-toggle { padding: 6px 14px; font-size: 0.9rem; }
}

.portal-main {
    min-height: calc(100vh - 80px);
    background: #f5f7fa;
    padding: 2rem 0 4rem;
}

.portal-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.portal-header h1 {
    font-size: 2rem;
    color: #333;
}

.portal-user {
    color: #666;
    font-size: 0.95rem;
}

/* .btn-secondary in styles.css is white-on-transparent for the dark hero and
   would vanish on this light background.
 *
 * .dialog has to be listed separately: dialogs are appended to document.body,
 * not into .portal-main, so a .portal-main-scoped rule never reaches them and
 * every Cancel button was white-on-white until you hovered it. */
.portal-main .btn-secondary,
.dialog .btn-secondary {
    background: #fff;
    color: #0066cc;
    border: 2px solid #0066cc;
}

.portal-main .btn-secondary:hover,
.dialog .btn-secondary:hover {
    background: #0066cc;
    color: #fff;
}

.btn-small {
    padding: 8px 18px;
    font-size: 0.9rem;
}

.btn:disabled,
.btn[disabled] {
    background: #d7dce3;
    color: #8a94a3;
    border-color: #d7dce3;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.portal-main .btn-secondary:disabled:hover,
.dialog .btn-secondary:disabled:hover {
    background: #d7dce3;
    color: #8a94a3;
}

/* --- Tabs --------------------------------------------------------------- */

.portal-tabs {
    display: flex;
    gap: 0.5rem;
    border-bottom: 2px solid #e3e8ef;
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.portal-tab {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    padding: 0.75rem 1.25rem;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    color: #667085;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.portal-tab:hover { color: #0066cc; }

.portal-tab.is-active {
    color: #0066cc;
    border-bottom-color: #0066cc;
}

/* --- Cards and panels --------------------------------------------------- */

.panel {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
    padding: 1.75rem;
}

.auth-card {
    max-width: 460px;
    margin: 2rem auto;
}

.auth-card h2 {
    color: #333;
    margin-bottom: 0.5rem;
}

.auth-card p {
    color: #667085;
    margin-bottom: 1.5rem;
}

/* --- Google sign-in ----------------------------------------------------- */

/* Google renders its own button here and controls its appearance -- their
   brand terms don't allow restyling it. We only centre it. */
.google-slot {
    display: flex;
    justify-content: center;
    min-height: 44px;
}

/* --- Choice list (account type, "who is joining?") ----------------------- */

.choice-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 1rem 0 1.5rem;
}

.choice {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    text-align: left;
    width: 100%;
    padding: 1rem 1.15rem;
    background: #fff;
    border: 1px solid #cfd6e0;
    border-radius: 10px;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.choice:hover:not(:disabled) {
    border-color: #0066cc;
    box-shadow: 0 2px 10px rgba(0, 102, 204, 0.12);
}

.choice:focus-visible {
    outline: 3px solid rgba(0, 102, 204, 0.35);
    outline-offset: 2px;
}

.choice:disabled { opacity: 0.55; cursor: not-allowed; }

.choice-label { font-weight: 600; color: #333; font-size: 1rem; }
.choice-hint { font-size: 0.87rem; color: #667085; }

/* --- Attendee chips ----------------------------------------------------- */

/* One per enrolled child on a session card; tapping toggles "can't make it". */
.attendee-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.55rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.28rem 0.7rem;
    border-radius: 50px;
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.chip-in { background: #e7f5ec; color: #1a7f3c; border-color: #b3e0c4; }
.chip-in:hover:not(:disabled) { background: #d6eede; }

.chip-away { background: #f2f4f7; color: #667085; border-color: #dde2e9; }
.chip-away:hover:not(:disabled) { background: #e8ebef; }
.chip-away .chip-state { text-decoration: line-through; }

.chip:disabled { cursor: default; opacity: 0.7; }

.chip-state { font-weight: 400; opacity: 0.8; }

.auth-divider {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin: 1.4rem 0;
    color: #98a2b3;
    font-size: 0.88rem;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1 1 auto;
    height: 1px;
    background: #e3e8ef;
}

/* --- Banner ------------------------------------------------------------- */

.banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    background: #fff8e6;
    border: 1px solid #f5d78e;
    border-left: 4px solid #e0a800;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    color: #6b5200;
}

/* --- Forms -------------------------------------------------------------- */

.form-field {
    margin-bottom: 1.25rem;
}

.form-field label {
    display: block;
    font-weight: 600;
    color: #344054;
    margin-bottom: 0.4rem;
}

.form-field input {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 1px solid #cfd6e0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    color: #333;
    background: #fff;
}

.form-field input:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.15);
}

.field-hint {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.85rem;
    color: #667085;
}

.form-section {
    border-top: 1px solid #e3e8ef;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
}

.form-section h3 {
    color: #333;
    margin-bottom: 0.25rem;
}

/* --- Week navigation ---------------------------------------------------- */

.week-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.week-label {
    font-size: 1.15rem;
    font-weight: 600;
    color: #333;
}

.week-nav-buttons {
    display: flex;
    gap: 0.5rem;
}

/* --- Day groups and session cards --------------------------------------- */

.day-group { margin-bottom: 2rem; }

.day-heading {
    font-size: 1.05rem;
    font-weight: 700;
    color: #003366;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding-bottom: 0.5rem;
    margin-bottom: 0.85rem;
    border-bottom: 2px solid #e3e8ef;
}

.session-card {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    background: #fff;
    border: 1px solid #e3e8ef;
    border-left: 4px solid #0066cc;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    transition: box-shadow 0.2s ease;
}

.session-card:hover { box-shadow: 0 4px 12px rgba(16, 24, 40, 0.08); }

.session-time {
    flex: 0 0 auto;
    min-width: 9.5rem;
    font-weight: 600;
    color: #003366;
}

.session-body { flex: 1 1 auto; min-width: 0; }

.session-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 0.2rem;
}

.session-meta {
    font-size: 0.88rem;
    color: #667085;
}

.session-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.seat-count {
    font-size: 0.85rem;
    color: #667085;
    white-space: nowrap;
}

.seat-count.is-low { color: #b54708; font-weight: 600; }

.badge {
    display: inline-block;
    padding: 0.25rem 0.7rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-registered { background: #e7f5ec; color: #1a7f3c; }
.badge-full       { background: #fdecea; color: #b42318; }
.badge-cancelled  { background: #f2f4f7; color: #667085; }
.badge-past       { background: #f2f4f7; color: #667085; }

.session-card.is-cancelled {
    border-left-color: #98a2b3;
    background: #fafbfc;
}

.session-card.is-cancelled .session-name,
.session-card.is-cancelled .session-time {
    text-decoration: line-through;
    color: #98a2b3;
}

.session-card.is-past { opacity: 0.65; border-left-color: #98a2b3; }
.session-card.is-registered { border-left-color: #1a7f3c; }

/* --- Notice cards -------------------------------------------------------- */

/* Notices borrow the session card's shape but not its states. They used to be
   given .is-cancelled to colour the bad news, which struck a line through the
   whole sentence and greyed it to #98a2b3 — so "we could not offer Leo a
   place, please contact an admin" arrived crossed out and at roughly 2.6:1
   contrast. The two messages that matter most were the two hardest to read,
   and a strikethrough on "No class on Aug 19" reads as the cancellation itself
   being cancelled. Colour lives in the left edge here; the words stay plain. */
.notice-card { border-left-width: 4px; }
.notice-card .session-name { color: #333; text-decoration: none; }
.notice-good  { border-left-color: #1a7f3c; }
.notice-alert { border-left-color: #b42318; background: #fffbfa; }

/* Admin week view: whole card is the control that opens a roster. */
.session-card.is-clickable { cursor: pointer; }
.session-card.is-clickable:focus-visible {
    outline: 3px solid rgba(0, 102, 204, 0.4);
    outline-offset: 2px;
}

/* --- Empty and loading states ------------------------------------------- */

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: #667085;
}

.empty-state h3 { color: #344054; margin-bottom: 0.5rem; }

.spinner {
    width: 34px;
    height: 34px;
    margin: 3rem auto;
    border: 3px solid #e3e8ef;
    border-top-color: #0066cc;
    border-radius: 50%;
    animation: portal-spin 0.8s linear infinite;
}

@keyframes portal-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    .spinner { animation-duration: 2.4s; }
    .session-card, .portal-tab, .btn { transition: none; }
}

/* --- Status lines ------------------------------------------------------- */

.status-line {
    margin-top: 1rem;
    padding: 0.7rem 1rem;
    border-radius: 8px;
    font-size: 0.92rem;
}

.status-error   { background: #fdecea; color: #b42318; border: 1px solid #f5c6c0; }
.status-success { background: #e7f5ec; color: #1a7f3c; border: 1px solid #b3e0c4; }
.status-info    { background: #eef4ff; color: #1849a9; border: 1px solid #c2d6ff; }

/* --- Dialog ------------------------------------------------------------- */

.dialog-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(16, 24, 40, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    z-index: 2000;
}

/* Centred while it fits, capped and self-scrolling once it does not. Without
   the cap, a dialog taller than the window is clipped at BOTH ends by the
   centring and cannot be scrolled to — on a phone in landscape, or with the
   keyboard open, that put Save out of reach with no way to get at it. dvh
   tracks the browser chrome sliding away on mobile; vh is the older fallback. */
.dialog {
    background: #fff;
    border-radius: 12px;
    padding: 1.75rem;
    max-width: 26rem;
    width: 100%;
    max-height: calc(100vh - 2.5rem);
    max-height: calc(100dvh - 2.5rem);
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(16, 24, 40, 0.25);
}

.dialog-title { color: #333; margin-bottom: 0.6rem; }
.dialog-body { color: #667085; margin-bottom: 1.5rem; }

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* --- Roster table ------------------------------------------------------- */

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

.roster-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 40rem;
}

.roster-table th,
.roster-table td {
    text-align: left;
    padding: 0.75rem 0.9rem;
    border-bottom: 1px solid #e3e8ef;
    font-size: 0.93rem;
}

.roster-table th {
    color: #667085;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.roster-table tbody tr:hover { background: #f9fafb; }

.roster-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.roster-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.inline-check {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin-top: 0.4rem;
    font-size: 0.88rem;
    color: #667085;
    cursor: pointer;
}

.roster-table tr.is-away td { opacity: 0.55; }

.form-field select {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 1px solid #cfd6e0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    color: #333;
    background: #fff;
}

/* --- Make-up counter ----------------------------------------------------- */

/* The +/- pair on the make-up balance. Tabular numerals so the count does not
   jitter sideways between 1 and 8 while somebody presses. */
.counter {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.counter-value {
    min-width: 1.75rem;
    text-align: center;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: #333;
}

.counter-btn {
    min-width: 2.5rem;
    padding-left: 0.6rem;
    padding-right: 0.6rem;
    font-size: 1.05rem;
    line-height: 1;
}

.roster-table tr.is-settled td { opacity: 0.65; }

/* --- Copy-addresses dialog ------------------------------------------------ */

/* Wider than a confirm, so a list of addresses reads as a list rather than a
   column of fragments. */
.dialog.dialog-wide { max-width: 34rem; }

.copy-area {
    width: 100%;
    padding: 0.7rem 0.9rem;
    margin-bottom: 1rem;
    border: 1px solid #cfd6e0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    color: #333;
    background: #f9fafb;
    resize: vertical;
    word-break: break-all;
}

/* Day heading with its own action beside it, on the admin week view. */
.day-heading-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    /* The row owns the space beneath it, not the heading inside it. The button
       is twice the height of the heading text, so with align-items:flex-end the
       row's bottom edge is the BUTTON's bottom edge -- and the heading's own
       margin-bottom sits above that, doing nothing. Without this the button
       lands directly on the first session card. */
    margin-bottom: 0.85rem;
}

.day-heading-row .day-heading {
    flex: 1 1 auto;
    margin-bottom: 0;
}

.minor-tag {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    background: #eef4ff;
    color: #1849a9;
    font-size: 0.72rem;
    font-weight: 600;
}

/* --- Responsive --------------------------------------------------------- */

@media (max-width: 768px) {
    .portal-main { padding: 1.25rem 0 3rem; }
    .portal-header h1 { font-size: 1.5rem; }
    .panel { padding: 1.25rem; }

    .session-card {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .session-time { min-width: 0; }

    .session-actions {
        justify-content: space-between;
        width: 100%;
        /* Admin class cards carry four buttons now. Without this they compress
           to unreadable slivers instead of wrapping onto a second row. */
        flex-wrap: wrap;
    }

    /* A fixed basis rather than auto, so four buttons wrap two-and-two instead
       of sitting four across at 40px each. 6.5rem and not more: at 375px a card
       has about 245px of room, so anything above ~7rem puts two buttons over
       the line and they stack one per row -- four full-width buttons per card,
       fourteen cards down the page. */
    .session-actions .btn { flex: 1 1 6.5rem; text-align: center; }

    .week-nav { flex-direction: column; align-items: stretch; }
    .week-nav-buttons { justify-content: space-between; }
    .week-nav-buttons .btn { flex: 1 1 auto; }
    .week-label { text-align: center; }

    /* Tabs wrap rather than scroll off the edge. The admin bar is five tabs
       wide and about 560px of that had no room on a phone, so Attendance and
       Payments sat past the right edge with no scrollbar to say so — on a
       touch screen there is no hint that a strip scrolls at all. */
    .portal-tabs { flex-wrap: wrap; overflow-x: visible; row-gap: 0; }

    /* Taking attendance happens standing in the room holding a phone, so the
       roster stops being a table there and becomes one card per student.
       Scrolling it sideways instead put Mark absent — the whole point of the
       screen — around 370px beyond the right edge of a 375px phone, reachable
       only by discovering a horizontal scroll with nothing to advertise it.
       The header row goes away and each cell carries its own label. */
    .roster-scroll { overflow-x: visible; }

    .roster-table { min-width: 0; display: block; }
    .roster-table thead { display: none; }
    .roster-table tbody,
    .roster-table tr,
    .roster-table td { display: block; width: 100%; }

    .roster-table tr {
        background: #fff;
        border: 1px solid #e3e8ef;
        border-left: 4px solid #0066cc;
        border-radius: 10px;
        padding: 0.9rem 1rem;
        margin-bottom: 0.75rem;
    }

    .roster-table tbody tr:hover { background: #fff; }

    .roster-table td {
        border-bottom: none;
        padding: 0.25rem 0;
    }

    /* The label a phone loses with the header row. */
    .roster-table td[data-label]::before {
        content: attr(data-label);
        display: block;
        color: #667085;
        font-size: 0.72rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }

    /* The name heads the card, so it needs no label above it. */
    .roster-table td.cell-name {
        font-size: 1rem;
        font-weight: 600;
        color: #333;
        padding-top: 0;
    }
    .roster-table td.cell-name::before { content: none; }

    .roster-table td.cell-action { margin-top: 0.7rem; padding-bottom: 0; }
    .roster-table td.cell-action::before { content: none; }
    .roster-table td.cell-action .btn { width: 100%; }

    /* cell-counter rather than cell-action: cell-action suppresses the label
       above, which is right for a button whose own text says what it does and
       wrong for a bare + and -. This one keeps its data-label and takes the
       same spacing. */
    .roster-table td.cell-counter { margin-top: 0.7rem; padding-bottom: 0; }

    .counter { width: 100%; justify-content: space-between; }
    .counter-btn { flex: 1 1 auto; }
    .counter-value { flex: 0 0 auto; min-width: 3rem; font-size: 1.1rem; }

    /* Comfortable to hit with a thumb. These were 32-36px tall, and they are
       the primary actions on every screen the portal has. */
    .btn-small {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 44px;
    }

    /* The portal has no hamburger to hide this in, so it is the only way to
       switch language on the page a Chinese-speaking parent actually uses. */
    .portal-nav .lang-toggle {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
    }
}

@media (max-width: 480px) {
    .portal-tab { padding: 0.7rem 0.85rem; font-size: 0.92rem; }
    .dialog-actions { flex-direction: column-reverse; }
    .dialog-actions .btn { width: 100%; }
}
