/* =========================================================================
   Appointment CMS — assets/css/style.css

   Brand system taken from https://eternesseclinic.com/
     Primary   #104b8d  (deep medical blue)   — buttons, nav, headings
     Dark      #05366c  (hover / gradients)
     Tints     #e4effd, #bed9fb               — soft panels, focus fill
     Accent    #e91a51  (crimson)             — underlines, dividers, badges
     Success   #009d23    Danger  #d50000
     Neutrals  #fbfbfb, #e6e6e6, #ccc, #333
     Typeface  Inter (Google Fonts), 8px corner radius

   Loaded after Bootstrap 5 so these rules win where they overlap.
   ========================================================================= */

:root {
    --brand-blue:        #104b8d;
    --brand-blue-dark:   #05366c;
    --brand-blue-light:  #1a63b4;
    --brand-blue-soft:   #e4effd;
    --brand-blue-tint:   #bed9fb;

    --brand-accent:      #e91a51;
    --brand-accent-dark: #c4123f;
    --brand-accent-soft: #fdeaf1;

    --brand-success:     #009d23;
    --brand-danger:      #d50000;

    --ink:               #333333;
    --ink-muted:         #6b7280;
    --line:              #e6e6e6;
    --surface:           #ffffff;
    --surface-alt:       #fbfbfb;

    --radius:            8px;
    --radius-lg:         12px;
    --shadow-sm:         0 1px 2px rgba(5, 54, 108, .07);
    --shadow-md:         0 6px 20px rgba(5, 54, 108, .10);
    --sidebar-width:     264px;
}

/* -------------------------------------------------------------- Base ---- */
body {
    background-color: var(--surface);
    color: var(--ink);
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: .95rem;
    line-height: 1.6;
}

a { color: var(--brand-blue); text-decoration-color: rgba(16, 75, 141, .35); }
a:hover { color: var(--brand-blue-light); }

h1, h2, h3, h4, h5, h6 {
    color: var(--brand-blue-dark);
    font-weight: 700;
    letter-spacing: -.01em;
}

.skip-link {
    position: absolute; top: .5rem; left: .5rem; z-index: 1080;
    background: var(--brand-blue); color: #fff; padding: .5rem .9rem; border-radius: var(--radius);
}

::selection { background-color: var(--brand-blue); color: #fff; }

/* Focus visibility for keyboard users (accessibility). */
a:focus-visible,
button:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible {
    outline: 3px solid var(--brand-blue);
    outline-offset: 2px;
}

.form-control, .form-select { border-color: #d8dee6; border-radius: var(--radius); }
.form-control:focus, .form-select:focus {
    border-color: var(--brand-blue);
    background-color: #f7fbff;
    box-shadow: 0 0 0 .2rem rgba(16, 75, 141, .15);
}
.form-check-input:focus { box-shadow: 0 0 0 .2rem rgba(16, 75, 141, .18); }
.form-check-input:checked {
    background-color: var(--brand-blue);
    border-color: var(--brand-blue);
}
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--brand-accent); }
.invalid-feedback { color: var(--brand-accent); }

/* ----------------------------------------------------------- Buttons ---- */
.btn { border-radius: var(--radius); font-weight: 600; }

.btn-brand {
    background-color: var(--brand-blue);
    border-color: var(--brand-blue);
    color: #fff;
    transition: background-color .3s;
}
.btn-brand:hover, .btn-brand:focus {
    background-color: var(--brand-blue-dark);
    border-color: var(--brand-blue-dark);
    color: #fff;
}
.btn-outline-brand {
    color: var(--brand-blue);
    border-color: var(--brand-blue);
    background-color: transparent;
}
.btn-outline-brand:hover, .btn-outline-brand:focus {
    background-color: var(--brand-blue);
    color: #fff;
}
.btn-accent {
    background-color: var(--brand-accent);
    border-color: var(--brand-accent);
    color: #fff;
}
.btn-accent:hover, .btn-accent:focus {
    background-color: var(--brand-accent-dark);
    border-color: var(--brand-accent-dark);
    color: #fff;
}
.btn-whatsapp {
    background-color: #25d366;
    border-color: #25d366;
    color: #08331a;
}
.btn-whatsapp:hover, .btn-whatsapp:focus { background-color: #1da851; border-color: #1da851; color: #fff; }

.bg-brand   { background-color: var(--brand-blue) !important; color: #fff; }
.bg-accent  { background-color: var(--brand-accent) !important; color: #fff !important; }
.text-brand { color: var(--brand-blue) !important; }
.text-accent{ color: var(--brand-accent) !important; }

/* ========================================================================
   PUBLIC APPOINTMENT FORM
   ======================================================================== */
.public-body {
    background:
        radial-gradient(1200px 420px at 50% -240px, rgba(16, 75, 141, .12), transparent 70%),
        var(--surface-alt);
    min-height: 100vh;
}

.public-header {
    background: linear-gradient(135deg, var(--brand-blue-dark), var(--brand-blue) 70%, var(--brand-blue-light));
    color: #fff;
    padding: 1.1rem 0;
    border-bottom: 4px solid var(--brand-accent);
}
.public-header .clinic-name { font-weight: 700; letter-spacing: -.01em; color: #fff; margin: 0; font-size: 1.3rem; }
.public-header .clinic-tag  { color: rgba(255,255,255,.88); font-size: .85rem; margin: 0; }
.public-header img.logo     { height: 46px; width: auto; background: #fff; border-radius: var(--radius); padding: .25rem; }

.form-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}
.form-card .card-head {
    background: var(--brand-blue-soft);
    border-bottom: 1px solid var(--brand-blue-tint);
    padding: 1.25rem 1.5rem;
}
.form-card .card-head h1 { font-size: 1.4rem; margin: 0 0 .35rem; }
.form-card .card-head p  { margin: 0; color: #45596e; font-size: .9rem; }
.form-card .card-body-pad { padding: 1.5rem; }

/* Section heading with the site's crimson rule, as used on eternesseclinic.com */
.section-title {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--brand-blue-dark);
    font-weight: 700;
    margin: 1.85rem 0 .9rem;
    display: flex;
    align-items: center;
    gap: .65rem;
}
.section-title::after {
    content: "";
    flex: 1;
    height: 4px;
    border-radius: 4px;
    background-color: var(--brand-accent);
    opacity: .85;
}
.section-title:first-of-type { margin-top: 0; }

.form-label { font-weight: 600; color: #3b4a5a; font-size: .875rem; }
.required-star { color: var(--brand-accent); }

.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .6rem; }
.choice-tile {
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    padding: .7rem .85rem;
    background: #fff;
    cursor: pointer;
    transition: border-color .2s ease, background-color .2s ease, box-shadow .2s ease;
    margin: 0;
    display: flex;
    align-items: center;
    gap: .55rem;
}
.choice-tile:hover { border-color: var(--brand-blue-light); background: var(--brand-blue-soft); }
.choice-tile input { margin: 0; flex: none; }
.choice-tile.is-selected {
    border-color: var(--brand-blue);
    background: var(--brand-blue-soft);
    box-shadow: inset 0 0 0 1px var(--brand-blue);
}
.choice-tile .tile-label { font-weight: 600; font-size: .92rem; }

/* ------------------------------------------------------- Slot picker ---- */
.slot-picker {
    background: var(--brand-blue-soft);
    border: 1px solid var(--brand-blue-tint);
    border-radius: var(--radius);
    padding: 1.1rem;
}
.slot-picker .form-control,
.slot-picker .form-select { background-color: #fff; }
.slot-picker .form-select:disabled { background-color: #f1f4f8; color: var(--ink-muted); }
.slot-status { min-height: 1.25rem; }
.slot-confirmed { border-left: 4px solid var(--brand-accent) !important; background: var(--brand-blue-soft); }

/* Slot chips on the admin slots page */
.slot-chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    border: 1px solid var(--line);
    border-radius: 2rem;
    padding: .15rem .6rem;
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
}
.slot-chip.is-open   { background: #eaf7ee; border-color: #bde5c8; color: #10662a; }
.slot-chip.is-full   { background: var(--brand-accent-soft); border-color: #f7ccd9; color: var(--brand-accent-dark); }
.slot-chip.is-off    { background: #f1f3f5; border-color: #dfe3e8; color: var(--ink-muted); }
.slot-chip.is-past   { background: #fff; border-style: dashed; color: var(--ink-muted); }

.consent-box {
    background: var(--brand-accent-soft);
    border: 1px solid #f7ccd9;
    border-radius: var(--radius);
    padding: 1rem;
}

.success-panel {
    background: #fff;
    border: 1px solid var(--line);
    border-top: 5px solid var(--brand-accent);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2.5rem 1.75rem;
    text-align: center;
}
.success-panel .tick {
    width: 76px; height: 76px; border-radius: 50%;
    background: var(--brand-blue-soft); color: var(--brand-blue);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 2.4rem; margin-bottom: 1rem;
}
.reference-chip {
    display: inline-block;
    background: var(--brand-blue);
    color: #fff;
    font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;
    letter-spacing: .06em;
    font-size: 1.05rem;
    padding: .55rem 1.1rem;
    border-radius: 2rem;
    border: 2px solid var(--brand-accent);
}

.public-footer {
    color: var(--ink-muted);
    font-size: .85rem;
    padding: 2rem 0 2.5rem;
    text-align: center;
}

/* ========================================================================
   ADMIN SHELL
   ======================================================================== */
.admin-body { background: var(--surface-alt); }

.admin-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    flex: 0 0 var(--sidebar-width);
    background: linear-gradient(180deg, var(--brand-blue-dark), var(--brand-blue));
    color: #e7f0fb;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1045;
    transition: transform .25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .14);
    min-height: 64px;
}
.sidebar-logo { height: 36px; width: 36px; object-fit: contain; background: #fff; border-radius: var(--radius); padding: .15rem; }
.sidebar-logo-fallback {
    height: 36px; width: 36px; border-radius: var(--radius);
    background: var(--brand-accent); color: #fff;
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.15rem;
}
.sidebar-brand-text {
    font-weight: 700; color: #fff; font-size: .98rem; line-height: 1.25;
    overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.sidebar-close { color: #fff; margin-left: auto; padding: .1rem .4rem; }

.sidebar-nav { padding: .85rem .6rem; overflow-y: auto; flex: 1; }
.sidebar .nav-link {
    color: #cfe0f5;
    border-radius: var(--radius);
    padding: .6rem .8rem;
    display: flex;
    align-items: center;
    gap: .7rem;
    font-weight: 500;
    margin-bottom: .15rem;
}
.sidebar .nav-link i { font-size: 1.05rem; width: 1.25rem; text-align: center; }
.sidebar .nav-link:hover { background: rgba(255, 255, 255, .10); color: #fff; }
.sidebar .nav-link.active {
    background: rgba(255, 255, 255, .16);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--brand-accent);
}
.sidebar .nav-link.text-danger-emphasis { color: #ffc9d6; }
.sidebar-divider { border-color: rgba(255, 255, 255, .18); margin: .75rem .4rem; }
.sidebar-footer {
    padding: .75rem 1.1rem;
    border-top: 1px solid rgba(255, 255, 255, .14);
    color: rgba(255, 255, 255, .62);
    font-size: .75rem;
}

.sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(5, 32, 60, .55); z-index: 1040;
}

.content-wrap {
    flex: 1 1 auto;
    min-width: 0;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--line);
    padding: .6rem 1.1rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    min-height: 64px;
    box-shadow: var(--shadow-sm);
}
.topbar-toggle { font-size: 1.5rem; color: var(--brand-blue); padding: 0 .35rem; text-decoration: none; }
.topbar-title { font-weight: 700; color: var(--brand-blue-dark); font-size: 1.05rem; display: flex; align-items: center; }
.topbar-right { margin-left: auto; display: flex; align-items: center; }
.btn-user { background: var(--brand-blue-soft); color: var(--brand-blue-dark); border: 1px solid var(--brand-blue-tint); font-weight: 600; }
.avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--brand-blue); color: #fff; font-weight: 700; font-size: .8rem;
}

.page-content { padding: 1.25rem; flex: 1; }
.page-footer {
    border-top: 1px solid var(--line);
    background: #fff;
    padding: .85rem 1.25rem;
    color: var(--ink-muted);
    font-size: .82rem;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow-md); }
    .content-wrap { margin-left: 0; }
}

/* -------------------------------------------------------------- Cards --- */
.card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-header {
    background: #fff;
    border-bottom: 1px solid var(--line);
    font-weight: 600;
    color: var(--brand-blue-dark);
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}

/* --------------------------------------------------------- Stat tiles --- */
.stat-card {
    border: 1px solid var(--line);
    border-left: 4px solid var(--brand-blue);
    border-radius: var(--radius);
    background: #fff;
    padding: .95rem 1rem;
    height: 100%;
    box-shadow: var(--shadow-sm);
    transition: transform .12s ease, box-shadow .12s ease;
    display: block;
    text-decoration: none;
    color: inherit;
}
a.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); color: inherit; }
.stat-card .stat-label { color: var(--ink-muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; color: var(--brand-blue-dark); line-height: 1.15; }
.stat-card .stat-icon  { font-size: 1.5rem; color: var(--brand-blue); opacity: .85; }
.stat-card.accent-pink   { border-left-color: var(--brand-accent); }
.stat-card.accent-pink .stat-icon { color: var(--brand-accent); }
.stat-card.accent-danger { border-left-color: var(--brand-danger); }
.stat-card.accent-danger .stat-icon { color: var(--brand-danger); }
.stat-card.accent-info   { border-left-color: var(--brand-blue-light); }
.stat-card.accent-info .stat-icon { color: var(--brand-blue-light); }
.stat-card.accent-dark   { border-left-color: var(--brand-success); }
.stat-card.accent-dark .stat-icon { color: var(--brand-success); }

/* ------------------------------------------------------------- Tables --- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { margin-bottom: 0; }
.table > thead {
    background: var(--brand-blue-soft);
}
.table > thead th {
    color: var(--brand-blue-dark);
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 700;
    white-space: nowrap;
    border-bottom: 2px solid var(--brand-blue-tint);
    vertical-align: middle;
}
.table > tbody td { vertical-align: middle; font-size: .875rem; }
.table-hover > tbody > tr:hover > * { background-color: #f4f9ff; }
.ref-cell {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: .8rem;
    font-weight: 600;
    color: var(--brand-blue-dark);
    white-space: nowrap;
}
.concern-cell { max-width: 240px; }
.actions-cell { white-space: nowrap; }

/* Mobile-friendly tables: stack rows into cards below 768px. */
@media (max-width: 767.98px) {
    .table-stack thead { display: none; }
    .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
    .table-stack tr {
        border: 1px solid var(--line);
        border-radius: var(--radius);
        margin-bottom: .75rem;
        padding: .35rem .15rem;
        background: #fff;
        box-shadow: var(--shadow-sm);
    }
    .table-stack td {
        border: 0;
        border-bottom: 1px dashed var(--line);
        padding: .5rem .8rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 1rem;
        text-align: right;
    }
    .table-stack td:last-child { border-bottom: 0; }
    .table-stack td::before {
        content: attr(data-label);
        font-weight: 700;
        font-size: .72rem;
        text-transform: uppercase;
        letter-spacing: .04em;
        color: var(--ink-muted);
        text-align: left;
        flex: 0 0 42%;
    }
    .concern-cell { max-width: none; }
}

/* -------------------------------------------------------- Detail view --- */
.detail-list dt { color: var(--ink-muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.detail-list dd { margin-bottom: .9rem; font-weight: 500; color: var(--ink); word-break: break-word; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 1.35rem; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 1.05rem .3rem; }
.timeline li::before {
    content: ""; position: absolute; left: -1.72rem; top: .3rem;
    width: 11px; height: 11px; border-radius: 50%;
    background: var(--brand-blue); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--brand-blue-soft);
}
.timeline .tl-meta { color: var(--ink-muted); font-size: .78rem; }

.note-item {
    background: var(--surface-alt);
    border: 1px solid var(--line);
    border-left: 3px solid var(--brand-accent);
    border-radius: var(--radius);
    padding: .7rem .9rem;
    margin-bottom: .65rem;
}
.note-item .note-meta { color: var(--ink-muted); font-size: .76rem; }
.note-item .note-body { white-space: pre-wrap; margin: .25rem 0 0; }

/* ------------------------------------------------------------ Filters --- */
.filter-bar { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.filter-bar .form-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-muted); }
.chip {
    display: inline-flex; align-items: center; gap: .35rem;
    background: var(--brand-blue-soft); color: var(--brand-blue-dark);
    border-radius: 2rem; padding: .2rem .65rem; font-size: .78rem; font-weight: 600;
}

/* ------------------------------------------------------------- Login ---- */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, var(--brand-blue-dark), var(--brand-blue) 55%, var(--brand-blue-light));
}
.login-card {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
    overflow: hidden;
    border-top: 5px solid var(--brand-accent);
}
.login-card .login-head { text-align: center; padding: 2rem 2rem .5rem; }
.login-card .login-head .brand-mark {
    width: 62px; height: 62px; border-radius: var(--radius-lg);
    background: var(--brand-blue-soft); color: var(--brand-blue);
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.9rem;
    margin-bottom: .75rem;
}
.login-card .login-body-pad { padding: .5rem 2rem 2rem; }

/* --------------------------------------------------------- Report bars -- */
.bar-track { background: var(--surface-alt); border-radius: 2rem; height: 12px; overflow: hidden; min-width: 90px; border: 1px solid var(--line); }
.bar-fill  { background: linear-gradient(90deg, var(--brand-blue), var(--brand-blue-light)); height: 100%; }
.bar-fill.accent { background: linear-gradient(90deg, var(--brand-accent-dark), var(--brand-accent)); }

/* ---------------------------------------------------------- Printing ---- */
@media print {
    .sidebar, .topbar, .page-footer, .no-print, .filter-bar, .modal, .btn { display: none !important; }
    .content-wrap { margin-left: 0 !important; }
    .page-content { padding: 0 !important; }
    body, .admin-body { background: #fff !important; }
    .card { border: 1px solid #999 !important; box-shadow: none !important; }
    a[href]::after { content: ""; }
    .table > thead { background: #e4effd !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .badge { border: 1px solid #666; color: #000 !important; background: #fff !important; }
}

.print-only { display: none; }
@media print { .print-only { display: block; } }
