/* Shared styles. Mobile and desktop both have to work; see CLAUDE.md. */

*, *::before, *::after { box-sizing: border-box; }

:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --text: #1d2330;
    --muted: #5d6677;
    --border: #d9dde4;
    --accent: #1f5fae;
    --accent-dark: #174a88;
    --success-bg: #e6f4ea;
    --success-text: #1e6b34;
    --error-bg: #fdecea;
    --error-text: #a3261c;
}

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

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

h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 0.75rem; }

.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
}

.muted { color: var(--muted); font-size: 0.9rem; }
.nowrap { white-space: nowrap; }

/* ---- Public landing ---- */

.landing-main {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    text-align: center;
}

/* ---- Admin bar ---- */

.admin-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.admin-bar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1.5rem;
}

.admin-bar .brand {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
}

/* The logo has a transparent background, gold letters and black outlines. */
.brand-logo,
.landing-logo {
    height: auto;
    display: block;
}

.brand-logo { height: 32px; width: auto; }

.landing-logo {
    width: min(322px, 80vw);
    margin: 0 auto 1rem;
}

.landing h1 { color: var(--muted); font-weight: 600; }

.admin-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 1rem;
}

.admin-nav a,
.admin-nav .link-button {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.95rem;
}

.admin-nav a:hover,
.admin-nav .link-button:hover { color: var(--accent); }

.inline-form { display: inline; margin: 0; }

.link-button {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    cursor: pointer;
}

/* ---- Cards, forms ---- */

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

.card.narrow { max-width: 440px; margin: 1rem auto; }
.card + .card { margin-top: 1.25rem; }
.card h2:first-child { margin-top: 0; }

.datatable-card { padding: 1rem; }
.datatable-card table { width: 100% !important; }

.section-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin-top: 2rem;
}

.section-heading h2 { margin: 0; }

.row-inactive td { color: var(--muted); }

/* Links and buttons that look like buttons */
.button,
button.secondary {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.button {
    background: var(--accent);
    color: #fff;
    border: 0;
}

.button:hover { background: var(--accent-dark); }

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

button.secondary:hover { background: #eef3fa; }

.cancel-link { margin-left: 1rem; }

/* User form */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0 1.25rem;
}

fieldset {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem 0.5rem;
    margin: 1.25rem 0 0;
}

legend { font-weight: 600; padding: 0 0.35rem; }

label.choice {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 400;
    margin: 0.5rem 1.5rem 0 0;
}

label.choice + .muted,
fieldset > .muted { margin: 0.2rem 0 0.5rem; }

.field-error {
    color: var(--error-text);
    font-size: 0.9rem;
    margin: 0.25rem 0 0;
}

.copy-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.copy-row input { flex: 1 1 280px; font-family: ui-monospace, Consolas, monospace; font-size: 0.9rem; }

label {
    display: block;
    font-weight: 600;
    margin: 0.75rem 0 0.25rem;
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="tel"],
select {
    width: 100%;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    background: #fff;
}

button[type="submit"]:not(.link-button):not(.secondary) {
    margin-top: 1rem;
    padding: 0.6rem 1.2rem;
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

button[type="submit"]:not(.link-button):not(.secondary):hover { background: var(--accent-dark); }

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.filters label { margin: 0; font-weight: 600; }
.filters select { width: auto; min-width: 10rem; display: block; margin-top: 0.25rem; }
.filters button[type="submit"] { margin-top: 0; }
button.secondary { margin-top: 0.5rem; }

/* ---- Messages ---- */

.flash {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.flash-success { background: var(--success-bg); color: var(--success-text); }
.flash-error { background: var(--error-bg); color: var(--error-text); }
.error-text { color: var(--error-text); }

/* ---- Tables ---- */

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

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

th, td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--border);
}

th { background: #eef1f5; font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }

.badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-sent { background: var(--success-bg); color: var(--success-text); }
.badge-failed { background: var(--error-bg); color: var(--error-text); }
.badge-admin { background: #e8eefb; color: var(--accent-dark); margin-left: 0.35rem; }
.badge-muted { background: #eceef2; color: var(--muted); }
.badge-toggle { background: #fff4e0; color: #8a5300; margin: 0 0.25rem 0.15rem 0; }

[hidden] { display: none !important; }

.pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

/* ---- Details, tiles ---- */

.details {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.4rem 1.25rem;
    margin: 0;
}

.details dt { font-weight: 600; }
.details dd { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 560px) {
    .details { grid-template-columns: 1fr; }
    .details dd { margin-bottom: 0.5rem; }
}

.email-body {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    font: 0.95rem/1.5 ui-monospace, Consolas, monospace;
}

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.tile {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
}

.tile:hover { border-color: var(--accent); }
.tile-value { font-size: 2rem; font-weight: 700; }
.tile-label { color: var(--muted); }
.tile-alert .tile-value { color: var(--error-text); }

/* ---- User portal (phone-first) ---- */

.portal-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.portal-bar-inner {
    max-width: 640px;
    margin: 0 auto;
    padding: 0.75rem 1rem;
}

.portal-bar .brand {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
}

.portal-main {
    max-width: 640px;
    margin: 0 auto;
    padding: 1.25rem 1rem 2rem;
}

.portal-main section + section { margin-top: 1.75rem; }

.portal-footer {
    max-width: 640px;
    margin: 0 auto;
    padding: 1rem 1rem 2rem;
    border-top: 1px solid var(--border);
}

.portal-footer form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.portal-footer .link-button { color: var(--accent); }

.all-done {
    background: var(--success-bg);
    color: var(--success-text);
    padding: 1rem;
    border-radius: 8px;
    margin: 0;
}

.todo-list,
.history-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.75rem;
}

.todo-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    padding: 1rem;
}

/* Big, easy-to-tap buttons. Full width on phones. */
.button-large,
button.button-large {
    padding: 0.8rem 1.5rem;
    font-size: 1.05rem;
    text-align: center;
}

@media (max-width: 480px) {
    .todo-item .button-large,
    form .button-large { width: 100%; }
}

.history-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
}

.history-missed { background: #fbfbfc; }

.history-heading {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.25rem 0.75rem;
}

.history-item details { margin-top: 0.4rem; }
.history-item summary { cursor: pointer; color: var(--accent); font-size: 0.95rem; }

.submission-body {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    background: var(--bg);
    border-radius: 6px;
    padding: 0.75rem;
    margin: 0.5rem 0 0;
}

.badge-late { background: #fff4e0; color: #8a5300; }

textarea {
    width: 100%;
    padding: 0.7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    resize: vertical;
    min-height: 10rem;
}

.counter { text-align: right; margin: 0.25rem 0 0; }

/* ---- Dashboard catch-up status ---- */

.tile-of { font-size: 1rem; font-weight: 600; color: var(--muted); }

.filter-note {
    background: #e8eefb;
    color: var(--accent-dark);
}

.missed-list {
    margin: 0.5rem 0 0;
    padding-left: 1.25rem;
}

/* ---- Admin user page ---- */

.user-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
}

.user-heading h1 { margin: 0; }
.user-heading + .muted { margin-top: 0.35rem; }

.badge-big { font-size: 0.9rem; padding: 0.2rem 0.7rem; }

.history-actions {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.button-outline {
    display: inline-block;
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: var(--surface);
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}

.button-outline:hover { background: #eef3fa; }

.button-small {
    padding: 0.2rem 0.7rem;
    font-size: 0.85rem;
}

/* Submissions column: two equal slots so Safety and Toolbox badges line up. */
.toggle-slots {
    display: inline-grid;
    grid-template-columns: 4.75rem 4.75rem;
    gap: 0.35rem;
}

.toggle-slots .badge {
    display: block;
    margin: 0;
    text-align: center;
}

/* ---- Toolbox Talks ---- */

/* Talk page image in the portal: full width of the card, keeps its shape. */
.talk-image-wrap { margin: 0.75rem 0; }

.talk-image {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fff;
}

.talk-title { margin: 0.5rem 0 0.25rem; font-size: 1.1rem; }

.history-meta { margin: 0.4rem 0 0; font-size: 0.95rem; color: var(--muted); }

/* Admin schedule */
.schedule-table td { vertical-align: middle; }
.row-current td { background: #f1f8f3; }
.row-past td { color: var(--muted); }
.talk-links { font-size: 0.85rem; }

.inline-row {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    margin: 0 0.5rem 0 0;
}

.inline-row input[type="date"] {
    padding: 0.25rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    font-size: 0.9rem;
}

.link-danger { color: var(--error-text); font-size: 0.9rem; }

.plain-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.6rem;
}

.plain-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem 1rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--border);
}

.plain-list li:last-child { border-bottom: 0; padding-bottom: 0; }

input[type="file"],
input[type="number"],
input[type="date"]:not(.inline-row input) {
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    background: #fff;
}

/* Toolbox Talk pages: wider on big screens so the talk page reads at about
   960 px without browser zoom. Phones are narrower than either width, so they
   don't change. */
.portal-wide .portal-bar-inner,
.portal-wide .portal-main,
.portal-wide .portal-footer {
    max-width: 1040px;
}

/* ---- Version footer, DEV badge, version history ---- */

.admin-footer {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem 1.5rem;
    font-size: 0.8rem;
}

.admin-footer a { color: var(--muted); text-decoration: none; }
.admin-footer a:hover { color: var(--accent); text-decoration: underline; }

/* Shown only when APP_ENV=development, so dev and production can't be confused. */
.badge-env {
    background: #e8590c;
    color: #fff;
    letter-spacing: 0.05em;
}

.version-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.version-list > li { border-bottom: 1px solid var(--border); padding-bottom: 1rem; }
.version-list > li:last-child { border-bottom: 0; padding-bottom: 0; }
.version-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.6rem; }
.version-list ul { margin: 0.4rem 0 0; padding-left: 1.25rem; }

/* ---- Injury log ---- */

/* Date on the left, the note taking the rest of the row; stacked on phones. */
.injury-fields {
    display: grid;
    grid-template-columns: minmax(10rem, 12rem) 1fr;
    gap: 0 1.25rem;
}

@media (max-width: 560px) {
    .injury-fields { grid-template-columns: 1fr; }
}

/* ---- Portal: "It's been N days since our last injury" ----
   Calm and encouraging, not an alarm: soft green, a thin darker edge,
   the number large. Count only, no details or links, by design. */
.injury-free {
    margin: 0 0 1.25rem;
    padding: 0.9rem 1.1rem;
    background: var(--success-bg);
    color: var(--success-text);
    border-left: 5px solid var(--success-text);
    border-radius: 8px;
    font-size: 1.05rem;
    line-height: 1.4;
}

.injury-free strong {
    font-size: 1.6rem;
    font-weight: 700;
    white-space: nowrap;
}

/* Email log: "Emails sent today" nearing the Brevo plan's daily cap. Dashboard: email warning line. */
.tile-warn .tile-value { color: #b35c00; }
.scheduler-status { margin-top: 0.25rem; }
.email-warning { color: #b35c00; font-weight: 600; }

/* Admin: last email + live delivery status (user-edit.php), email log heading button. */
.last-email { margin: 0.25rem 0 1rem; font-size: 0.95rem; }
.last-email .link-button { color: var(--accent); margin-left: 0.35rem; font-size: 0.9rem; }
.email-log-heading { margin-top: 0; }
.email-log-heading h1 { margin: 0; }
