/* HMC Teachers - phone-first, compact. HMC blue is the same as the website. */

:root {
    --hmc-blue: #082766;
    --hmc-blue-light: #355dae;
    --text: #212529;
    --muted: #6c757d;
    --border: #dee2e6;
    --page: #f4f6fa;

    --charged: #d4edda;        /* outcome 1: lesson given, charged */
    --charged-edge: #2e8540;
    --absent: #fff3cd;         /* outcome 2: didn't attend, charged anyway */
    --absent-edge: #c79100;
    --goodwill: #d6e4f7;       /* outcome 3: lesson given, no charge */
    --goodwill-edge: #355dae;
    --nolesson: #ffffff;       /* outcome 4 (default) */
    --nolesson-edge: #ced4da;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--page);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 16px;
}

.hidden { display: none !important; }

/* ---- Header ---- */

.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    padding-top: calc(8px + env(safe-area-inset-top));
    background: var(--hmc-blue);
    color: #fff;
}

.app-logo {
    height: 40px;
    width: 40px;
    border-radius: 8px;
    background: #fff;       /* the logo is black line art on white */
    padding: 2px;
}

.app-name { font-size: 16px; font-weight: 600; line-height: 1.1; white-space: nowrap; }
.app-user { font-size: 13px; opacity: 0.85; }

/* ---- Day / Term switch in the header ---- */

.view-switch { margin-left: auto; display: flex; gap: 3px; }

.view-switch button {
    border: 1px solid rgba(255, 255, 255, 0.6);
    background: transparent;
    color: #fff;
    border-radius: 14px;
    padding: 4px 8px;
    font-size: 13px;
    cursor: pointer;
}

.view-switch button.active { background: #fff; color: var(--hmc-blue); font-weight: 600; }

/* ---- Screens ---- */

.screen {
    max-width: 560px;
    margin: 0 auto;
    padding: 12px 16px 96px;
}

h2 { margin: 8px 0 2px; font-size: 20px; color: var(--hmc-blue); }
.subtitle { color: var(--muted); font-size: 14px; margin-bottom: 12px; }

/* ---- Day bar ---- */

.day-bar { display: flex; gap: 8px; margin-bottom: 10px; align-items: center; }
.day-bar select, .day-bar input { min-width: 0; }
.day-term { flex: 0 0 auto; font-size: 18px; font-weight: 600; color: var(--hmc-blue); text-align: right; white-space: nowrap; }
/* While the other-date picker is showing there is no room for the term beside it */
.day-bar:has(#otherDate:not(.hidden)) .day-term { display: none; }

select, input[type="date"], input[type="time"], input[type="number"], input[type="search"], textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: 16px;      /* 16px stops iOS zooming into the field */
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font-family: inherit;
}

#daySelect { font-weight: 600; color: var(--hmc-blue); }

.notice {
    background: #e8eefb;
    border-left: 4px solid var(--hmc-blue-light);
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 10px;
    font-size: 14px;
}

/* ---- Time headings and pupil blocks ---- */

.time-heading {
    margin: 14px 0 6px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.pupil-block {
    display: block;
    width: 100%;
    text-align: left;
    margin-bottom: 8px;
    padding: 10px 12px;
    border: 1px solid var(--nolesson-edge);
    border-left-width: 6px;
    border-radius: 8px;
    background: var(--nolesson);
    color: var(--text);
    font: inherit;
    cursor: pointer;
}

.pupil-block:active { filter: brightness(0.96); }

.pupil-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pupil-name { font-weight: 600; }
.pupil-status { font-size: 13px; color: var(--muted); white-space: nowrap; }
.pupil-detail { font-size: 13px; color: var(--muted); margin-top: 2px; }
.pupil-note { font-size: 13px; margin-top: 4px; font-style: italic; }

/* The two status icons: lesson given (tick/cross) and charged (pound / struck-through pound) */
.icons { display: inline-flex; gap: 3px; vertical-align: middle; }

.icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
}

/* Entries not yet marked: the default outcome, shown pale */
.icons-default { opacity: 0.4; }

.icon-lesson-yes { background: var(--charged-edge); color: #fff; }
.icon-lesson-no  { background: #adb5bd; color: #fff; }
.icon-charge-yes { background: var(--hmc-blue); color: #fff; }
.icon-charge-no  { position: relative; background: #fff; color: #495057; border: 1px solid #adb5bd; }

/* A diagonal line through the pound sign, top left to bottom right */
.icon-charge-no::after {
    content: "";
    position: absolute;
    width: 1.5px;
    height: 125%;
    background: #c0392b;
    transform: rotate(-45deg);
}

.badge {
    display: inline-block;
    margin-left: 6px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--hmc-blue-light);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    vertical-align: middle;
}

.badge-extra { background: #c25e00; }

.outcome-1 { background: var(--charged);  border-color: var(--charged-edge); }
.outcome-2 { background: var(--absent);   border-color: var(--absent-edge); }
.outcome-3 { background: var(--goodwill); border-color: var(--goodwill-edge); }
.outcome-4 { background: var(--nolesson); border-color: var(--nolesson-edge); }

.day-total {
    margin-top: 14px;
    padding: 10px 12px;
    border-top: 2px solid var(--hmc-blue);
    font-weight: 600;
    color: var(--hmc-blue);
    display: flex;
    justify-content: space-between;
}

.add-button {
    display: block;
    width: 100%;
    margin-top: 16px;
    padding: 12px;
    border: 2px dashed var(--hmc-blue-light);
    border-radius: 8px;
    background: transparent;
    color: var(--hmc-blue);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

/* ---- Lesson (pupil) screen ---- */

.back-button {
    border: 0;
    background: none;
    padding: 6px 0;
    font-size: 17px;
    color: var(--hmc-blue-light);
    cursor: pointer;
}

.option {
    display: block;
    width: 100%;
    text-align: left;
    margin-bottom: 8px;
    padding: 12px;
    border: 1px solid var(--border);
    border-left-width: 6px;
    border-radius: 8px;
    font: inherit;
    color: var(--text);
    cursor: pointer;
}

.option.option-1 { background: var(--charged);  border-left-color: var(--charged-edge); }
.option.option-2 { background: var(--absent);   border-left-color: var(--absent-edge); }
.option.option-3 { background: var(--goodwill); border-left-color: var(--goodwill-edge); }
.option.option-4 { background: var(--nolesson); border-left-color: var(--nolesson-edge); }

.option.chosen { outline: 3px solid var(--hmc-blue); }

.option { position: relative; }
.option-icons { position: absolute; top: 12px; right: 12px; }
.option-title { display: block; font-weight: 600; padding-right: 56px; }
.option-help { display: block; font-size: 13px; color: #495057; margin-top: 2px; }

.note-label { display: block; margin: 14px 0 4px; font-size: 14px; color: var(--muted); }

/* ---- Add pupil screen ---- */

.add-row {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    margin-top: 6px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    font: inherit;
    color: var(--text);
    cursor: pointer;
}

.add-row small { color: var(--muted); }

.primary-button {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 12px;
    border: 0;
    border-radius: 8px;
    background: var(--hmc-blue);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

/* ---- Emailing families ---- */

#emailDay { margin-bottom: 10px; font-weight: 600; color: var(--hmc-blue); }
.email-options { display: flex; justify-content: space-between; }
.email-all { display: flex; align-items: center; gap: 10px; padding: 4px 12px 2px; font-weight: 600; color: var(--hmc-blue); }

.email-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}
.email-row input, .email-all input { width: 20px; height: 20px; margin: 0; flex: 0 0 auto; }
.email-row.no-email { opacity: 0.55; cursor: default; }
.email-text { min-width: 0; }
.email-names { font-weight: 600; }
.email-detail { font-size: 13px; color: var(--muted); }

/* The button stays in view at the bottom of the screen however long the list is */
#emailSendButton { position: sticky; bottom: calc(12px + env(safe-area-inset-bottom)); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25); }
#emailSendButton:disabled { background: #adb5bd; cursor: default; }

/* ---- The term grid ---- */

.screen-wide { max-width: none; padding-left: 8px; padding-right: 8px; }

.term-title { font-weight: 600; color: var(--hmc-blue); margin: 4px 0; }

/* The holiday is laid out like the term grid: a row for each lesson with the name, the date and the dot of its record; the term follows it */
.holiday-wrap { margin-bottom: 14px; }
.holiday-table tbody tr { cursor: pointer; }
.term-table .date-col { text-align: left; color: var(--muted); padding: 4px 8px 4px 6px; }

.term-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--border); border-radius: 8px; }

/* The table is only as wide as its columns need, so the weeks sit close together; it scrolls sideways if the screen is narrower */
.term-table { border-collapse: separate; border-spacing: 0; font-size: 14px; width: auto; }

.term-table th, .term-table td { padding: 4px 2px; text-align: center; white-space: nowrap; border-bottom: 1px solid #eef0f3; }

.term-table thead th { background: #f4f6fa; color: #495057; font-weight: 700; font-size: 14px; }
.term-table thead th.outside { color: #c25e00; }
.term-table .current { background: #e8eefb; }

.term-table .name-col {
    position: sticky;
    left: 0;
    z-index: 1;
    background: #fff;
    text-align: left;
    min-width: 120px;
    padding-left: 8px;
    padding-right: 6px;
    border-right: 1px solid var(--border);
}

.term-table thead .name-col { background: #f4f6fa; }
.term-table .pupil-tag { color: var(--muted); font-size: 11px; font-weight: 700; margin-left: 4px; }

.term-table .time-col { color: var(--muted); padding: 4px 6px; }

.term-table .day-row td { background: #f4f6fa; text-align: left; font-weight: 700; color: var(--hmc-blue); padding: 3px 8px; }

/* Every week the same width, whatever is in it: the heading, the dot and the total under it all fit in 36px */
.term-table .cell { width: 36px; min-width: 36px; max-width: 36px; padding-left: 0; padding-right: 0; cursor: default; }
.term-table tfoot .cell { font-size: 11px; }
.term-table .cell.has-detail { cursor: pointer; }

.term-table .hours-col { font-weight: 700; min-width: 54px; padding: 4px 6px; }

.term-table tfoot td { font-weight: 700; background: #f4f6fa; border-top: 2px solid var(--hmc-blue); }
.term-table tfoot .name-col { background: #f4f6fa; }

.dot {
    display: inline-block;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.35);
    vertical-align: middle;
    margin: 0 1px;
}

.dot-1 { background: #2e8540; }
.dot-2 { background: #f0b400; }
.dot-3 { background: #355dae; }
.dot-4 { background: #fff; }
.dot-blank { border-color: transparent; }
/* A + in the top right corner: the dot stands for more than one lesson */
.dot-plus { position: relative; }
.dot-plus::after {
    content: "+";
    position: absolute;
    top: -10px;
    right: -9px;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    color: #c25e00;
}

.term-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.term-legend .dot-plus { margin-right: 8px; }

/* ---- The detail behind a cell ---- */

.sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.sheet { background: #fff; width: 100%; max-width: 560px; border-radius: 12px 12px 0 0; padding: 14px 16px 18px; }
.sheet h3 { margin: 0 0 8px; color: var(--hmc-blue); font-size: 17px; }
.sheet .line { padding: 6px 0; border-top: 1px solid #eef0f3; font-size: 14px; }
.sheet .line small { color: var(--muted); display: block; }


/* The day's name in the pinned first column of a day heading, and names that can be tapped for contact details */
.term-table .day-row .name-col { background: #f4f6fa; font-weight: 700; color: var(--hmc-blue); }
.term-table tbody .name-col.has-contact { cursor: pointer; }
.sheet a { color: var(--hmc-blue-light); font-weight: 600; }

/* The contact details in the pop-up: labels in one column, values lined up in the next */
.contact-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.contact-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 7px 14px 7px 0; border-top: 1px solid #eef0f3; white-space: nowrap; vertical-align: top; width: 1%; }
.contact-table td { padding: 7px 0; border-top: 1px solid #eef0f3; word-break: break-word; }

/* The duration drop-down, with a box beside it for typing a length that is not on the list */
.duration-row { display: flex; gap: 8px; align-items: center; }
.duration-row select { flex: 1; }
.duration-row input[type="number"] { width: 110px; flex: none; }

.sheet .line .dot { margin: 0 6px 2px 2px; }

/* Delete is a plain grey button with no icon, so it is not mistaken for one of the four kinds of lesson */
.delete-button {
    display: block;
    width: 100%;
    margin-top: 18px;
    padding: 12px;
    border: 0;
    border-radius: 8px;
    background: #e9ecef;
    color: #495057;
    font-size: 15px;
    cursor: pointer;
}

.day-filter { margin-bottom: 10px; }

/* A search box with a round x at its right-hand end, for clearing it */
.clearable { position: relative; }
.clearable input { padding-right: 42px; }

.clear-button {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: #dee2e6;
    color: #495057;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

/* Our own x replaces the browser's, so there are never two */
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }

/* Confirming an extra took place: green, like a lesson given and charged */
.confirm-button { background: var(--charged-edge); }

/* A number inside a green circle (several single-event extras in one week), and hours in an extra's week */
.dot-count-green { font-size: 10px; font-weight: 700; line-height: 14px; text-align: center; color: #fff; vertical-align: middle; }
.extra-hours { font-weight: 700; font-size: 11px; color: var(--extra); }

/* Other work (supervising, accompanying...) is orange, to tell it from lessons */
:root { --extra: #e07400; --extra-bg: #fcebd8; }

.dot-teacher-extra { background: var(--extra); }

.pupil-block.extra-block { border-left-color: var(--extra); }
.pupil-block.extra-done { background: var(--extra-bg); border-color: var(--extra); }
.icon-extra-yes { background: var(--extra); color: #fff; }
.confirm-button { background: var(--extra); }
