/* Medicia - design tokens and shared primitives */
:root {
    --paper: #EEF3F2;
    --surface: #FFFFFF;
    --ink: #10262B;
    --ink-2: #3E555B;
    --muted: #66797F;
    --line: #D5E0DE;
    --line-strong: #B9CBC8;

    --brand: #0B7A69;
    --brand-ink: #075A4D;
    --brand-wash: #DDF0EC;

    --warn: #7A4D00;
    --warn-wash: #FCEFD0;
    --danger: #C23B22;
    --danger-ink: #9A2A15;
    --danger-wash: #FBE3DD;

    --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
    --font-body: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

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

h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.15; letter-spacing: -.015em; }
h1 { font-size: clamp(2rem, 1.4rem + 2vw, 2.9rem); font-weight: 700; letter-spacing: -.03em; }

button, input, select { font: inherit; color: inherit; }
a { color: var(--brand-ink); }

:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, white); outline-offset: 2px; }

button, a, input, select { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

/* lock page scroll (and pull-to-refresh) while a dialog is open */
body:has(.backdrop) { overflow: hidden; }
html:has(.backdrop) { overscroll-behavior: none; }

/* ---------- Page header ---------- */
.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px 24px;
}
.page-head p { margin-top: 8px; max-width: 56ch; color: var(--ink-2); }

.toolbar { display: flex; gap: 12px; margin-top: 28px; }
.search { width: 100%; max-width: 360px; }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(270px, 100%), 1fr));
    gap: 18px;
    margin-top: 24px;
}

.skeleton {
    min-height: 236px;
    border-radius: 20px;
    background: linear-gradient(90deg, #E3EBEA 0%, #EEF3F2 50%, #E3EBEA 100%);
    background-size: 200% 100%;
    animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.load-error {
    margin-top: 40px;
    padding: 28px;
    border-radius: 20px;
    background: var(--danger-wash);
    color: var(--danger-ink);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.load-error strong { display: block; font-family: var(--font-display); font-size: 1.2rem; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 42px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color .12s, border-color .12s, color .12s;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-ink); }

.btn-ghost { border-color: var(--line-strong); background: var(--surface); }
.btn-ghost:hover:not(:disabled) { border-color: var(--ink-2); }

.btn-danger-ghost { color: var(--danger-ink); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--danger-wash); }

.btn.confirming, .btn.confirming:hover:not(:disabled) { background: var(--danger); color: #fff; }

.btn-icon { width: 42px; padding: 0; }
.btn-icon.confirming { width: auto; padding: 0 14px; }

.icon-btn {
    flex: none;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    color: var(--ink-2);
}
.icon-btn:hover { background: #E8EFEE; color: var(--ink); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-weight: 600; font-size: .88rem; color: var(--ink-2); }

.input {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    background: #fff;
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
select.input { appearance: auto; }

/* ---------- Bits ---------- */
.chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}
.chip.ok { background: var(--brand-wash); color: var(--brand-ink); }
.chip.warn { background: var(--warn-wash); color: var(--warn); }
.chip.danger { background: var(--danger-wash); color: var(--danger-ink); }

.muted { color: var(--muted); }
.spacer { flex: 1; }

/* ---------- Blazor chrome ---------- */
.boot { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; color: var(--muted); font-family: var(--font-display); font-size: 1.2rem; }

#blazor-error-ui {
    background: #fff3cd;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, .2);
    display: none;
    left: 0;
    padding: .6rem 1.25rem .7rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

/* ---------- Phones ---------- */
@media (max-width: 640px) {
    h1 { font-size: 1.9rem; }
    .page-head { gap: 16px; }
    .page-head p { font-size: .95rem; }
    .page-head > .btn { width: 100%; height: 48px; }
    .toolbar { margin-top: 20px; }
    .search { max-width: none; }
    .card-grid { gap: 14px; margin-top: 18px; }
    .btn { height: 44px; }
    .btn-icon { width: 44px; }
    .icon-btn { width: 44px; height: 44px; }
    .load-error { padding: 20px; }
    input[type="date"].input { -webkit-appearance: none; appearance: none; min-width: 0; }
}

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