/* ============================================================
   Peer Support Hub
   Design concept: a steady, low-glare console you'd trust at
   3am on a night shift, built around American Ambulance's real
   brand colors from their logo -- navy (#213F97) as the deep
   background, their red (#CA2030) as the one signal color for
   "on duty" / primary actions, a lighter brand-derived blue for
   calm/secondary actions.
   ============================================================ */

:root {
    --ink: #0E1A4A;
    --panel: #16225C;
    --panel-raised: #1E2D70;
    --hairline: #33448C;
    --paper: #F2F4FB;
    --muted: #98A6D6;

    --brand-red: #CA2030;
    --brand-red-ink: #FFFFFF;
    --brand-blue: #6E8FDB;
    --brick: #E2472E;

    --radius-card: 14px;
    --radius-control: 8px;

    --font-display: "Zilla Slab", Georgia, serif;
    --font-body: "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

/* Guarantees anything marked hidden actually disappears, even if it also
   has a class that sets its own display value (like .member-grid's
   display: grid) -- without this, that class can silently win and leave
   a "hidden" element still visible. This bug only shows up in a real
   browser; it's invisible to any test that doesn't render real CSS. */
[hidden] {
    display: none !important;
}

html {
    color-scheme: dark;
}

body {
    margin: 0;
    background: var(--ink);
    color: var(--paper);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: 1.2;
    margin: 0 0 0.5em;
}

h1 { font-size: 1.85rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }

p {
    margin: 0 0 1em;
    max-width: 62ch;
    color: var(--paper);
}

a {
    color: inherit;
}

.skip-link {
    position: absolute;
    left: -999px;
    top: 0;
    background: var(--brand-red);
    color: var(--brand-red-ink);
    padding: 0.75em 1em;
    border-radius: 0 0 var(--radius-control) 0;
    z-index: 100;
}

.skip-link:focus {
    left: 0;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

:focus-visible {
    outline: 2px solid var(--brand-red);
    outline-offset: 2px;
}

/* ---------- Top navigation ---------- */

.topbar {
    border-bottom: 1px solid var(--hairline);
    background: var(--ink);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-inner {
    max-width: 980px;
    margin: 0 auto;
    padding: 0.9rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    text-decoration: none;
    color: var(--paper);
}

.brand-mark {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    object-fit: contain;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-org {
    font-size: 0.72rem;
    color: var(--muted);
}

.brand-product {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.05rem;
}

.topnav {
    display: flex;
    gap: 1.5rem;
}

.topnav a {
    text-decoration: none;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.92rem;
    padding: 0.4rem 0.1rem;
    border-bottom: 2px solid transparent;
}

.topnav a:hover {
    color: var(--paper);
}

.topnav a.active {
    color: var(--paper);
    border-bottom-color: var(--brand-red);
}

/* ---------- Page shell ---------- */

.page {
    max-width: 980px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 7rem;
}

.page-intro {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--hairline);
}

.section {
    margin-bottom: 2.75rem;
}

.section h1, .section h2 {
    margin-bottom: 0.35em;
}

/* ---------- Dashboard hero ---------- */

.status-hero {
    padding: 2.25rem 0 2rem;
    border-bottom: 1px solid var(--hairline);
    margin-bottom: 2.5rem;
}

.status-hero-count {
    display: flex;
    align-items: baseline;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.status-number {
    font-family: var(--font-display);
    font-size: 4.5rem;
    font-weight: 600;
    color: var(--brand-red);
    line-height: 1;
}

.status-label {
    font-size: 1.1rem;
    color: var(--paper);
}

.status-sub {
    color: var(--muted);
    margin-top: 0.6rem;
    margin-bottom: 0;
}

/* ---------- Member cards (dashboard) ---------- */

.member-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

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

.member-card-top {
    display: flex;
    margin-bottom: 0.85rem;
}

.avatar-wrap {
    position: relative;
    display: inline-flex;
}

.avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--panel-raised);
    border: 1px solid var(--hairline);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.4rem;
    color: var(--paper);
    object-fit: cover; /* only matters when this is an <img>, ignored on a <span> */
    flex-shrink: 0;
}

.avatar-sm {
    width: 56px;
    height: 56px;
    font-size: 1.05rem;
    flex-shrink: 0;
}

.duty-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--brand-red);
    box-shadow: 0 0 0 3px rgba(202, 32, 48, 0.18);
    margin-top: 4px;
}

/* On the dashboard's on-duty cards, the dot sits as a badge on the
   avatar's corner instead of floating separately beside it. */
.avatar-wrap .duty-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    margin-top: 0;
    border: 3px solid var(--panel);
    box-shadow: none;
}

.member-name {
    font-size: 1.05rem;
    margin-bottom: 0.15em;
}

.member-role {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 0.85em;
}

.member-actions {
    display: flex;
    gap: 0.6rem;
}

/* ---------- Buttons & links ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.88rem;
    padding: 0.55em 1.1em;
    border-radius: var(--radius-control);
    border: 1px solid transparent;
    cursor: pointer;
}

.btn-primary {
    background: var(--brand-red);
    color: var(--brand-red-ink);
}

.btn-primary:hover {
    background: #EBAE55;
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: transparent;
    border-color: var(--hairline);
    color: var(--paper);
}

.btn-secondary:hover {
    border-color: var(--brand-blue);
    color: var(--brand-blue);
}

.text-link {
    color: var(--brand-blue);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: rgba(110, 143, 219, 0.5);
    text-underline-offset: 3px;
}

/* ---------- Empty state ---------- */

.empty-state {
    background: var(--panel);
    border: 1px dashed var(--hairline);
    border-radius: var(--radius-card);
    padding: 1.5rem;
}

.empty-state p {
    margin-bottom: 0.75em;
}

/* ---------- Quiet section / two-up ---------- */

.quiet-section {
    background: var(--panel);
    border-radius: var(--radius-card);
    padding: 1.75rem;
}

.two-up {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.two-up p {
    margin-bottom: 0;
    color: var(--muted);
}

/* ---------- Team page ---------- */

.self-status-panel {
    background: var(--panel);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-card);
    padding: 1.5rem;
    margin-bottom: 2.5rem;
}

.self-status-hint {
    color: var(--muted);
    font-size: 0.9rem;
}

.self-status-controls {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

select {
    background: var(--panel-raised);
    color: var(--paper);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-control);
    padding: 0.55em 0.8em;
    font-family: var(--font-body);
    font-size: 0.9rem;
    min-width: 200px;
}

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

.roster-row {
    display: flex;
    align-items: flex-start;
    gap: 0.9rem;
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--hairline);
}

.roster-row:last-child {
    border-bottom: none;
}

.roster-main {
    flex: 1;
}

.roster-name {
    margin: 0 0 0.1em;
    font-weight: 600;
}

.roster-meta {
    color: var(--muted);
    font-size: 0.85rem;
    margin-bottom: 0.6em;
}

.duty-status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    padding-top: 0.15rem;
}

.duty-status .duty-dot {
    background: var(--hairline);
    box-shadow: none;
}

.duty-status.is-on .duty-dot {
    background: var(--brand-red);
    box-shadow: 0 0 0 3px rgba(202, 32, 48, 0.18);
}

.duty-status.is-on .duty-text {
    color: var(--brand-red);
}

.duty-status.is-off .duty-text {
    color: var(--muted);
}

/* ---------- Resources page ---------- */

.resource-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

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

.resource-availability {
    color: var(--brand-blue);
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 0.6em;
}

.resource-description {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 1.1em;
}

.resource-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.resource-text-instructions {
    font-size: 0.85rem;
    color: var(--paper);
    background: var(--panel-raised);
    border-radius: var(--radius-control);
    padding: 0.5em 0.8em;
}

/* ---------- Persistent help strip ---------- */

.help-strip {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--panel);
    border-top: 1px solid var(--hairline);
    z-index: 30;
}

.help-strip-inner {
    max-width: 980px;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    overflow-x: auto;
}

.help-strip-label {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--brick);
    white-space: nowrap;
    flex-shrink: 0;
}

.help-strip-items {
    display: flex;
    gap: 0.6rem;
    overflow-x: auto;
}

.help-chip {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    background: var(--panel-raised);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-control);
    padding: 0.4em 0.85em;
    white-space: nowrap;
    flex-shrink: 0;
}

.help-chip:hover {
    border-color: var(--brick);
}

.help-chip-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--paper);
}

.help-chip-detail {
    font-size: 0.75rem;
    color: var(--muted);
}

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

@media (max-width: 600px) {
    .status-number {
        font-size: 3.2rem;
    }

    .topbar-inner {
        padding: 0.75rem 1rem;
    }

    .page {
        padding: 1.75rem 1rem 8rem;
    }

    .two-up {
        align-items: flex-start;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

/* ---------- Blazor-specific additions ---------- */

.initial-loading {
    max-width: 980px;
    margin: 4rem auto;
    padding: 0 1.5rem;
    color: var(--muted);
    font-family: var(--font-display);
    font-size: 1.2rem;
}

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--brick);
    color: var(--paper);
    padding: 0.9rem 1.5rem;
    z-index: 40;
}

#blazor-error-ui .reload {
    color: var(--paper);
    text-decoration: underline;
    margin-left: 0.5rem;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    float: right;
}

/* removed, not needed in the React build */

.loading-text, .help-chip-loading {
    color: var(--muted);
}

.sign-out-btn {
    margin-left: auto;
}

.topbar-inner {
    flex-wrap: nowrap;
}

.login-intro {
    max-width: 480px;
}

.login-form {
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.login-form label {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--muted);
}

.login-form input {
    background: var(--panel);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-control);
    padding: 0.65em 0.85em;
    color: var(--paper);
    font-family: var(--font-body);
    font-size: 0.95rem;
}

.login-error {
    color: var(--brick);
    font-size: 0.88rem;
    max-width: none;
}

/* Blazor's NavLink adds this class automatically on route match. */
.topnav a.active {
    color: var(--paper);
    border-bottom-color: var(--brand-red);
}

/* ---------- Team Admin page ---------- */

.admin-row {
    border-bottom: 1px solid var(--hairline);
    padding: 0.9rem 0;
}

.admin-row:last-child {
    border-bottom: none;
}

.admin-row-summary {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.admin-row-summary .roster-main {
    flex: 1;
}

.admin-edit-panel {
    margin-top: 1rem;
    margin-left: calc(56px + 0.9rem); /* aligns under the name, past the avatar */
    padding: 1rem;
    background: var(--panel);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-card);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.admin-edit-panel label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
}

.admin-edit-panel input[type="text"],
.admin-edit-panel input[type="tel"],
.admin-edit-panel input[type="email"],
.admin-edit-panel input[type="number"],
.admin-edit-panel input:not([type]) {
    background: var(--panel-raised);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-control);
    padding: 0.55em 0.75em;
    color: var(--paper);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 400;
}

.admin-checkbox-label {
    flex-direction: row !important;
    align-items: center;
    gap: 0.5rem !important;
}

.admin-edit-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-top: 0.3rem;
}

.admin-remove-btn {
    margin-left: auto;
    color: var(--brick);
    border-color: var(--brick);
}

@media (max-width: 600px) {
    .admin-edit-panel {
        margin-left: 0;
    }

    .admin-remove-btn {
        margin-left: 0;
    }
}

/* ---------- Duty calendar ---------- */

.cal-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.cal-nav h2 {
    margin: 0;
    min-width: 12ch;
    text-align: center;
}

.cal-weekday-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--muted);
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.5rem;
}

.cal-day {
    background: var(--panel);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-control);
    padding: 0.5rem;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.cal-day-empty {
    background: transparent;
    border: none;
}

.cal-day-today {
    border-color: var(--brand-red);
}

.cal-day-number {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--muted);
}

.cal-day-today .cal-day-number {
    color: var(--brand-red);
}

.cal-day-members {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    flex: 1;
}

.cal-day-members li {
    font-size: 0.78rem;
    color: var(--paper);
    background: var(--panel-raised);
    border-radius: 4px;
    padding: 0.15em 0.4em;
}

.cal-edit-btn {
    align-self: flex-start;
    font-size: 0.75rem;
    padding: 0.3em 0.7em;
}

.cal-edit-checklist {
    list-style: none;
    margin: 0 0 0.5rem;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.5rem;
}

.cal-edit-checklist label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--paper);
}

@media (max-width: 700px) {
    .cal-weekday-row span:nth-child(n) {
        font-size: 0.65rem;
    }

    .cal-day {
        min-height: 64px;
        padding: 0.3rem;
    }

    .cal-day-members li {
        font-size: 0.68rem;
    }

    .cal-edit-btn {
        font-size: 0.68rem;
        padding: 0.25em 0.5em;
    }
}

/* ---------- Dashboard intro/confidentiality banner ---------- */

.intro-banner {
    background: var(--panel);
    border: 1px solid var(--hairline);
    border-left: 3px solid var(--brand-red);
    border-radius: var(--radius-card);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.intro-banner h2 {
    margin-bottom: 0.5em;
}

.intro-banner p {
    color: var(--muted);
    margin-bottom: 1.1em;
}

.intro-toggle-link {
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-body);
    padding: 0;
    display: inline-block;
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
}

/* ---------- Loading skeletons ---------- */

.skeleton {
    background: linear-gradient(90deg, var(--panel-raised) 25%, var(--hairline) 37%, var(--panel-raised) 63%);
    background-size: 400% 100%;
    animation: skeleton-shimmer 1.4s ease infinite;
    border-radius: 4px;
    color: transparent;
}

@keyframes skeleton-shimmer {
    0% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@media (prefers-reduced-motion: reduce) {
    .skeleton {
        animation: none;
    }
}

.skeleton-line {
    height: 0.85rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.skeleton-line:last-child {
    margin-bottom: 0;
}

.skeleton-w-90 { width: 90%; }
.skeleton-w-70 { width: 70%; }
.skeleton-w-60 { width: 60%; }
.skeleton-w-50 { width: 50%; }

.skeleton-btn {
    width: 68px;
    height: 34px;
    border-radius: var(--radius-control);
}

.help-chip-skeleton {
    width: 140px;
    height: 44px;
    border-radius: var(--radius-control);
    flex-shrink: 0;
}

/* ---------- Search inputs ---------- */

.search-input {
    display: block;
    width: 100%;
    max-width: 360px;
    background: var(--panel);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-control);
    padding: 0.6em 0.9em;
    color: var(--paper);
    font-family: var(--font-body);
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
}

.search-input::placeholder {
    color: var(--muted);
}

/* ---------- QR code page ---------- */

.qr-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    background: var(--panel);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-card);
    padding: 2rem;
    max-width: 360px;
    margin-bottom: 1.5rem;
}

.qr-display canvas {
    background: #FFFFFF;
    border-radius: 8px;
    padding: 12px;
}

.qr-url-label {
    font-size: 0.8rem;
    color: var(--muted);
    word-break: break-all;
    text-align: center;
    margin: 0;
}

@media print {
    .no-print {
        display: none !important;
    }

    body {
        background: #FFFFFF;
    }

    .qr-display {
        background: #FFFFFF;
        border: none;
        box-shadow: none;
        margin: 0 auto;
    }

    .qr-url-label {
        color: #000000;
    }
}
