/* ==========================================================================
   Aarogyam Clinic - application styles (Bootstrap 5 on top)
   Desktop: fixed sidebar | Tablet: collapsible sidebar | Mobile: cards + bottom bar
   ========================================================================== */
:root {
    --ac-primary: #0b5cad;
    --ac-primary-dark: #084585;
    --ac-primary-soft: #e7f0fd;
    --ac-sidebar: #0a2f5c;
    --ac-sidebar-text: #d6e4fb;
    --ac-bg: #f3f6fb;
    --ac-border: #e3e8e8;
    --ac-text: #1f2d2d;
    --ac-muted: #6b7b7b;
    --ac-sidebar-w: 250px;
    --bs-primary: #0f766e;
    --bs-primary-rgb: 15, 118, 110;
    --bs-link-color: #0f766e;
    --bs-link-hover-color: #115e59;
}

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--ac-bg);
    color: var(--ac-text);
    font-size: 14px;
}

.btn-primary { --bs-btn-bg: var(--ac-primary); --bs-btn-border-color: var(--ac-primary); --bs-btn-hover-bg: var(--ac-primary-dark); --bs-btn-hover-border-color: var(--ac-primary-dark); --bs-btn-active-bg: var(--ac-primary-dark); --bs-btn-disabled-bg: var(--ac-primary); --bs-btn-disabled-border-color: var(--ac-primary); }
.btn-outline-primary { --bs-btn-color: var(--ac-primary); --bs-btn-border-color: var(--ac-primary); --bs-btn-hover-bg: var(--ac-primary); --bs-btn-hover-border-color: var(--ac-primary); --bs-btn-active-bg: var(--ac-primary-dark); }
.text-primary { color: var(--ac-primary) !important; }
.bg-primary-soft { background: var(--ac-primary-soft) !important; }
.form-control:focus, .form-select:focus { border-color: #5fb3aa; box-shadow: 0 0 0 .2rem rgba(15,118,110,.15); }
.form-label { font-weight: 500; margin-bottom: .25rem; font-size: 13px; }
.req::after { content: " *"; color: #dc3545; }

/* ---------------- Layout ---------------- */
.ac-sidebar {
    width: var(--ac-sidebar-w);
    background: var(--ac-sidebar);
    color: var(--ac-sidebar-text);
}
@media (min-width: 992px) {
    .ac-sidebar { position: fixed; top: 0; bottom: 0; left: 0; overflow-y: auto; z-index: 1030; visibility: visible !important; transform: none !important; }
    .ac-main { margin-left: var(--ac-sidebar-w); }
}
.ac-brand { display: flex; align-items: center; gap: 10px; padding: 18px 20px; color: #fff; text-decoration: none; font-weight: 700; font-size: 17px; border-bottom: 1px solid rgba(255,255,255,.08); }
.ac-brand i { font-size: 22px; color: #5eead4; }
.ac-brand:hover { color: #fff; }
.ac-menu { list-style: none; margin: 0; padding: 12px 10px; }
.ac-menu .ac-menu-head { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #7fa8a4; padding: 14px 12px 6px; }
.ac-menu a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; color: var(--ac-sidebar-text); border-radius: 8px; text-decoration: none; margin-bottom: 2px; }
.ac-menu a i { width: 18px; text-align: center; opacity: .85; }
.ac-menu a:hover { background: rgba(255,255,255,.07); color: #fff; }
.ac-menu a.active { background: var(--ac-primary); color: #fff; font-weight: 600; }
.ac-sidebar .offcanvas-header { background: var(--ac-sidebar); }

.ac-topbar { position: sticky; top: 0; z-index: 1020; background: #fff; border-bottom: 1px solid var(--ac-border); padding: 10px 20px; display: flex; align-items: center; gap: 12px; }
.ac-topbar h1 { font-size: 18px; font-weight: 700; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-user { display: flex; align-items: center; gap: 8px; }
.ac-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--ac-primary-soft); color: var(--ac-primary); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.ac-content { padding: 20px; padding-bottom: 90px; }
@media (min-width: 992px) { .ac-content { padding-bottom: 30px; } }

/* Mobile bottom quick actions (role priorities) */
.ac-bottombar { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--ac-border); display: flex; z-index: 1040; box-shadow: 0 -2px 10px rgba(0,0,0,.05); }
.ac-bottombar a { flex: 1; text-align: center; padding: 8px 2px 6px; color: var(--ac-muted); text-decoration: none; font-size: 11px; }
.ac-bottombar a i { display: block; font-size: 18px; margin-bottom: 2px; }
.ac-bottombar a.active { color: var(--ac-primary); font-weight: 600; }

/* ---------------- Cards / tiles ---------------- */
.card { border: 1px solid var(--ac-border); border-radius: 12px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: #fff; border-bottom: 1px solid var(--ac-border); font-weight: 600; padding: 12px 16px; border-radius: 12px 12px 0 0 !important; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-header .ms-auto { margin-left: auto; }
.stat-tile { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: #fff; border: 1px solid var(--ac-border); border-radius: 12px; height: 100%; text-decoration: none; color: inherit; }
.stat-tile:hover { border-color: #b8d8d4; color: inherit; }
.stat-tile .icon { width: 42px; height: 42px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.stat-tile .num { font-size: 22px; font-weight: 700; line-height: 1.1; }
.stat-tile .lbl { font-size: 12px; color: var(--ac-muted); }
.ic-teal { background: #e6f4f2; color: #0f766e; }
.ic-blue { background: #e7f0fd; color: #1d63d8; }
.ic-orange { background: #fff1e6; color: #c2570c; }
.ic-purple { background: #f1ebfd; color: #6d3fd1; }
.ic-green { background: #e7f7ec; color: #188038; }
.ic-yellow { background: #fff8db; color: #9a6b00; }
.ic-red { background: #fdecec; color: #c62828; }
.ic-grey { background: #eef1f1; color: #56615f; }

/* ---------------- Status badges: colour + icon + text ---------------- */
.st-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.st-green { background: #e7f7ec; color: #146c2e; border-color: #b7e4c4; }
.st-blue { background: #e7f0fd; color: #1a56b8; border-color: #bcd3f7; }
.st-orange { background: #fff1e6; color: #a84b0a; border-color: #fbd3b3; }
.st-yellow { background: #fff8db; color: #7a5500; border-color: #f3dc8a; }
.st-purple { background: #f1ebfd; color: #5b33b3; border-color: #d6c6f7; }
.st-red { background: #fdecec; color: #b42318; border-color: #f5c2c0; }
.st-grey { background: #eef1f1; color: #4b5856; border-color: #d7dddd; }

/* Row accents for appointment grids */
.table > tbody > tr > td:first-child { border-left: 4px solid transparent; }
.table > tbody > tr.row-green > td:first-child { border-left-color: #22a55a; }
.table > tbody > tr.row-blue > td:first-child { border-left-color: #2f6fe0; }
.table > tbody > tr.row-orange > td:first-child { border-left-color: #ea7a24; }
.table > tbody > tr.row-yellow > td:first-child { border-left-color: #e6b800; }
.table > tbody > tr.row-purple > td:first-child { border-left-color: #7c4ddf; }
.table > tbody > tr.row-red > td:first-child { border-left-color: #d64545; }
.table > tbody > tr.row-grey > td:first-child { border-left-color: #a5b0ae; }

.legend { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------------- Tables ---------------- */
.table { margin-bottom: 0; }
.table thead th { background: #f6f9f9; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: #506260; font-weight: 600; white-space: nowrap; }
.table td { vertical-align: middle; }
.table-actions { white-space: nowrap; }
.table-actions .btn { padding: 2px 8px; font-size: 12px; }
.empty-state { text-align: center; padding: 36px 16px; color: var(--ac-muted); }
.empty-state i { font-size: 32px; display: block; margin-bottom: 8px; opacity: .5; }

/* Tables become cards on phones: add class "table-stack" + data-label on each td */
@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 { background: #fff; border: 1px solid var(--ac-border); border-radius: 10px; margin-bottom: 10px; padding: 8px 10px; }
    .table-stack > tbody > tr > td:first-child { border-left: 0; }
    .table-stack tr.row-green { border-left: 4px solid #22a55a; }
    .table-stack tr.row-blue { border-left: 4px solid #2f6fe0; }
    .table-stack tr.row-orange { border-left: 4px solid #ea7a24; }
    .table-stack tr.row-yellow { border-left: 4px solid #e6b800; }
    .table-stack tr.row-purple { border-left: 4px solid #7c4ddf; }
    .table-stack tr.row-red { border-left: 4px solid #d64545; }
    .table-stack td { border: 0; padding: 4px 0; text-align: left !important; }
    .table-stack td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--ac-muted); text-transform: uppercase; }
    .table-stack td.table-actions { padding-top: 8px; white-space: normal; }
    .table-stack td.table-actions .btn { margin: 2px 2px 2px 0; padding: 5px 10px; }
}

/* ---------------- Slots ---------------- */
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.slot-btn { border: 1px solid #b8d8d4; background: #fff; color: var(--ac-primary-dark); border-radius: 8px; padding: 8px 4px; text-align: center; font-weight: 600; font-size: 13px; text-decoration: none; display: block; }
.slot-btn:hover { background: var(--ac-primary-soft); color: var(--ac-primary-dark); }
.slot-btn.selected { background: var(--ac-primary); color: #fff; border-color: var(--ac-primary); }
.slot-btn.disabled, .slot-btn[disabled] { background: #f1f3f3; color: #a3adab; border-color: #e1e6e6; text-decoration: line-through; pointer-events: none; }
.slot-btn small { display: block; font-weight: 400; font-size: 10px; text-decoration: none; }

/* ---------------- Queue board ---------------- */
.queue-now { background: linear-gradient(135deg, #0f766e, #14958a); color: #fff; border-radius: 12px; padding: 16px; }
.queue-now .token { font-size: 40px; font-weight: 800; line-height: 1; }
.token-chip { display: inline-flex; align-items: center; justify-content: center; min-width: 38px; height: 30px; padding: 0 8px; border-radius: 8px; background: var(--ac-primary-soft); color: var(--ac-primary-dark); font-weight: 700; }

/* ---------------- Patient banner (consultation) ---------------- */
.patient-banner { background: #fff; border: 1px solid var(--ac-border); border-radius: 12px; padding: 14px 16px; display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; }
.patient-banner .pb-name { font-size: 18px; font-weight: 700; }
.patient-banner .pb-item { font-size: 13px; color: var(--ac-muted); }
.patient-banner .pb-item b { color: var(--ac-text); font-weight: 600; }

.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ac-primary-dark); margin: 4px 0 10px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--ac-muted); font-weight: 500; }
.kv dd { margin: 0; }

/* ---------------- Custom controls inside Bootstrap forms ---------------- */
.dtp-wrapper { display: block !important; width: 100%; }
.dtp-input { width: 100% !important; height: 38px; border: 1px solid #dee2e6 !important; border-radius: 6px !important; font-size: 14px !important; }
.sdd-wrapper { font-family: inherit !important; font-size: 14px !important; }
.sdd-header { min-height: 38px; border-color: #dee2e6 !important; border-radius: 6px !important; padding: 7px 12px !important; }
.cgv-btn { border-radius: 6px; font-size: 13px; }
.cgv-scroll-wrapper { border-radius: 8px; }

/* ---------------- Auth pages ---------------- */
.auth-wrap { min-height: 100vh; display: flex; }
.auth-visual { flex: 1.1; background: linear-gradient(135deg, rgba(11,59,58,.92), rgba(15,118,110,.85)); color: #fff; display: flex; align-items: center; justify-content: center; padding: 40px; }
.auth-visual h2 { font-weight: 800; font-size: 34px; }
.auth-visual ul { list-style: none; padding: 0; margin-top: 24px; }
.auth-visual li { margin: 10px 0; opacity: .92; }
.auth-visual li i { width: 26px; color: #5eead4; }
.auth-panel { flex: 1; display: flex; align-items: center; justify-content: center; padding: 30px 18px; background: #fff; }
.auth-box { width: 100%; max-width: 420px; }
.auth-box .logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; color: var(--ac-primary-dark); margin-bottom: 18px; }
@media (max-width: 991.98px) { .auth-visual { display: none; } }

/* ---------------- Print ---------------- */
.print-sheet { max-width: 800px; margin: 20px auto; background: #fff; padding: 28px; border: 1px solid var(--ac-border); border-radius: 8px; }
.print-head { display: flex; justify-content: space-between; border-bottom: 2px solid var(--ac-primary); padding-bottom: 10px; margin-bottom: 14px; }
.print-head h2 { margin: 0; color: var(--ac-primary-dark); font-weight: 800; font-size: 22px; }
.rx-symbol { font-size: 28px; font-weight: 800; color: var(--ac-primary); font-family: Georgia, serif; }
.token-slip { max-width: 320px; text-align: center; }
.token-slip .big { font-size: 64px; font-weight: 800; line-height: 1; color: var(--ac-primary-dark); }
@media print {
    .no-print { display: none !important; }
    body { background: #fff; }
    .print-sheet { border: 0; margin: 0; max-width: none; padding: 0; }
}

/* ---------- Brand (logo colours: blue + green) & vibrant menu selection ---------- */
:root { --ac-accent: #2e9e3f; --ac-accent-2: #7ed957; }
.brand-logo { width: 34px; height: 34px; border-radius: 9px; background: #fff; padding: 2px; object-fit: contain; }
.auth-logo { max-width: 220px; width: 70%; height: auto; }
.ac-menu .ac-menu-head { color: #8fb3ea; }
.ac-menu a:hover { background: rgba(126,217,87,.14); color: #fff; }
/* active menu / bottom-bar item: see modern.css (same look as AarogyamPath) */

/* ---------- Consultation: bilingual fields + voice-to-text ---------- */
.bi-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 767.98px) { .bi-row { grid-template-columns: 1fr; } }
.bi-field { position: relative; }
.bi-field .bi-lang { position: absolute; top: -9px; left: 10px; background: #fff; padding: 0 6px; font-size: 11px; color: var(--ac-muted); z-index: 2; }
.bi-field textarea, .bi-field input { padding-right: 44px; }
.mic-btn { position: absolute; right: 6px; top: 6px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--ac-primary-soft); color: var(--ac-primary); z-index: 2; }
.mic-btn:hover { background: var(--ac-primary); color: #fff; }
.mic-btn.listening { background: #dc3545; color: #fff; animation: micPulse 1s infinite; }
@keyframes micPulse { 0% { box-shadow: 0 0 0 0 rgba(220,53,69,.6); } 70% { box-shadow: 0 0 0 10px rgba(220,53,69,0); } 100% { box-shadow: 0 0 0 0 rgba(220,53,69,0); } }
.hindi, [lang="hi"] { font-family: "Noto Sans Devanagari", "Mangal", "Nirmala UI", sans-serif; }
.rx-table td, .rx-table th { vertical-align: middle; }
.locked .mic-btn { display: none; }

/* ---------- Payment colour code: fully paid / part paid / unpaid ---------- */
tr.pay-full > td { background: #e3f7e8 !important; } tr.pay-full > td:first-child { border-left: 5px solid #1e9e45; }
tr.pay-part > td { background: #fff4d6 !important; } tr.pay-part > td:first-child { border-left: 5px solid #f0a400; }
tr.pay-none > td { background: #fde4e4 !important; } tr.pay-none > td:first-child { border-left: 5px solid #dc3545; }
.pay-legend { display: flex; gap: 14px; flex-wrap: wrap; }
.pay-legend span { padding: 2px 10px; border-radius: 12px; font-weight: 600; }
.pay-legend .pay-full { background: #e3f7e8; color: #146c2e; } .pay-legend .pay-part { background: #fff4d6; color: #8a5a00; } .pay-legend .pay-none { background: #fde4e4; color: #a61b29; }

/* ---------- Printing list pages inside the main layout ---------- */
.print-only { display: none; }
@media print {
    .ac-sidebar, .ac-topbar, .ac-bottombar, .offcanvas, .alert-dismissible .btn-close { display: none !important; }
    .ac-main { margin-left: 0 !important; }
    .print-only { display: block !important; }
    .card { border: 0; box-shadow: none; }
    table { font-size: 11px; }
    tr.pay-full > td, tr.pay-part > td, tr.pay-none > td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ===== Phase 1: dashboard ===== */
.dash-chart { position: relative; height: 240px; }
.pipe-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: #f0efec; gap: 2px; }
.pipe-bar > span { display: block; height: 100%; min-width: 4px; }
.pipe-booked { background: #86b6ef; }
.pipe-waiting { background: #eda100; }
.pipe-incons { background: #2a78d6; }
.pipe-done { background: #0ca30c; }
.pipe-cancel { background: #8a8984; }
.pipe-noshow { background: #e34948; }
.pipe-empty { background: #f0efec; }
.pipe-chip { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .6rem; border: 1px solid #e5e4df; border-radius: 999px; font-size: .85rem; background: #fff; }
.pipe-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.hbar-list { list-style: none; padding: 0; margin: 0; }
.hbar-list li { margin-bottom: .55rem; }
.hbar { height: 8px; background: #f0efec; border-radius: 4px; overflow: hidden; margin-top: 3px; }
.hbar > span { display: block; height: 100%; background: #2a78d6; border-radius: 0 4px 4px 0; }
.queue-card { border: 1px solid #e5e4df; border-radius: .6rem; padding: .6rem .75rem; background: #fff; height: 100%; }
.ac-branch .form-select-sm { font-size: .82rem; }

/* ===== Phase 1: consultation ===== */
.consult-nav { position: sticky; top: 0; z-index: 5; background: var(--bs-body-bg, #fff); padding: .35rem 0; }
.consult-nav .btn { font-size: .78rem; }
.voice-orders { border-left: 4px solid #2a78d6; }
.vo-mic.listening { background: #e34948; border-color: #e34948; animation: voPulse 1.2s infinite; }
@keyframes voPulse { 0% { box-shadow: 0 0 0 0 rgba(227,73,72,.5); } 70% { box-shadow: 0 0 0 10px rgba(227,73,72,0); } 100% { box-shadow: 0 0 0 0 rgba(227,73,72,0); } }
.vo-table td, .vo-table th { vertical-align: middle; }
.vital-alert { border-color: #e34948 !important; background: #fdecec !important; }
@media print { .consult-nav, .voice-orders { display: none !important; } }

/* ===== Phase 1: rights matrix ===== */
.rights-actions label { margin: 0 .9rem 0 .3rem; }
.rights-table td { padding-top: .45rem; padding-bottom: .45rem; }

/* ===== Phase 1: patient file ===== */
.timeline-list { list-style: none; margin: 0; padding: 0; }
.timeline-list li { display: flex; gap: .75rem; padding: .55rem 0; border-bottom: 1px dashed #e5e4df; }
.timeline-list li:last-child { border-bottom: 0; }
.tl-icon { flex: 0 0 32px; height: 32px; border-radius: 50%; background: #eaf2fc; color: #2a78d6; display: inline-flex; align-items: center; justify-content: center; }
.ac-search .dropdown-menu { top: 100%; left: 0; }

/* ===== Phase 1: calendar, diagnoses ===== */
.cal-item { border: 1px solid #e5e4df; border-radius: .5rem; padding: .35rem .5rem; margin-bottom: .4rem; background: #fff; }
.cal-item:hover { border-color: #2a78d6; }
.dx-chip { display: inline-flex; align-items: center; gap: .25rem; border: 1px solid #cde2fb; background: #f3f8fe; border-radius: 999px; padding: .15rem .6rem; font-size: .85rem; }
.dx-primary { border-color: #2a78d6; background: #e3eefc; }
