/* EMS web app: plain CSS, system fonts (no external requests, works with a flaky connection). */

:root {
    --navy-900: #0a2540;
    --blue-800: #0b3d91;
    --blue-600: #1560bd;
    --blue-500: #1d78d8;
    --cyan-400: #38bdf8;
    --bg: #f3f6fb;
    --surface: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --danger: #b42318;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2 { margin: 0 0 .4rem; line-height: 1.2; }
h1 { font-size: 1.75rem; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0 0 1rem; line-height: 1.55; }
a { color: var(--blue-600); }
.muted { color: var(--muted); }
h1:focus { outline: none; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .65rem 1.1rem;
    border: 1px solid transparent;
    border-radius: 10px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:focus-visible { outline: 3px solid rgba(56, 189, 248, .55); outline-offset: 2px; }
.btn[disabled] { opacity: .65; cursor: default; }
.btn-primary { background: linear-gradient(180deg, var(--blue-500), var(--blue-600)); color: #fff; box-shadow: 0 1px 2px rgba(11, 61, 145, .35); }
.btn-primary:hover:not([disabled]) { background: linear-gradient(180deg, #2b86e6, var(--blue-800)); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: #eef3fa; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; margin-top: 1.5rem; }
.form label { font-size: .85rem; font-weight: 600; margin: 0 0 .35rem; color: #334155; }
.form input {
    width: 100%;
    padding: .7rem .85rem;
    margin-bottom: .35rem;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font: inherit;
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
.form input:focus { outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(29, 120, 216, .18); }
.form .btn { margin-top: .9rem; }
.validation-message { color: var(--danger); font-size: .82rem; margin-bottom: .6rem; }
.modified.invalid { border-color: var(--danger); }

/* ---------- Login ---------- */
.auth-shell { min-height: 100vh; }

.login {
    display: grid;
    grid-template-columns: 1fr clamp(380px, 34vw, 520px);
    min-height: 100vh;
}

.login-hero {
    background: #bcd0e6 url("../images/login-hero.jpg") center / cover no-repeat;
}

.login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--surface);
}

.login-card { width: 100%; max-width: 380px; }
.login-logo { display: none; width: 72px; height: 72px; margin-bottom: 1rem; }
.demo-note { margin-top: 1.25rem; font-size: .8rem; color: var(--muted); }

@media (max-width: 900px) {
    .login { grid-template-columns: 1fr; }
    .login-hero { display: none; }
    .login-panel {
        align-items: flex-start;
        padding-top: 12vh;
        background: linear-gradient(180deg, #eaf1fb 0, var(--surface) 55%);
    }
    .login-logo { display: block; }
}

/* ---------- App shell ---------- */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .6rem 1.25rem;
    color: #fff;
    background: linear-gradient(90deg, var(--navy-900), var(--blue-800));
    box-shadow: 0 2px 8px rgba(10, 37, 64, .25);
}
.brand { display: flex; align-items: center; gap: .7rem; color: #fff; text-decoration: none; }
.brand img { width: 38px; height: 38px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 1.05rem; letter-spacing: .04em; }
.brand-text small { font-size: .72rem; color: #bcd6f5; }
.topbar-right { display: flex; align-items: center; gap: .75rem; }
.user-chip { padding: .3rem .7rem; border-radius: 999px; background: rgba(255, 255, 255, .14); font-size: .85rem; }
.topbar .btn-ghost { color: #fff; border-color: rgba(255, 255, 255, .35); padding: .4rem .8rem; }
.topbar .btn-ghost:hover { background: rgba(255, 255, 255, .12); }

.content { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 2rem 1.25rem; }
.footer { padding: 1rem; text-align: center; font-size: .8rem; color: var(--muted); }
.page { max-width: 560px; }

@media (max-width: 560px) {
    .brand-text small { display: none; }
    .user-chip { display: none; }
}

/* ---------- Welcome ---------- */
.welcome {
    padding: 2.5rem 1.5rem;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
}
.welcome-logo { width: 120px; height: 120px; margin-bottom: 1rem; filter: drop-shadow(0 6px 14px rgba(11, 61, 145, .25)); }
.lead { max-width: 620px; margin: .5rem auto 2rem; color: #475569; font-size: 1.05rem; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; text-align: left; }
.tile { padding: 1.1rem 1.2rem; background: #f8fafd; border: 1px solid var(--border); border-radius: var(--radius); }
.tile p { margin-bottom: .8rem; font-size: .9rem; }
.badge {
    display: inline-block;
    padding: .15rem .6rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
    color: var(--blue-800);
    background: #e3eefc;
}

/* ---------- Loading screen (shown before Blazor starts and while auth is checked) ---------- */
.boot-screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    background: var(--bg);
}
.boot-screen img { width: 84px; height: 84px; }
.boot-bar { width: 140px; height: 4px; border-radius: 4px; background: #dbe5f3; overflow: hidden; }
.boot-bar span {
    display: block;
    width: 40%;
    height: 100%;
    border-radius: 4px;
    background: var(--blue-500);
    animation: boot-slide 1.1s ease-in-out infinite;
}
@keyframes boot-slide {
    0% { transform: translateX(-110%); }
    100% { transform: translateX(350%); }
}

/* ---------- Offline banner (plain JS in index.html; no Blazor connection involved) ---------- */
#offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2000;
    padding: .45rem 1rem;
    text-align: center;
    font-size: .85rem;
    color: #5b3a00;
    background: #ffe9b3;
    border-bottom: 1px solid #f2cf75;
}
#offline-banner[hidden] { display: none; }

/* ---------- Blazor error UI ---------- */
#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3000;
    padding: .7rem 1.25rem .8rem;
    color: #3b2a00;
    background: #fff4d1;
    border-top: 1px solid #f2cf75;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, .15);
}
#blazor-error-ui .dismiss { position: absolute; right: .75rem; top: .5rem; cursor: pointer; }
#blazor-error-ui .reload { margin-left: .5rem; }

.blazor-error-boundary {
    padding: 1rem 1rem 1rem 1rem;
    color: #fff;
    background: var(--danger);
}
.blazor-error-boundary::after { content: "An error has occurred."; }
