@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}

:root {
    --sidebar-bg: #111827;
    --sidebar-hover: #1f2937;
    --sidebar-active: #374151;
    --sidebar-text: #9ca3af;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --surface: #ffffff;
    --surface-secondary: #f9fafb;
    --border: #e5e7eb;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0284c7;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
}

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    color: var(--text-primary);
    background: var(--surface-secondary);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

h1, h2, h3, h4, h5, h6 { font-weight: 700; color: var(--text-primary); }

/* Buttons */
.btn {
    font-weight: 500;
    border-radius: var(--radius);
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    transition: all 0.15s ease;
}
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-lg { padding: 0.625rem 1.25rem; font-size: 0.938rem; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.813rem; }
.btn:focus { box-shadow: 0 0 0 0.2rem rgba(37,99,235,0.25); }

/* Cards */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    background: var(--surface);
}
.card-header {
    background: var(--surface-secondary);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

/* Forms */
.form-control, .form-select {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(37,99,235,0.15);
}
.form-control-lg { padding: 0.625rem 0.875rem; font-size: 0.938rem; }
.form-label { font-size: 0.875rem; color: var(--text-primary); margin-bottom: 0.375rem; }
.form-text { font-size: 0.8rem; color: var(--text-secondary); }

/* Tables */
.table { font-size: 0.875rem; color: var(--text-primary); }
.table thead th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    background: var(--surface-secondary);
    border-bottom: 2px solid var(--border);
    padding: 0.625rem 0.75rem;
}
.table tbody td { padding: 0.625rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table-striped > tbody > tr:nth-of-type(odd) > * { background: var(--surface-secondary); }
.table-hover > tbody > tr:hover > * { background: var(--primary-light); }

/* Badges */
.badge {
    font-weight: 600;
    font-size: 0.7rem;
    padding: 0.25em 0.6em;
    border-radius: 0.25rem;
}

/* Breadcrumbs */
.breadcrumb {
    font-size: 0.813rem;
}
.breadcrumb-item a { color: var(--text-secondary); }
.breadcrumb-item.active { color: var(--text-primary); font-weight: 500; }

/* Content area */
.content { padding-top: 1.25rem; }

/* Sidebar overrides — desktop only; below 641px the template collapses the sidebar to a top bar */
.sidebar {
    background: var(--sidebar-bg);
}
@media (min-width: 641px) {
    .sidebar {
        width: 260px;
        min-height: 100vh;
        position: sticky;
        top: 0;
    }
}
main {
    flex: 1;
    min-width: 0;
    background: var(--surface-secondary);
}
.top-row {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    min-height: 3.25rem;
    display: flex;
    align-items: center;
}

/* Nav sidebar */
.nav-scrollable { background: var(--sidebar-bg); }
.navbar-brand { color: #fff !important; font-weight: 700; font-size: 1.15rem; }
/* Tenant logo (see Components/Shared/OrgLogo.razor): a light chip so dark-on-transparent
   marks stay visible against the sidebar. */
.navbar-org-logo { height: 34px; max-width: 180px; object-fit: contain; background: #fff; border-radius: 6px; padding: 3px 8px; }
.hero-org-logo { height: 72px; max-width: 320px; object-fit: contain; background: rgba(255,255,255,0.92); border-radius: 10px; padding: 8px 14px; }
.login-org-logo { height: 56px; max-width: 240px; object-fit: contain; }
.navbar-dark { background: var(--sidebar-bg) !important; }

.nav-item ::deep .nav-link {
    color: var(--sidebar-text);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.12s;
}
.nav-item ::deep .nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}
.nav-item ::deep a.active {
    background: var(--sidebar-active);
    color: #fff;
}

/* Alert styling */
.alert {
    border-radius: var(--radius-lg);
    border: 1px solid;
    font-size: 0.875rem;
}
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-danger { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }

/* Accordion improvements */
.accordion-button { font-weight: 600; font-size: 0.938rem; }
.accordion-button:not(.collapsed) { background: var(--primary-light); color: var(--primary); }

/* Stat cards */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.stat-card:hover { box-shadow: var(--shadow-md); }

/* Nav tabs */
.nav-tabs {
    border-bottom: 2px solid var(--border);
}
.nav-tabs .nav-link {
    border: none;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.813rem;
    padding: 0.625rem 1rem;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}
.nav-tabs .nav-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: none;
}
.nav-tabs .nav-link:hover { color: var(--text-primary); border-bottom-color: var(--border); }

/* Section toggle headers (registration page) */
.section-toggle {
    font-weight: 600;
    font-size: 0.938rem;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}
.section-toggle:hover { background: var(--surface-secondary); }

/* Validation */
.valid.modified:not([type=checkbox]) { outline: 1px solid var(--success); }
.invalid { outline: 1px solid var(--danger); }
.validation-message { color: var(--danger); font-size: 0.8rem; }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, var(--danger);
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}
.blazor-error-boundary::after { content: "An error has occurred." }

/* PWA / Mobile optimizations */
@media (max-width: 767px) {
    .container { padding-left: 0.75rem; padding-right: 0.75rem; }
    .content { padding: 0; }
    main { padding-bottom: 60px; }
    .btn-lg { font-size: 1rem; padding: 0.75rem 1rem; }
    .form-control-lg { font-size: 1rem; padding: 0.75rem; }
    input[type=number], input[type=password] { font-size: 16px; } /* prevent iOS zoom */
}
@media (display-mode: standalone) {
    header, .top-row { padding-top: env(safe-area-inset-top); }
    .mobile-nav { padding-bottom: env(safe-area-inset-bottom); }
}

/* ---- Inline jargon help (InfoTip / GlossaryPanel) -------------------------
   This is a school product: the reader is often a teacher or a volunteer, not a
   sports scientist, so terms like ACWR are explained where they appear. CSS-only
   so it needs no JS init and works before the circuit connects. */

.info-tip {
    position: relative;
    display: inline-block;
    cursor: help;
    vertical-align: middle;
    margin-left: 0.15rem;
}

.info-tip-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 0.95rem;
    height: 0.95rem;
    border-radius: 50%;
    background: #dee2e6;
    color: #495057;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 1;
}

.info-tip:hover .info-tip-mark,
.info-tip:focus .info-tip-mark { background: var(--bs-primary, #0d6efd); color: #fff; }

/* Opens DOWNWARD, not up. The load table lives in an overflow-x:auto container, and a
   non-visible overflow-x forces overflow-y to auto too — so a bubble above a table header
   is clipped straight out of the scroll box. There is always room below. */
.info-tip-bubble {
    position: absolute;
    top: calc(100% + 0.45rem);
    left: 50%;
    transform: translateX(-50%);
    z-index: 1080;
    display: none;
    width: max-content;
    max-width: 15rem;
    padding: 0.5rem 0.65rem;
    border-radius: 0.4rem;
    background: #212529;
    color: #f8f9fa;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.35;
    text-align: left;
    white-space: normal;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

.info-tip-bubble strong { display: block; margin-bottom: 0.15rem; color: #fff; }

.info-tip:hover .info-tip-bubble,
.info-tip:focus .info-tip-bubble,
.info-tip:focus-within .info-tip-bubble { display: block; }

/* Arrow points back up at the marker. */
.info-tip-bubble::after {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-bottom-color: #212529;
}

/* In a table, a centred bubble on the last (right-aligned) column runs off the edge.
   Anchor those to the right instead. */
th:last-child .info-tip-bubble,
td:last-child .info-tip-bubble {
    left: auto;
    right: 0;
    transform: none;
}

th:last-child .info-tip-bubble::after,
td:last-child .info-tip-bubble::after {
    left: auto;
    right: 0.35rem;
    transform: none;
}

.glossary {
    border: 1px solid #e9ecef;
    border-radius: 0.75rem;
    background: #f8f9fa;
    padding: 0.75rem 1rem;
    max-width: 760px;
}

.glossary > summary {
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: #495057;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.glossary > summary::-webkit-details-marker { display: none; }
.glossary[open] > summary { margin-bottom: 0.75rem; }

.glossary-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 50%;
    background: #dee2e6;
    color: #495057;
    font-size: 0.7rem;
    font-weight: 700;
}

.glossary-body dl { display: grid; grid-template-columns: minmax(6rem, 9rem) 1fr; gap: 0.4rem 1rem; }
.glossary-body dt { font-size: 0.82rem; font-weight: 600; color: #212529; }
.glossary-body dd { margin: 0; font-size: 0.82rem; color: #6c757d; line-height: 1.45; }

@media (max-width: 576px) {
    .glossary-body dl { grid-template-columns: 1fr; gap: 0.1rem; }
    .glossary-body dd { margin-bottom: 0.6rem; }
}

/* ConsentSummary component (review queue + athlete profile) */
.consent-box { background: #f8f9fa; border-radius: 0.5rem; padding: 0.6rem 0.75rem; font-size: 0.78rem; }
.consent-box .title { font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; color: #6c757d; margin-bottom: 0.35rem; }
.consent-row { display: flex; justify-content: space-between; gap: 0.75rem; line-height: 1.5; }
.consent-row + .consent-row { margin-top: 0.15rem; }
.consent-box.full { font-size: 0.85rem; }
.consent-box.full .consent-row { padding: 0.45rem 0; border-top: 1px solid #e3e6ea; }
.consent-box.full .consent-row:first-of-type { border-top: 0; }
.consent-statement { color: #495057; font-size: 0.8rem; margin-top: 0.1rem; }
.consent-yes { color: #198754; font-weight: 600; white-space: nowrap; }
.consent-no { color: #dc3545; font-weight: 600; white-space: nowrap; }
.consent-guardian { margin-top: 0.4rem; padding-top: 0.4rem; border-top: 1px solid #e3e6ea; color: #495057; }
