/*
 * The whole stylesheet for the web client. Served from /web/assets/app.css with
 * a long cache lifetime and a content hash in the URL, so it is fetched once.
 */

:root {
    --bg: #fbfaf9;
    --surface: #ffffff;
    --border: #e4e0db;
    --text: #1c1a18;
    --muted: #6b645c;
    --accent: #8c4a2f;
    --accent-text: #ffffff;
    --danger: #a3261c;
    --danger-bg: #fdf0ee;
    --radius: 10px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #16140f;
        --surface: #211e19;
        --border: #38332b;
        --text: #f0ece5;
        --muted: #a49b8e;
        --accent: #d98a5f;
        --accent-text: #1c1a18;
        --danger: #f3897c;
        --danger-bg: #33201d;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    line-height: 1.55;
}

a { color: var(--accent); }

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.site-header .brand {
    font-weight: 600;
    letter-spacing: 0.01em;
    text-decoration: none;
    color: var(--text);
}

.site-header nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.site-header nav a { text-decoration: none; }

main { padding: 2rem 1.25rem; }

.narrow {
    max-width: 26rem;
    margin: 0 auto;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

h1 { font-size: 1.35rem; margin: 0 0 0.35rem; }

.subtitle { color: var(--muted); margin: 0 0 1.25rem; font-size: 0.925rem; }

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.3rem;
}

input[type="text"], input[type="email"], input[type="password"] {
    width: 100%;
    padding: 0.6rem 0.7rem;
    margin-bottom: 1rem;
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
}

input:focus-visible, button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

button {
    width: 100%;
    padding: 0.65rem 1rem;
    font: inherit;
    font-weight: 600;
    color: var(--accent-text);
    background: var(--accent);
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}

button.link {
    width: auto;
    padding: 0;
    color: var(--accent);
    background: none;
    font-weight: 400;
    text-decoration: underline;
}

/*
 * role="alert" so a screen reader announces the failure. A login error that is
 * only visible is invisible to the people most likely to mistype.
 */
.error {
    margin: 0 0 1rem;
    padding: 0.6rem 0.75rem;
    font-size: 0.9rem;
    color: var(--danger);
    background: var(--danger-bg);
    border: 1px solid var(--danger);
    border-radius: 8px;
}

.form-footer {
    margin: 1.1rem 0 0;
    font-size: 0.9rem;
    color: var(--muted);
    text-align: center;
}

/* htmx sets this while a request is in flight. */
form.htmx-request button { opacity: 0.6; pointer-events: none; }

/* --- calendar --- */

.calendar-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 21rem);
    gap: 1.5rem;
    max-width: 62rem;
    margin: 0 auto;
    align-items: start;
}

@media (max-width: 820px) {
    .calendar-layout { grid-template-columns: minmax(0, 1fr); }
}

.month-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.9rem;
}

.month-header h1 { margin: 0; }

.month-nav { display: flex; gap: 0.4rem; }

.month-nav button {
    width: 2.2rem;
    padding: 0.3rem 0;
    line-height: 1;
}

.month-nav button[disabled] {
    opacity: 0.35;
    cursor: not-allowed;
}

.weekday-row, .month-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
}

.weekday-row {
    margin-bottom: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    text-align: center;
}

.day-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0.2rem;
    min-height: 3.6rem;
    padding: 0.35rem 0.2rem;
    font: inherit;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    width: auto;
    font-weight: 400;
}

.day-cell.outside { opacity: 0.4; }

.day-cell.empty {
    background: transparent;
    border-color: transparent;
    cursor: default;
}

.day-cell[disabled] {
    opacity: 0.3;
    cursor: not-allowed;
}

.day-cell.today { border-color: var(--accent); }

.day-cell.selected {
    background: var(--accent);
    color: var(--accent-text);
}

.day-cell .count {
    font-size: 0.7rem;
    color: var(--muted);
}

.day-cell.selected .count { color: inherit; }

/* A booked day is marked with a dot AND the count, never colour alone. */
.day-cell .dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent);
}

.day-cell.selected .dot { background: var(--accent-text); }

.day-cell.full .count { text-decoration: line-through; }

/* --- day panel and class detail --- */

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.panel h2 { font-size: 1.05rem; margin: 0 0 0.2rem; }

.panel .muted { color: var(--muted); font-size: 0.9rem; }

.class-list { list-style: none; margin: 1rem 0 0; padding: 0; }

.class-list li + li { margin-top: 0.5rem; }

.class-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    padding: 0.6rem 0.7rem;
    font: inherit;
    text-align: left;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 400;
}

.class-row .time { font-variant-numeric: tabular-nums; font-weight: 600; }

.class-row .meta { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }

.badge {
    display: inline-block;
    padding: 0.05rem 0.4rem;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 999px;
    border: 1px solid currentColor;
}

.badge.booked { color: var(--accent); }

.badge.cancelled { color: var(--danger); }

.back-link {
    display: inline-block;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    background: none;
    border: 0;
    padding: 0;
    width: auto;
    color: var(--accent);
    text-decoration: underline;
    cursor: pointer;
    font-weight: 400;
}

.detail-facts { margin: 0.75rem 0; padding: 0; list-style: none; font-size: 0.9rem; }

.detail-facts li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.2rem 0; }

.detail-facts .label { color: var(--muted); }

button.secondary {
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
}

/* --- teacher: class management --- */

.wide { max-width: 52rem; margin: 0 auto; }

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

.page-header h1 { margin: 0; }

.page-header button, .inline-actions button { width: auto; }

.template-list { list-style: none; margin: 0; padding: 0; }

.template-list li + li { margin-top: 0.6rem; }

.template-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.85rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.template-card .title { font-weight: 600; }

.template-card .when {
    font-size: 0.85rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.inline-actions { display: flex; gap: 0.4rem; align-items: center; }

.inline-actions button {
    padding: 0.35rem 0.7rem;
    font-size: 0.85rem;
}

.inline-actions form { display: inline; }

button.danger {
    color: var(--danger);
    background: var(--danger-bg);
    border: 1px solid var(--danger);
}

.field-row { display: flex; gap: 0.75rem; }

.field-row > div { flex: 1; min-width: 0; }

select {
    width: 100%;
    padding: 0.6rem 0.7rem;
    margin-bottom: 1rem;
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
}

input[type="number"], input[type="time"], input[type="date"] {
    width: 100%;
    padding: 0.6rem 0.7rem;
    margin-bottom: 1rem;
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.attendees { margin-top: 1.25rem; border-top: 1px solid var(--border); padding-top: 1rem; }

.attendees h3 { font-size: 0.95rem; margin: 0 0 0.5rem; }

.attendees ol { margin: 0; padding-left: 1.2rem; font-size: 0.9rem; }

.attendees li { padding: 0.1rem 0; }

/*
 * A confirmation of something that just happened, not a failure. role="status"
 * rather than "alert": it is announced politely, without interrupting.
 */
.notice {
    margin: 0 0 1rem;
    padding: 0.6rem 0.75rem;
    font-size: 0.9rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: 8px;
}

/*
 * Grey secondary text, anywhere. `.muted` was previously styled only inside
 * `.panel`, so the same class rendered as ordinary body text on the class list
 * and on the subscription rows.
 */
.muted { color: var(--muted); }

/*
 * The class-type pill ("Classical"), on class cards and subscription rows.
 * Named `.chip` in the markup since Phase 7.2 and never styled until now.
 */
.chip {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.05rem 0.45rem;
    font-size: 0.75rem;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 999px;
}

/*
 * The subscription list reuses the class-card shapes; these are the two things
 * it adds. `.balance` is the number a teacher acts on, so it is the one that is
 * emphasised - `remaining` sits beside it in `.muted`, read-only, because it is
 * derived from the calendar and no button can change it.
 */
.balance { font-weight: 600; }

.ledger { margin: 0; padding-left: 1.2rem; font-size: 0.9rem; list-style: none; }

.ledger li { padding: 0.35rem 0; border-bottom: 1px solid var(--border); }

.ledger li:last-child { border-bottom: none; }

.ledger .delta { font-weight: 600; font-variant-numeric: tabular-nums; }

.badge.paid { border-color: var(--accent); }

.badge.owing { border-color: var(--danger); }

/* The active filter on the people list. */
button.selected { border-color: var(--accent); color: var(--accent); }
