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

:root {
    --primary: #0d9488;          /* teal 600 */
    --primary-dark: #0f766e;     /* teal 700 */
    --primary-light: #ccfbf1;    /* teal 100 */
    --sidebar-bg: #0f172a;       /* slate 900 */
    --sidebar-hover: #1e293b;    /* slate 800 */
    --bg: #f1f5f9;               /* slate 100 */
    --surface: #ffffff;
    --border: #e2e8f0;           /* slate 200 */
    --text: #0f172a;             /* slate 900 */
    --text-muted: #64748b;       /* slate 500 */
    --radius: 14px;
    --shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.08);
    --shadow: 0 4px 12px rgba(15,23,42,.08);
    --shadow-lg: 0 10px 30px rgba(15,23,42,.12);
}

html, body {
    font-family: 'Inter', system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    font-size: 15px;
}

h1, h2, h3, h4, h5 { font-weight: 700; color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

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

.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 1000;
}
.sidebar-brand {
    padding: 22px 20px;
    font-size: 1.25rem;
    font-weight: 800;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .logo {
    width: 36px; height: 36px; border-radius: 10px;
    background: var(--primary);
    display: grid; place-items: center;
    font-size: 1.1rem;
}
.sidebar-nav { padding: 14px 12px; flex: 1; overflow-y: auto; }
.nav-section {
    font-size: .7rem; text-transform: uppercase; letter-spacing: .08em;
    color: #64748b; margin: 16px 12px 6px; font-weight: 600;
}
.nav-item-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; margin: 2px 0;
    border-radius: 10px;
    color: #cbd5e1; font-weight: 500;
    transition: all .15s;
}
.nav-item-link:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item-link.active { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.nav-item-link .ico { font-size: 1.1rem; width: 22px; text-align: center; }

.sidebar-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,.08); }

/* ---------- Main content ---------- */
.main-wrap { flex: 1; margin-left: 260px; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    height: 64px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 26px;
    position: sticky; top: 0; z-index: 500;
}
.topbar-title { font-size: 1.05rem; font-weight: 600; color: var(--text-muted); }
.user-chip {
    display: flex; align-items: center; gap: 10px;
    background: var(--bg); padding: 6px 14px; border-radius: 999px;
    font-weight: 500; font-size: .9rem;
}
.user-chip .avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: grid; place-items: center; font-weight: 700; font-size: .8rem;
}

.content { padding: 26px; flex: 1; }

/* ---------- Page header ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.page-head h1 { font-size: 1.6rem; margin: 0; }
.page-head .sub { color: var(--text-muted); font-size: .9rem; margin-top: 2px; }

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px 22px; }
.card-title { font-size: 1rem; font-weight: 600; margin-bottom: 16px; }

/* ---------- Stat cards ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px; margin-bottom: 26px; }
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    display: flex; align-items: center; gap: 16px;
    transition: transform .15s, box-shadow .15s;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat .stat-ico {
    width: 52px; height: 52px; border-radius: 14px;
    display: grid; place-items: center; font-size: 1.5rem; flex-shrink: 0;
}
.stat .stat-val { font-size: 1.7rem; font-weight: 800; line-height: 1; }
.stat .stat-label { color: var(--text-muted); font-size: .82rem; margin-top: 4px; }
.ico-teal { background: #ccfbf1; color: #0d9488; }
.ico-blue { background: #dbeafe; color: #2563eb; }
.ico-amber { background: #fef3c7; color: #d97706; }
.ico-green { background: #dcfce7; color: #16a34a; }
.ico-rose { background: #ffe4e6; color: #e11d48; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 18px; border-radius: 10px;
    font-weight: 600; font-size: .9rem; border: 1px solid transparent;
    cursor: pointer; transition: all .15s; line-height: 1.2;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); color: #fff; }
.btn-light { background: var(--bg); color: var(--text); border-color: var(--border); }
.btn-light:hover { background: #e2e8f0; }
.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: #fff; color: #e11d48; border-color: #fecdd3; }
.btn-danger:hover { background: #fff1f2; }
.btn-sm { padding: 6px 12px; font-size: .82rem; border-radius: 8px; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Forms ---------- */
.form-label { font-weight: 600; font-size: .85rem; margin-bottom: 6px; display: block; color: #334155; }
.form-control, .form-select {
    width: 100%; padding: 10px 12px;
    border: 1px solid var(--border); border-radius: 10px;
    font-size: .92rem; background: #fff; color: var(--text);
    transition: border-color .15s, box-shadow .15s; font-family: inherit;
}
.form-control:focus, .form-select:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13,148,136,.15);
}
.field { margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.validation-message, .text-danger { color: #e11d48; font-size: .82rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left; padding: 12px 14px; font-size: .78rem;
    text-transform: uppercase; letter-spacing: .04em;
    color: var(--text-muted); border-bottom: 2px solid var(--border); font-weight: 600;
}
.table td { padding: 13px 14px; border-bottom: 1px solid var(--border); font-size: .9rem; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #f8fafc; }
.table .empty { text-align: center; color: var(--text-muted); padding: 30px; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 11px; border-radius: 999px; font-size: .78rem; font-weight: 600;
}
.badge-token { background: var(--sidebar-bg); color: #fff; font-size: .9rem; padding: 4px 12px; }
.b-waiting { background: #f1f5f9; color: #475569; }
.b-doctor { background: #dbeafe; color: #1d4ed8; }
.b-prescribed { background: #cffafe; color: #0e7490; }
.b-dispensing { background: #fef3c7; color: #b45309; }
.b-completed { background: #dcfce7; color: #15803d; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: 10px; font-size: .9rem; margin-bottom: 0; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; }

/* ---------- List group (dispensing) ---------- */
.list-group { display: flex; flex-direction: column; gap: 6px; }
.list-item {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
    background: #fff; cursor: pointer; text-align: left; width: 100%; font: inherit;
    transition: all .12s;
}
.list-item:hover { border-color: var(--primary); background: #f0fdfa; }
.list-item.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.list-item.active .badge-token { background: rgba(255,255,255,.25); }

/* ---------- Auth (login) ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
    background:
        linear-gradient(rgba(15,118,110,.42), rgba(15,23,42,.58)),
        url('/img/hospital-bg.png') center / cover no-repeat fixed,
        linear-gradient(135deg, #0f766e, #0f172a); }
.auth-card { background: rgba(255,255,255,.38); border-radius: 20px; box-shadow: var(--shadow-lg);
    width: 100%; max-width: 410px; padding: 40px 36px;
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    border: 1px solid rgba(255,255,255,.4); }
.auth-logo { width: 60px; height: 60px; border-radius: 16px; background: var(--primary);
    display: grid; place-items: center; font-size: 1.8rem; margin: 0 auto 16px; color:#fff; }
.auth-card h1 { text-align: center; font-size: 1.5rem; margin: 0 0 4px; }
.auth-card .muted { text-align: center; color: var(--text-muted); margin-bottom: 26px; font-size: .9rem; }
.cred-hint { margin-top: 18px; padding: 12px; background: var(--bg); border-radius: 10px;
    font-size: .82rem; color: var(--text-muted); text-align: center; }

/* ---------- Helpers ---------- */
.flex { display: flex; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 16px; } .mt-4 { margin-top: 24px; }
.mb-3 { margin-bottom: 16px; } .mb-4 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.text-end { text-align: right; }
.text-center { text-align: center; }
.fw-bold { font-weight: 700; }
.w-100 { width: 100%; }
.flex-wrap { flex-wrap: wrap; }

/* ---------- Mobile menu button + overlay ---------- */
.menu-btn {
    display: none; background: none; border: none;
    font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--text);
    padding: 4px 8px; border-radius: 8px;
}
.menu-btn:hover { background: var(--bg); }
.sidebar-overlay { display: none; }

/* Two-column split (dispensing) — responsive */
.two-col-320 { display: grid; grid-template-columns: 320px 1fr; gap: 18px; align-items: start; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: translateX(0); }
    .main-wrap { margin-left: 0; }
    .menu-btn { display: inline-flex; align-items: center; }
    .sidebar-overlay.show {
        display: block; position: fixed; inset: 0;
        background: rgba(15,23,42,.45); z-index: 900;
    }
    .grid-2, .grid-3, .grid-4, .two-col-320 { grid-template-columns: 1fr; }
    .content { padding: 16px; }
    .topbar { padding: 0 14px; }
    .topbar-title { font-size: .92rem; }
    .page-head h1 { font-size: 1.35rem; }
    .user-chip { max-width: 160px; }
    .user-chip .email { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .stat .stat-val { font-size: 1.45rem; }
}

@media (max-width: 480px) {
    .user-chip .email { display: none; }
    .topbar-title { font-size: .82rem; }
    .stats-grid { gap: 12px; }
}

/* Blazor error UI */
#blazor-error-ui {
    background: #fee2e2; color: #991b1b; bottom: 0; left: 0; right: 0;
    display: none; padding: 12px 20px; position: fixed; z-index: 2000; box-shadow: var(--shadow-lg);
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 16px; top: 10px; }
.blazor-error-boundary { background: #fee2e2; padding: 16px; border-radius: 10px; color: #991b1b; }

/* ---- Token slip (compact, modern) ---- */
.tslip { max-width: 300px; margin: 0 auto; background: #fff; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; box-shadow: 0 4px 16px rgba(15,23,42,.08); font-size: .82rem; }
.tslip-head { background: var(--primary); color: #fff; text-align: center; padding: 10px 12px; }
.tslip-head .name { font-weight: 800; font-size: 1.05rem; letter-spacing: .3px; }
.tslip-head .sub { font-size: .7rem; opacity: .85; text-transform: uppercase; letter-spacing: 1px; }
.tslip-token { text-align: center; padding: 10px 0 8px; border-bottom: 1px dashed var(--border); }
.tslip-token .label { font-size: .65rem; letter-spacing: 1.5px; color: var(--text-muted); }
.tslip-token .num { font-size: 2.6rem; font-weight: 800; line-height: 1; color: var(--primary); }
.tslip-body { padding: 8px 14px; }
.tslip-row { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; }
.tslip-row span:first-child { color: var(--text-muted); }
.tslip-row span:last-child { font-weight: 600; text-align: right; }
.tslip-foot { text-align: center; font-size: .7rem; color: var(--text-muted); padding: 8px 12px 10px; border-top: 1px dashed var(--border); }
@media print { .tslip { box-shadow: none; border-radius: 0; } }

/* ---- Searchable combo box ---- */
.combo { position: relative; }
.combo-list { position: fixed; z-index: 2000; margin: 4px 0 0; padding: 4px; list-style: none; max-height: 220px; overflow-y: auto; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(15,23,42,.15); }
.combo-list li { padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: .9rem; }
.combo-list li:hover { background: #e6f6f3; color: var(--primary); }
.clinic-logo svg{width:100%;height:auto;display:block;}
