/* =========================================================================
   Admin panel. Deliberately calmer than the public site: dense tables,
   high contrast, no decoration that competes with the data.
   ========================================================================= */

:root {
    --brand: #1A5BA8;
    --brand-2: #103F7A;
    /* The same metallic highlight the public site uses, kept to the one place
       it earns: the active item in the sidebar. */
    --gold: #C2A24C;

    --ad-ink: #0E1B2A;
    --ad-ink-2: #4A5A6B;
    --ad-ink-3: #7C8B9A;
    --ad-line: #E3E8EC;
    --ad-bg: #F5F7F9;
    --ad-surface: #ffffff;
    --ad-sidebar: #0C2440;
    --ad-sidebar-2: #143654;

    --ad-radius: 12px;
    --ad-shadow: 0 1px 2px rgba(14,27,42,.05), 0 4px 14px rgba(14,27,42,.06);
    --ad-sidebar-w: 260px;
    --ad-topbar-h: 68px;
}

* { box-sizing: border-box; }

.ad-body {
    margin: 0;
    background: var(--ad-bg);
    color: var(--ad-ink);
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-feature-settings: "cv02", "cv03", "cv04", "cv11";
    -webkit-font-smoothing: antialiased;
    font-size: .94rem;
    line-height: 1.6;
}

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

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

/* ---------- Sidebar --------------------------------------------------- */
.ad-nav-toggle { display: none; }

.ad-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--ad-sidebar-w);
    background: linear-gradient(180deg, var(--ad-sidebar), var(--ad-sidebar-2));
    color: rgba(255,255,255,.78);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    overflow-y: auto;
    scrollbar-width: thin;
}

.ad-brand {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    position: sticky;
    top: 0;
    background: var(--ad-sidebar);
    z-index: 2;
}
.ad-brand img { height: 38px; width: auto; }
.ad-brand strong { display: block; color: #fff; font-size: .95rem; line-height: 1.2; }
.ad-brand small { color: rgba(255,255,255,.5); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }

.ad-nav { padding: .75rem 0 2rem; }
.ad-nav-group { margin-bottom: .5rem; }
.ad-nav-heading {
    display: block;
    padding: .85rem 1.25rem .35rem;
    font-size: .68rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: rgba(255,255,255,.38);
    font-weight: 700;
}

.ad-nav-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .55rem 1.25rem;
    color: rgba(255,255,255,.76);
    font-size: .89rem;
    border-left: 3px solid transparent;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.ad-nav-link i { font-size: 1.02rem; width: 18px; text-align: center; }
.ad-nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.ad-nav-link.is-active {
    background: rgba(255,255,255,.1);
    color: #fff;
    border-left-color: var(--gold);
    font-weight: 600;
}

.ad-backdrop { display: none; }

/* ---------- Main ------------------------------------------------------ */
.ad-main { margin-left: var(--ad-sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

.ad-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    min-height: var(--ad-topbar-h);
    background: var(--ad-surface);
    border-bottom: 1px solid var(--ad-line);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .65rem 1.5rem;
}
.ad-topbar-title { flex: 1; min-width: 0; }
.ad-topbar-title h1 { font-size: 1.15rem; font-weight: 700; margin: 0; line-height: 1.3; }
.ad-topbar-title p {
    margin: 0;
    font-size: .82rem;
    color: var(--ad-ink-3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ad-topbar-actions { display: flex; align-items: center; gap: .6rem; flex-shrink: 0; }

.ad-burger {
    display: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--ad-ink-2);
    padding: .2rem .4rem;
}

.ad-user {
    display: flex;
    align-items: center;
    gap: .55rem;
    background: transparent;
    border: 1px solid var(--ad-line);
    border-radius: 999px;
    padding: .25rem .8rem .25rem .25rem;
    font-size: .88rem;
    font-weight: 600;
    color: var(--ad-ink);
}
.ad-user:hover { background: var(--ad-bg); }
.ad-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--brand); color: #fff;
    display: grid; place-items: center;
    font-size: .78rem; font-weight: 700;
}

.ad-content { padding: 1.5rem; flex: 1; }

/* ---------- Cards ----------------------------------------------------- */
.ad-card {
    background: var(--ad-surface);
    border: 1px solid var(--ad-line);
    border-radius: var(--ad-radius);
    box-shadow: var(--ad-shadow);
    overflow: hidden;
}
.ad-card-head {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--ad-line);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}
.ad-card-title { font-size: .95rem; font-weight: 700; margin: 0; }
.ad-card-body { padding: 1.25rem; }
.ad-card-foot { padding: 1rem 1.25rem; border-top: 1px solid var(--ad-line); background: #fbfcfd; }
.ad-card-actions { display: flex; gap: .5rem; flex-shrink: 0; }

.ad-sticky { position: sticky; top: calc(var(--ad-topbar-h) + 1rem); }

/* ---------- Toolbar --------------------------------------------------- */
.ad-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.ad-search { max-width: 280px; }
.ad-search .input-group-text { background: #fff; border-color: var(--ad-line); }
.ad-filter { width: auto; min-width: 140px; }

.form-control, .form-select {
    border-color: var(--ad-line);
    border-radius: 8px;
    font-size: .9rem;
    padding: .45rem .7rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent);
}

.btn { border-radius: 8px; font-weight: 600; font-size: .88rem; padding: .45rem 1rem; }
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover { background: color-mix(in srgb, var(--brand) 86%, black); border-color: transparent; color: #fff; }
.btn-outline-brand { border: 1px solid var(--brand); color: var(--brand); background: #fff; }
.btn-outline-brand:hover { background: var(--brand); color: #fff; }
.btn-light { background: #fff; border: 1px solid var(--ad-line); color: var(--ad-ink-2); }
.btn-light:hover { background: var(--ad-bg); color: var(--ad-ink); }

/* ---------- Tables ---------------------------------------------------- */
.ad-table { font-size: .88rem; }
.ad-table thead th {
    background: #fbfcfd;
    border-bottom: 1px solid var(--ad-line);
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--ad-ink-3);
    font-weight: 700;
    white-space: nowrap;
    padding: .7rem .9rem;
}
.ad-table tbody td { padding: .7rem .9rem; border-bottom: 1px solid var(--ad-line); vertical-align: middle; }
.ad-table tbody tr:hover { background: #fafbfd; }
.ad-table tbody tr:last-child td { border-bottom: 0; }

.ad-sort { color: var(--ad-ink-3); display: inline-flex; align-items: center; gap: .3rem; }
.ad-sort:hover { color: var(--brand); }
.ad-sort.is-sorted { color: var(--brand); }
.ad-sort i { font-size: .72rem; opacity: .7; }

.ad-col-thumb { width: 72px; }
.ad-col-order { width: 92px; }
.ad-col-actions { width: 1%; white-space: nowrap; }

.ad-thumb {
    width: 52px; height: 40px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--ad-line);
    background: var(--ad-bg);
    display: block;
}
.ad-thumb-empty { display: grid; place-items: center; color: var(--ad-ink-3); }

.ad-row-actions { display: inline-flex; gap: .25rem; }
.ad-row-actions .btn { padding: .3rem .55rem; }

.ad-order-form { max-width: 80px; }
.ad-order-form .form-control { text-align: center; padding: .28rem .4rem; }

.badge { font-weight: 600; font-size: .72rem; padding: .32rem .6rem; border-radius: 6px; }
.ad-badge-yes { background: #e6f5ef; color: #0d7a52; }
.ad-badge-no { background: #f1f3f5; color: #6b7a85; }
.ad-badge-key { background: #eef3f8; color: #2c5c8a; letter-spacing: .04em; }
.ad-badge-new { background: #fff4e0; color: #9a6300; }
.ad-badge-confirmed { background: #e6f5ef; color: #0d7a52; }
.ad-badge-cancelled { background: #fdecee; color: #b02a37; }
.ad-badge-completed { background: #eef3f8; color: #2c5c8a; }

.ad-stars { color: #d9a400; font-size: .78rem; letter-spacing: .05em; }

/* Status toggle switch */
.ad-toggle {
    width: 40px; height: 22px;
    border-radius: 999px;
    background: #d4dbe0;
    border: 0;
    padding: 0;
    position: relative;
    cursor: pointer;
    transition: background .18s ease;
}
.ad-toggle span {
    position: absolute;
    top: 3px; left: 3px;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: transform .18s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.ad-toggle.is-on { background: var(--brand); }
.ad-toggle.is-on span { transform: translateX(18px); }

/* ---------- Forms ----------------------------------------------------- */
.ad-field-label {
    display: block;
    font-size: .8rem;
    font-weight: 700;
    color: var(--ad-ink-2);
    margin-bottom: .3rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.ad-required { color: #b02a37; }
.ad-field-help { display: block; font-size: .78rem; color: var(--ad-ink-3); margin-top: .3rem; }

.ad-check { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; padding-top: 1.4rem; }
.ad-check .form-check-input { margin: 0; width: 1.15em; height: 1.15em; }
.ad-check .form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.ad-check .form-check-label { font-weight: 600; font-size: .88rem; margin: 0; }

.ad-html { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .84rem; line-height: 1.55; }

/* ---------- Upload field ----------------------------------------------- */
/* A photo/file control rather than a bare file input: the current image is
   shown, a new one previews before the form is saved, and the whole panel is
   a drop target. The real <input type="file"> stays in the DOM (visually
   hidden, not display:none) so the form still posts it and it remains
   reachable by keyboard. */
.ad-upload {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    padding: .85rem;
    border: 1px dashed var(--ad-line);
    border-radius: 10px;
    background: #fbfcfd;
    transition: border-color .15s ease, background .15s ease;
}
.ad-upload.is-dragging {
    border-color: var(--brand);
    background: color-mix(in srgb, var(--brand) 5%, white);
}

.ad-upload-preview {
    flex: 0 0 96px;
    width: 96px;
    height: 96px;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--ad-line);
    display: grid;
    place-items: center;
}
.ad-upload-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ad-upload-preview.is-empty { border-style: dashed; }
.ad-upload-doc { font-size: 1.9rem; color: var(--ad-ink-3); }

/* Once there is something to look at, the thumbnail opens it full size. */
.ad-upload-preview.is-viewable { cursor: zoom-in; position: relative; }
.ad-upload-preview.is-viewable::after {
    content: "\F4A0"; /* bootstrap-icons: zoom-in */
    font-family: "bootstrap-icons";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(14, 27, 42, .45);
    color: #fff;
    font-size: 1.3rem;
    opacity: 0;
    transition: opacity .15s ease;
}
.ad-upload-preview.is-viewable:hover::after { opacity: 1; }

/* Full-size viewer */
.ad-viewer .modal-content { border: 0; border-radius: var(--ad-radius); overflow: hidden; }
.ad-viewer .modal-body { padding: 0; background: var(--ad-bg); display: grid; place-items: center; }
.ad-viewer .modal-body img { max-width: 100%; max-height: 72vh; display: block; }

.ad-upload-body { flex: 1; min-width: 0; }
.ad-upload-name {
    font-size: .88rem;
    font-weight: 600;
    color: var(--ad-ink);
    margin: 0 0 .5rem;
    overflow-wrap: anywhere;
}
.ad-upload-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .5rem; }
.ad-upload-actions .btn { display: inline-flex; align-items: center; gap: .35rem; }
.ad-upload-clear { color: #b02a37; }
.ad-upload-clear:hover { background: #fdecec; color: #8f1d28; }

.ad-upload-error { display: block; font-size: .8rem; color: #b02a37; margin-top: .35rem; }

/* Visually hidden, but still focusable and still posted with the form. */
.ad-upload-input {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}
.ad-upload-input:focus-visible + * { outline: 2px solid var(--brand); }
.ad-upload:focus-within { border-color: var(--brand); }

@media (max-width: 575.98px) {
    .ad-upload { flex-direction: column; }
    .ad-upload-preview { flex: 0 0 auto; width: 100%; height: 150px; }
}

/* ---------- Dashboard ------------------------------------------------- */
.ad-stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; }
.ad-stat {
    background: var(--ad-surface);
    border: 1px solid var(--ad-line);
    border-radius: var(--ad-radius);
    padding: 1.1rem 1.2rem;
    display: flex;
    align-items: center;
    gap: .9rem;
    box-shadow: var(--ad-shadow);
    color: var(--ad-ink);
    transition: transform .15s ease, box-shadow .15s ease;
}
.ad-stat:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(14,30,52,.1); color: var(--ad-ink); }
.ad-stat-icon {
    width: 44px; height: 44px; border-radius: 10px;
    display: grid; place-items: center;
    font-size: 1.2rem;
    background: color-mix(in srgb, var(--brand) 10%, white);
    color: var(--brand);
    flex-shrink: 0;
}
.ad-stat-value { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.ad-stat-label { font-size: .8rem; color: var(--ad-ink-3); font-weight: 600; }
.ad-stat-badge {
    margin-left: auto;
    background: #fff4e0; color: #9a6300;
    font-size: .7rem; font-weight: 700;
    padding: .2rem .5rem; border-radius: 6px;
}

/* ---------- Empty / alerts -------------------------------------------- */
.ad-empty { text-align: center; padding: 3rem 1rem; color: var(--ad-ink-3); }
.ad-empty i { font-size: 2.5rem; display: block; margin-bottom: .6rem; color: var(--ad-line); }

.ad-alert { display: flex; align-items: flex-start; gap: .6rem; border: 0; border-radius: var(--ad-radius); font-size: .89rem; }
.ad-alert i { font-size: 1.05rem; margin-top: .1rem; }

/* ---------- Sign in ----------------------------------------------------- */
/* A split screen: the hospital's own brand panel beside the form, so the
   admin entrance feels like part of the same product as the public site. */
.ad-login {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.ad-login-brand {
    position: relative;
    overflow: hidden;
    background: var(--navy, #071A35);
    color: rgba(255,255,255,.72);
    display: flex;
    align-items: center;
    padding: clamp(2rem, 5vw, 4.5rem);
}
/* One soft bloom plus fine diagonal rules — the same treatment the public
   site uses on its inner page headers. */
.ad-login-brand::after {
    content: "";
    position: absolute;
    left: -10%; bottom: -45%;
    width: 42rem; height: 42rem;
    background: radial-gradient(circle, color-mix(in srgb, var(--brand) 52%, transparent) 0%, transparent 66%);
    pointer-events: none;
}
.ad-login-pattern {
    position: absolute;
    inset: 0;
    background-image: repeating-linear-gradient(
        115deg,
        rgba(255,255,255,.04) 0px,
        rgba(255,255,255,.04) 1px,
        transparent 1px,
        transparent 14px);
    -webkit-mask-image: linear-gradient(100deg, #000 0%, transparent 70%);
    mask-image: linear-gradient(100deg, #000 0%, transparent 70%);
    pointer-events: none;
}
.ad-login-brand-inner { position: relative; z-index: 2; max-width: 30rem; }
.ad-login-brand-logo { height: 68px; width: auto; margin-bottom: 1.75rem; }
.ad-login-brand-title {
    font-family: "Playfair Display", Georgia, serif;
    font-weight: 600;
    font-size: clamp(1.75rem, 1.3rem + 1.6vw, 2.5rem);
    line-height: 1.15;
    color: #fff;
    margin: 0 0 .5rem;
}
.ad-login-brand-tagline {
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--gold, #C8A44D);
    margin: 0 0 1.5rem;
}
.ad-login-brand-copy { font-size: .95rem; line-height: 1.7; margin: 0; max-width: 34ch; }
.ad-login-crest {
    display: inline-flex; align-items: center; gap: .7rem;
    margin-top: 2.5rem;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: rgba(255,255,255,.5);
}
.ad-login-crest::before { content: ""; width: 40px; height: 1px; background: rgba(255,255,255,.3); }

.ad-login-form {
    display: grid;
    place-items: center;
    padding: clamp(1.5rem, 4vw, 3rem);
    background: var(--ad-bg);
}
.ad-login-card { width: min(27rem, 100%); }

.ad-login-head { margin-bottom: 1.75rem; }
.ad-login-head img { height: 52px; width: auto; margin-bottom: 1.1rem; }
.ad-login-head h1 {
    font-family: "Playfair Display", Georgia, serif;
    font-size: 1.65rem;
    font-weight: 600;
    color: var(--ad-ink);
    margin: 0 0 .3rem;
}
.ad-login-head p { font-size: .9rem; color: var(--ad-ink-3); margin: 0; }

/* The brand panel carries the hospital identity, so the form itself stays
   plain: no card, no shadow competing with it. */
.ad-login .ad-field-label {
    display: block;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--ad-ink-2);
    margin-bottom: .45rem;
}
.ad-login .input-group { border-radius: 10px; }
.ad-login .input-group-text {
    background: #fff;
    border-color: var(--ad-line);
    border-right: 0;
    color: var(--ad-ink-3);
    padding-left: .9rem;
}
.ad-login .form-control {
    border-left: 0;
    border-color: var(--ad-line);
    padding: .72rem .9rem;
    font-size: .95rem;
}
.ad-login .input-group:focus-within .input-group-text,
.ad-login .input-group:focus-within .form-control { border-color: var(--brand); }
.ad-login .form-control:focus { box-shadow: none; }
.ad-login .input-group:focus-within { box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 12%, transparent); }

.ad-reveal {
    border: 1px solid var(--ad-line);
    border-left: 0;
    background: #fff;
    color: var(--ad-ink-3);
    padding-inline: .85rem;
}
.ad-reveal:hover { color: var(--brand); background: #fff; }

.ad-login-submit {
    padding-block: .8rem;
    font-size: .95rem;
    border-radius: 10px;
    box-shadow: 0 10px 24px color-mix(in srgb, var(--brand) 26%, transparent);
}

.ad-login-foot {
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--ad-line);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    font-size: .82rem;
}
.ad-login-help { color: var(--ad-ink-3); }

@media (max-width: 991.98px) {
    /* The brand panel becomes a banner above the form rather than disappearing,
       so the page still identifies itself on a phone. */
    .ad-login { grid-template-columns: 1fr; min-height: 100dvh; }
    .ad-login-brand { padding: 2.25rem 1.5rem; }
    .ad-login-brand-logo { height: 52px; margin-bottom: 1.1rem; }
    .ad-login-brand-copy, .ad-login-crest { display: none; }
    .ad-login-form { align-items: start; padding-top: 2.25rem; }
}

/* ---------- Page sections builder ------------------------------------- */
.ad-section-row {
    border: 1px solid var(--ad-line);
    border-radius: var(--ad-radius);
    background: #fff;
    margin-bottom: .75rem;
    overflow: hidden;
}
.ad-section-head {
    display: flex; align-items: center; gap: .75rem;
    padding: .75rem 1rem;
    background: #fbfcfd;
    border-bottom: 1px solid var(--ad-line);
}
.ad-section-head .badge { flex-shrink: 0; }
.ad-section-body { padding: 1rem; }

/* ---------- Responsive ------------------------------------------------- */
@media (max-width: 991.98px) {
    .ad-sidebar { transform: translateX(-100%); transition: transform .22s ease; }
    .ad-nav-toggle:checked ~ .ad-sidebar { transform: translateX(0); }
    .ad-nav-toggle:checked ~ .ad-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(9,24,44,.45);
        z-index: 1035;
    }
    .ad-main { margin-left: 0; }
    .ad-burger { display: block; }
    .ad-content { padding: 1rem; }
    .ad-sticky { position: static; }
}

@media (max-width: 575.98px) {
    .ad-topbar { padding: .6rem .9rem; }
    .ad-topbar-title h1 { font-size: 1rem; }
    .ad-toolbar { width: 100%; }
    .ad-search { max-width: none; flex: 1 1 100%; }
    .ad-card-head { flex-direction: column; align-items: stretch; }
    .ad-card-actions { justify-content: stretch; }
    .ad-card-actions .btn { flex: 1; }
}

/* ---------- Validation summaries --------------------------------------- */
/* The tag helper always emits its <div>, so without this an empty red alert
   sits above the sign-in form before anything has been submitted. */
.validation-summary-valid { display: none; }
.field-validation-error { display: block; font-size: .8rem; color: #b02a37; margin-top: .25rem; }
.input-validation-error { border-color: #b02a37; }
