html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

h1:focus {
    outline: none;
}

/* Links follow the active theme's link colour (set per data-bs-theme below) so they keep
   good contrast in dark / sandy / water modes instead of a single hardcoded blue. */

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.content {
    padding-top: 1.1rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1M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cuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto 0 auto;
}

    .loading-progress circle {
        fill: none;
        stroke: #e0e0e0;
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: #1b6ec2;
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

code {
    color: #c02d76;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}
/* a11y: skip-to-content link, visible on keyboard focus */
.skip-link { position: absolute; left: -999px; top: 0; z-index: 1100; background: #0d6efd; color: #fff; padding: .5rem 1rem; }
.skip-link:focus { left: 0; }
/* Navbar adapts to the active theme: a light bar (dark text/clock) in light themes, a dark bar
   (light text/clock) in dark themes — using the theme's own surface + border colours. */
.bg-navbar {
    background-color: var(--bs-secondary-bg) !important;
    border-bottom: 1px solid var(--bs-border-color);
}

/* ── Color themes ──────────────────────────────────────────────────────────
   light + dark are Bootstrap 5.3 native (set as the data-bs-theme BASE). The custom
   themes retint the page via data-et-theme overlays over that base:
     light base : sandy, water, forest, solar, magma
     dark  base : oak (a deliberately darker, wood-toned dark mode)
   Smooth transition between themes. */
html { transition: background-color .25s ease, color .25s ease; }

[data-et-theme="sandy"] {
    --bs-body-bg: #faf6ee;
    --bs-body-color: #44382a;
    --bs-emphasis-color: #271e14;
    --bs-secondary-color: #7a6a55;
    --bs-secondary-bg: #f3ead9;
    --bs-tertiary-bg: #efe4cf;
    --bs-border-color: #e2d7c2;
    --bs-heading-color: #3a2f22;
    --bs-link-color: #b45309;
    --bs-link-hover-color: #92400e;
    --bs-link-color-rgb: 180, 83, 9;
}
[data-et-theme="sandy"] .card { background-color: #fffdf8; }

[data-et-theme="water"] {
    --bs-body-bg: #f0f9ff;
    --bs-body-color: #0c3a52;
    --bs-emphasis-color: #062c40;
    --bs-secondary-color: #4a6675;   /* darkened so muted text clears WCAG AA on the light card bg */
    --bs-secondary-bg: #e0f2fe;
    --bs-tertiary-bg: #d4ecfb;
    --bs-border-color: #cfe6f5;
    --bs-heading-color: #0c4a6e;
    --bs-link-color: #0e7490;
    --bs-link-hover-color: #0c5e74;
    --bs-link-color-rgb: 14, 116, 144;
}
[data-et-theme="water"] .card { background-color: #f8fdff; }

[data-et-theme="forest"] {
    --bs-body-bg: #f4f8f4;
    --bs-body-color: #1f3a2e;
    --bs-emphasis-color: #14271d;
    --bs-secondary-color: #41614e;   /* dark muted green — clears WCAG AA on the light card bg */
    --bs-secondary-bg: #e3eee3;
    --bs-tertiary-bg: #d7e7d7;
    --bs-border-color: #cfe0cf;
    --bs-heading-color: #14532d;
    --bs-link-color: #047857;
    --bs-link-hover-color: #065f46;
    --bs-link-color-rgb: 4, 120, 87;
}
[data-et-theme="forest"] .card { background-color: #f9fcf8; }

/* Solar — soft yellow (light base) */
[data-et-theme="solar"] {
    --bs-body-bg: #fdfbed;
    --bs-body-color: #4a4310;
    --bs-emphasis-color: #2e2a08;
    --bs-secondary-color: #6b6020;   /* dark muted gold — clears WCAG AA on the light card bg */
    --bs-secondary-bg: #f7f0cf;
    --bs-tertiary-bg: #f2e9bf;
    --bs-border-color: #e9dfb0;
    --bs-heading-color: #5c4d04;
    --bs-link-color: #7a6108;
    --bs-link-hover-color: #5e4b06;
    --bs-link-color-rgb: 122, 97, 8;
}
[data-et-theme="solar"] .card { background-color: #fffdf3; }

/* Magma — soft red (light base) */
[data-et-theme="magma"] {
    --bs-body-bg: #fdf3f1;
    --bs-body-color: #5a1f17;
    --bs-emphasis-color: #3c130d;
    --bs-secondary-color: #9c4a3f;   /* dark muted red — clears WCAG AA on the light card bg */
    --bs-secondary-bg: #fbddd7;
    --bs-tertiary-bg: #f8cfc7;
    --bs-border-color: #f0cfc8;
    --bs-heading-color: #7a241a;
    --bs-link-color: #b91c1c;
    --bs-link-hover-color: #991b1b;
    --bs-link-color-rgb: 185, 28, 28;
}
[data-et-theme="magma"] .card { background-color: #fffaf9; }

/* Oak — deliberately darker, warm wood-toned DARK mode (dark base) */
[data-et-theme="oak"] {
    --bs-body-bg: #1a1410;
    --bs-body-color: #e8ddcf;
    --bs-emphasis-color: #fbf3e7;
    --bs-secondary-color: #b9a890;
    --bs-secondary-bg: #2a211a;
    --bs-tertiary-bg: #332820;
    --bs-border-color: #3d3025;
    --bs-heading-color: #f0e6d6;
    --bs-link-color: #d9a441;
    --bs-link-hover-color: #e6b85c;
    --bs-link-color-rgb: 217, 164, 65;
}
[data-et-theme="oak"] .card { background-color: #241c16; }

/* Bootstrap's btn-outline-secondary label is a fixed grey (#6c757d) that drops below WCAG AA
   contrast on dark / sandy / water backgrounds. Use the theme's body colour for the label so it
   stays readable in every theme (the neutral border is unchanged; hover still fills grey). */
.btn-outline-secondary { --bs-btn-color: var(--bs-body-color); }

/* small colour dot used by the theme switcher */
.theme-dot {
    display: inline-block;
    width: .8rem; height: .8rem;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,.2);
    vertical-align: -1px;
    margin-right: .35rem;
}
/* full-viewport invisible catcher so clicking outside closes the theme menu (no JS needed) */
.theme-backdrop { position: fixed; inset: 0; z-index: 1040; }

/* a11y: ensure interactive targets meet 44x44px (NFR-A11Y-005). Buttons AND text inputs/selects share
   the same 44px floor so controls sitting together (e.g. a search box next to a sort dropdown and its
   buttons) line up at one height instead of the ~31px (-sm) vs 44px (button) mismatch. Single-line
   inputs/selects vertically-center their text, so the taller box reads as a roomy control, not a gap. */
.btn { min-height: 44px; }
.form-control, .form-select { min-height: 44px; }
/* multi-line textareas grow naturally and shouldn't be pinned to a one-line height */
textarea.form-control { min-height: calc(1.5em + 0.75rem + 2px); }
/* Anchor-buttons (<a class="btn">) must hug their text instead of stretching to the
   container width, and center their label within the 44px min-height. (w-100 still wins.) */
a.btn { display: inline-flex; align-items: center; justify-content: center; }

/* Drag-to-reorder handle (program days + day-exercises). touch-action:none lets SortableJS
   own the gesture on touch devices so a press-drag reorders instead of scrolling. */
.drag-handle { cursor: grab; touch-action: none; color: var(--bs-secondary-color, #888); user-select: none; }
.drag-handle:active { cursor: grabbing; }
.sortable-ghost { opacity: .5; }
.sortable-chosen { background: var(--bs-tertiary-bg, #f0f0f0); }

/* Responsive "stack to cards" for read-only data tables on narrow screens (< lg / 992px).
   Add class `table-stack-lg` to the <table> and `data-label="…"` to each <td>; below lg the
   header row is hidden and each row renders as a bordered card with label→value rows. Above lg the
   table is unchanged. Used by the admin Audit log and Notifications "Sent & scheduled" lists so
   their wider columns don't overflow the viewport on a phone. */
@media (max-width: 991.98px) {
    table.table-stack-lg thead { display: none; }
    table.table-stack-lg, table.table-stack-lg tbody { display: block; width: 100%; }
    table.table-stack-lg tr {
        display: block;
        border: 1px solid var(--bs-border-color, #dee2e6);
        border-radius: .5rem;
        padding: .5rem .75rem;
        margin-bottom: .6rem;
    }
    table.table-stack-lg td {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 1rem;
        border: none;
        padding: .25rem 0;
        text-align: right;
    }
    table.table-stack-lg td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--bs-secondary-color, #6c757d);
        text-align: left;
        white-space: nowrap;
    }
    /* cells with no label (e.g. an actions cell) span full width and align normally */
    table.table-stack-lg td[data-label=""] { justify-content: flex-end; }
    table.table-stack-lg td[data-label=""]::before { content: none; }
}
