/* Tendthrive shared styles — "Refined clinical" (Option A).
   Component-specific rules live in scoped .razor.css files; only app-wide
   tokens and primitives belong here. System fonts, no images, no JS. */

:root {
    --ink: #0b1220;
    --ink-2: #4b5563;
    --ink-3: #8a93a1;
    --surface: #f6f7f9;
    --card: #ffffff;
    --line: #e5e8ec;
    --line-soft: #f0f2f5;
    --brand: #2a78d6;
    --brand-ink: #1c5cab;
    --good: #008300;
    --good-bg: #e7f4e7;
    --warn: #b45309;
    --warn-bg: #fff4e0;
    --bad: #c22f2e;
    --bad-bg: #fdecec;
    --ai: #4a3aa7;
    --ai-bg: #eef2ff;
    --sidebar: #0f1b2d;
    --sidebar-ink: #c7d2e0;
    --radius: 12px;
}

html, body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    margin: 0;
    background-color: var(--surface);
    color: var(--ink);
}

h1 { font-size: 1.25rem; letter-spacing: -0.02em; margin: 0.25rem 0 1rem; }
h1:focus { outline: none; } /* FocusOnNavigate targets h1 for screen readers */
h2 { font-size: 0.95rem; letter-spacing: -0.01em; margin: 1.4rem 0 0.6rem; }
h3 { font-size: 0.9rem; margin: 1rem 0 0.4rem; }

a { color: var(--brand-ink); }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.45rem 0.95rem;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 0.9rem;
    font-weight: 550;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.12s ease;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background-color: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background-color: var(--brand-ink); }
.btn-secondary { background-color: var(--card); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover:not(:disabled) { background-color: var(--surface); }
.btn-danger { background-color: var(--bad); color: #fff; }
.btn-ai { background-color: var(--ai); color: #fff; }
.btn-ai:hover:not(:disabled) { background-color: #3b2e86; }

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 0.9rem;
    margin-bottom: 1rem;
}
.form-field { display: flex; flex-direction: column; gap: 0.3rem; }
.form-field label { font-size: 0.82rem; font-weight: 600; color: var(--ink-2); }
.form-field input, .form-field select, .form-field textarea,
select {
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 0.92rem;
    font-family: inherit;
    background: var(--card);
    color: var(--ink);
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
    outline: 2px solid var(--brand);
    outline-offset: -1px;
    border-color: var(--brand);
}
.form-field textarea { min-height: 90px; resize: vertical; }
.form-field-full { grid-column: 1 / -1; }
.form-check { display: flex; align-items: center; gap: 0.45rem; font-size: 0.9rem; }

/* Cards & tables */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem 1.2rem;
    margin-bottom: 1rem;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    font-size: 0.88rem;
}
.data-table th {
    text-align: left;
    padding: 0.6rem 1rem;
    background: #fafbfc;
    border-bottom: 1px solid var(--line);
    font-size: 0.72rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-3);
}
.data-table td {
    padding: 0.68rem 1rem;
    border-bottom: 1px solid var(--line-soft);
    color: var(--ink-2);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr.clickable { cursor: pointer; }
.data-table tr.clickable:hover { background: #f7fafc; }

/* Status pills */
.pill {
    display: inline-block;
    padding: 0.14rem 0.6rem;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 650;
    background: #eef1f5;
    color: var(--ink-2);
    white-space: nowrap;
    margin: 0.12rem 0.25rem 0.12rem 0;
    vertical-align: middle;
}
.pill-green { background: var(--good-bg); color: var(--good); }
.pill-amber { background: var(--warn-bg); color: var(--warn); }
.pill-red { background: var(--bad-bg); color: var(--bad); }
.pill-blue { background: #e8f1fb; color: var(--brand-ink); }
.pill-purple { background: var(--ai-bg); color: var(--ai); }

/* Dashboard tiles */
.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 0.9rem;
    margin-bottom: 1.5rem;
}
.tile {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem 1.15rem;
}
.tile .tile-label {
    font-size: 0.78rem;
    color: var(--ink-2);
    font-weight: 550;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.4rem;
}
.tile .tile-value {
    font-size: 1.9rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-top: 0.35rem;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
}
.tile .tile-hint { font-size: 0.75rem; color: var(--ink-3); margin-top: 0.2rem; }
.tile.tile-alert { border-left: 3px solid var(--bad); }
.tile.tile-alert .tile-value { color: var(--bad); }

.chip {
    font-size: 0.66rem;
    font-weight: 700;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    white-space: nowrap;
}
.chip-due { background: var(--bad-bg); color: var(--bad); }
.chip-ai { background: var(--ai-bg); color: var(--ai); }

.meter { height: 5px; background: #eceff3; border-radius: 999px; margin-top: 0.7rem; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--brand); border-radius: 999px; }

/* Messages */
.error-box {
    background: var(--bad-bg);
    border: 1px solid #f1aeb5;
    color: var(--bad);
    border-radius: 8px;
    padding: 0.65rem 0.9rem;
    margin: 0.75rem 0;
    font-size: 0.9rem;
}
.info-box {
    background: #e8f1fb;
    border: 1px solid #bcd7f3;
    color: var(--brand-ink);
    border-radius: 8px;
    padding: 0.65rem 0.9rem;
    margin: 0.75rem 0;
    font-size: 0.9rem;
}
.empty-state { color: var(--ink-3); font-style: italic; padding: 1rem 0; font-size: 0.9rem; }

.page-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin: 0.75rem 0 1rem; }

.detail-list { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1.2rem; font-size: 0.9rem; }
.detail-list dt { font-weight: 600; color: var(--ink-2); }
.detail-list dd { margin: 0; white-space: pre-wrap; color: var(--ink-2); }

.page-sub { color: var(--ink-3); font-size: 0.82rem; margin: -0.6rem 0 1.2rem; line-height: 1.5; }

/* Inside a card the subtitle follows a normal heading, not the page h1 —
   no negative pull, and breathing room below before the content starts. */
.card .page-sub {
    margin: 0.3rem 0 0.9rem;
}

/* Card headings: consistent space before their content. */
.card > h2:first-child,
.card > h3:first-child {
    margin-top: 0;
}

.card h2 {
    margin-bottom: 0.6rem;
}

.card h3 {
    margin-bottom: 0.55rem;
}

.section-head { display: flex; justify-content: space-between; align-items: baseline; margin: 1.4rem 0 0.6rem; }
.section-head h2 { margin: 0; }
.section-head a { font-size: 0.82rem; font-weight: 550; text-decoration: none; }

/* Loading */
.loading-progress { position: relative; display: block; width: 8rem; height: 8rem; margin: 20vh auto 1rem; }
.loading-progress circle {
    fill: none; stroke: #e0e0e0; stroke-width: 0.6rem;
    transform-origin: 50% 50%; transform: rotate(-90deg);
}
.loading-progress circle:last-child {
    stroke: var(--brand);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
}
.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"); }

#blazor-error-ui {
    background: lightyellow; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,0.2);
    display: none; left: 0; padding: 0.6rem 1.25rem 0.7rem; position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }


/* Long-text fields grow with their content (Chromium 123+; older browsers
   fall back to the rows attribute), so pasted text stays visible and editable. */
textarea {
    field-sizing: content;
    min-height: 2.6rem;
    max-height: 18rem;
    resize: vertical;
}

/* Dashboard tiles are links: the whole tile is the anchor, always (touch and keyboard
   included); the arrow is quiet at rest and clear on hover/focus. Static tiles have none. */
a.tile {
    display: block;
    position: relative;
    color: inherit;
    text-decoration: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
a.tile:hover, a.tile:focus-visible {
    border-color: var(--brand);
    box-shadow: 0 4px 14px rgba(16, 33, 59, 0.08);
    transform: translateY(-1px);
    outline: none;
}
a.tile:focus-visible { box-shadow: 0 0 0 3px rgba(42, 120, 214, 0.25); }
a.tile .tile-hint { padding-right: 3.6rem; } /* room for the arrow on long hints */
.tile-go {
    position: absolute;
    right: 0.9rem;
    bottom: 0.7rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--ink-3);
    opacity: 0.55;
    transition: opacity 0.15s ease, color 0.15s ease;
}
a.tile:hover .tile-go, a.tile:focus-visible .tile-go { opacity: 1; color: var(--brand-ink); }
.tile.tile-alert:hover { border-left-color: var(--bad); }

/* "Showing X only · Show all" strip used when a list page opens pre-filtered. */
.filter-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    background: #eaf2fd;
    border: 1px solid #c9dcf5;
    color: var(--brand-ink);
    border-radius: 10px;
    padding: 0.5rem 0.9rem;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}
.filter-banner a { color: var(--brand-ink); font-weight: 600; }

/* Offline capture: notes kept on the device until signal returns. */
.offline-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    flex-wrap: wrap;
    background: var(--warn-bg);
    border: 1px solid #f0d9a8;
    color: var(--warn);
    border-radius: 10px;
    padding: 0.6rem 0.9rem;
    font-size: 0.88rem;
    margin-bottom: 1rem;
}
