/* ===========================================================
   Maurya Hospital HMS Prototype — AgentNation
   Clinical, calm, trustworthy. Teal / medical-blue + white.
   =========================================================== */

:root {
  --teal:        #0E8C8C;
  --teal-dark:   #0A6E6E;
  --teal-soft:   #E6F4F4;
  --teal-softer: #F2F9F9;
  --blue:        #1E6FB8;
  --blue-soft:   #E8F1FA;
  --accent:      #F2994A;   /* warm accent */
  --accent-soft: #FCEDDD;
  --ink:         #1F2A37;
  --ink-2:       #4B5563;
  --ink-3:       #6B7280;
  --line:        #E5E9EE;
  --line-2:      #EEF1F5;
  --bg:          #F6F8FA;
  --white:       #FFFFFF;
  --green:       #1FA971;
  --green-soft:  #E5F6EF;
  --red:         #D14343;
  --red-soft:    #FBEAEA;
  --amber:       #C98A12;
  --amber-soft:  #FBF1DC;
  --shadow-sm:   0 1px 2px rgba(16,40,60,.06), 0 1px 3px rgba(16,40,60,.05);
  --shadow:      0 2px 8px rgba(16,40,60,.06), 0 8px 24px rgba(16,40,60,.05);
  --shadow-lg:   0 10px 40px rgba(16,40,60,.12);
  --radius:      16px;
  --radius-sm:   12px;
  --sidebar-w:   256px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', 'Noto Sans Devanagari', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Devanagari sizing — Noto Sans Devanagari runs a touch small; nudge line-height */
html[lang="hi"] body { line-height: 1.6; }

button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ---------- Language toggle visibility ---------- */
.lang-hi, .lang-en { display: none; }
html[lang="hi"] .lang-hi { display: inline; }
html[lang="en"] .lang-en { display: inline; }
/* block-level paired elements */
.lang-hi.block, .lang-en.block { display: none; }
html[lang="hi"] .lang-hi.block { display: block; }
html[lang="en"] .lang-en.block { display: block; }

/* ============================ LAYOUT ============================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--white);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 40;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--line-2);
}
.brand-logo {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--teal), var(--blue));
  display: grid; place-items: center;
  color: #fff; flex: 0 0 auto;
  box-shadow: var(--shadow-sm);
}
.brand-logo svg { width: 24px; height: 24px; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -.01em; line-height: 1.2; }
.brand-sub  { font-size: 11px; color: var(--ink-3); margin-top: 2px; }

.nav { padding: 12px 12px 8px; display: flex; flex-direction: column; gap: 3px; }
.nav-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3);
  padding: 12px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: 14.5px; font-weight: 500;
  border: 1px solid transparent;
  transition: background .14s, color .14s;
  text-align: left; width: 100%; background: transparent;
}
.nav-item svg { width: 21px; height: 21px; flex: 0 0 auto; opacity: .85; }
.nav-item:hover { background: var(--teal-softer); color: var(--teal-dark); }
.nav-item.active {
  background: var(--teal-soft); color: var(--teal-dark);
  font-weight: 600; border-color: #D3EBEB;
}
.nav-item.active svg { opacity: 1; }
.nav-badge {
  margin-inline-start: auto;
  background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; display: grid; place-items: center;
}
.sidebar-foot {
  margin-top: auto; padding: 14px 16px;
  border-top: 1px solid var(--line-2);
  font-size: 11px; color: var(--ink-3);
}
.sidebar-foot strong { color: var(--ink-2); }

/* ---------- Main column ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px;
  padding: 12px 24px;
}
.menu-btn {
  display: none; width: 40px; height: 40px;
  border: 1px solid var(--line); border-radius: 10px;
  background: #fff; place-items: center; color: var(--ink-2);
}
.menu-btn svg { width: 22px; height: 22px; }
.topbar-title { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.topbar-date  { font-size: 12.5px; color: var(--ink-3); margin-top: 1px; }
.topbar-right { margin-inline-start: auto; display: flex; align-items: center; gap: 10px; }

.demo-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-soft); color: #9A5B1E;
  border: 1px solid #F2D3B0;
  font-size: 12px; font-weight: 700;
  padding: 5px 11px; border-radius: 999px;
}
.demo-badge::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 3px rgba(242,153,74,.2);
}

.lang-toggle {
  display: inline-flex; align-items: center;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px; gap: 2px;
}
.lang-toggle button {
  border: none; background: transparent; color: var(--ink-3);
  font-size: 13px; font-weight: 600; padding: 5px 12px;
  border-radius: 999px; transition: all .14s;
}
.lang-toggle button.active {
  background: var(--white); color: var(--teal-dark);
  box-shadow: var(--shadow-sm);
}

.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--teal));
  color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 14px; flex: 0 0 auto;
}

/* ---------- Page area ---------- */
.page-wrap { padding: 24px; max-width: 1320px; width: 100%; margin: 0 auto; }
.page { display: none; animation: fade .25s ease; }
.page.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.page-head p { color: var(--ink-3); font-size: 14px; margin: 6px 0 0; }

/* ============================ COMPONENTS ============================ */
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px; border-bottom: 1px solid var(--line-2);
}
.card-head h3 { margin: 0; font-size: 15.5px; font-weight: 700; }
.card-head .sub { font-size: 12.5px; color: var(--ink-3); margin-inline-start: auto; }

.grid { display: grid; gap: 18px; }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.span-2 { grid-column: span 2; }

/* KPI stat cards */
.stat {
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat-ico {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center; margin-bottom: 14px;
}
.stat-ico svg { width: 23px; height: 23px; }
.ico-teal  { background: var(--teal-soft);  color: var(--teal-dark); }
.ico-blue  { background: var(--blue-soft);  color: var(--blue); }
.ico-green { background: var(--green-soft); color: var(--green); }
.ico-amber { background: var(--amber-soft); color: var(--amber); }
.stat-val { font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.stat-lbl { font-size: 13.5px; color: var(--ink-3); margin-top: 7px; font-weight: 500; }
.stat-trend {
  font-size: 12px; font-weight: 600; margin-top: 9px;
  display: inline-flex; align-items: center; gap: 4px;
}
.trend-up   { color: var(--green); }
.trend-flat { color: var(--ink-3); }

/* Chart */
.chart { display: flex; align-items: flex-end; gap: 12px; height: 180px; padding: 8px 4px 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.bar {
  width: 100%; max-width: 38px; border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, var(--teal), #2BB3B3);
  transition: height .6s cubic-bezier(.2,.8,.2,1);
}
.bar.muted { background: linear-gradient(180deg, #BFE0E0, #D7ECEC); }
.bar-lbl { font-size: 11.5px; color: var(--ink-3); font-weight: 500; }

/* Tables */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; font-size: 11.5px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3);
  padding: 11px 16px; border-bottom: 1px solid var(--line); background: var(--teal-softer);
}
.tbl td {
  padding: 13px 16px; font-size: 14px; border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tr.row-click { cursor: pointer; transition: background .12s; }
.tbl tr.row-click:hover { background: var(--teal-softer); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

.uid { font-family: 'Inter', monospace; font-size: 12.5px; color: var(--ink-2); font-weight: 600; }

/* Patient avatar mini */
.p-cell { display: flex; align-items: center; gap: 11px; }
.p-ava {
  width: 36px; height: 36px; border-radius: 10px; flex: 0 0 auto;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
  background: var(--teal-soft); color: var(--teal-dark);
}
.p-name { font-weight: 600; font-size: 14px; }
.p-meta { font-size: 12px; color: var(--ink-3); margin-top: 1px; }

/* Pills / status */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; }
.pill-wait  { background: var(--amber-soft); color: var(--amber); }
.pill-wait::before  { background: var(--amber); }
.pill-active{ background: var(--blue-soft); color: var(--blue); }
.pill-active::before{ background: var(--blue); animation: pulse 1.4s infinite; }
.pill-done  { background: var(--green-soft); color: var(--green); }
.pill-done::before  { background: var(--green); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.35} }

.tag { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 6px; background: var(--line-2); color: var(--ink-2); }
.tag-exempt { background: var(--green-soft); color: var(--green); }
.tag-tax    { background: var(--blue-soft); color: var(--blue); }
.tag-h1     { background: var(--red-soft);  color: var(--red); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 12px; font-size: 14.5px; font-weight: 600;
  border: 1px solid transparent; transition: all .15s; white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--teal); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--teal-dark); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-blue { background: var(--blue); color: #fff; box-shadow: var(--shadow-sm); }
.btn-blue:hover { background: #195C99; transform: translateY(-1px); }
.btn-accent { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-accent:hover { background: #E0852F; transform: translateY(-1px); }
.btn-ghost { background: #fff; color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--teal); color: var(--teal-dark); background: var(--teal-softer); }
.btn-soft { background: var(--teal-soft); color: var(--teal-dark); }
.btn-soft:hover { background: #D3EBEB; }
.btn-lg { padding: 14px 24px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 13px; font-size: 13px; border-radius: 10px; }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field label .req { color: var(--red); }
.input, .select, .textarea {
  width: 100%; padding: 12px 14px; font-size: 14.5px; font-family: inherit;
  border: 1px solid var(--line); border-radius: 11px; background: #fff; color: var(--ink);
  transition: border .14s, box-shadow .14s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(14,140,140,.14);
}
.textarea { resize: vertical; min-height: 78px; }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; }
.seg button { border: none; background: transparent; padding: 9px 18px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--ink-3); }
.seg button.active { background: #fff; color: var(--teal-dark); box-shadow: var(--shadow-sm); }

.hint { font-size: 12.5px; color: var(--ink-3); }

/* Banner / notice */
.notice {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 16px; border-radius: 12px; font-size: 13.5px;
  background: var(--blue-soft); color: #1A5C9A; border: 1px solid #CCE2F5;
}
.notice svg { width: 20px; height: 20px; flex: 0 0 auto; margin-top: 1px; }
.notice-amber { background: var(--amber-soft); color: #8A6212; border-color: #F0DBA8; }
.notice-green { background: var(--green-soft); color: #157A53; border-color: #BCE7D4; }

/* Success state */
.success-box {
  text-align: center; padding: 36px 24px;
}
.success-ring {
  width: 76px; height: 76px; border-radius: 50%;
  background: var(--green-soft); color: var(--green);
  display: grid; place-items: center; margin: 0 auto 18px;
  animation: pop .35s cubic-bezier(.2,1.2,.3,1);
}
.success-ring svg { width: 40px; height: 40px; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.success-box h2 { margin: 0 0 6px; font-size: 22px; }
.success-box p { color: var(--ink-3); margin: 0 0 18px; }
.token-card {
  display: inline-flex; flex-direction: column; gap: 4px;
  background: var(--teal-soft); border: 1px dashed var(--teal);
  border-radius: 14px; padding: 14px 26px; margin: 4px 8px;
}
.token-card .k { font-size: 11.5px; color: var(--teal-dark); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.token-card .v { font-size: 26px; font-weight: 800; color: var(--teal-dark); letter-spacing: .01em; }

/* Prescription pad medicine rows */
.med-row {
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; margin-bottom: 10px;
}
.med-row .mname { font-weight: 600; font-size: 14.5px; }
.med-row .mdose { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.x-btn {
  width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: var(--red); display: grid; place-items: center;
}
.x-btn:hover { background: var(--red-soft); border-color: #EBC4C4; }
.x-btn svg { width: 17px; height: 17px; }

/* searchable list dropdown */
.search-wrap { position: relative; }
.search-list {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 20;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-lg); max-height: 260px; overflow-y: auto; padding: 6px;
}
.search-list.hidden { display: none; }
.search-opt { padding: 10px 12px; border-radius: 9px; cursor: pointer; font-size: 14px; display: flex; justify-content: space-between; gap: 10px; }
.search-opt:hover { background: var(--teal-softer); }
.search-opt .so-meta { font-size: 12px; color: var(--ink-3); }

/* vitals chips */
.vitals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.vital { background: var(--teal-softer); border: 1px solid var(--line-2); border-radius: 12px; padding: 12px 14px; }
.vital .vk { font-size: 12px; color: var(--ink-3); font-weight: 600; }
.vital .vv { font-size: 18px; font-weight: 700; margin-top: 4px; }
.vital .vv small { font-size: 12px; color: var(--ink-3); font-weight: 500; }

/* Bill */
.bill-line { display: grid; grid-template-columns: 1fr auto; padding: 11px 0; border-bottom: 1px solid var(--line-2); font-size: 14.5px; }
.bill-line .bl-name { display: flex; align-items: center; gap: 9px; }
.bill-line .bl-amt { font-variant-numeric: tabular-nums; font-weight: 600; }
.bill-sub { display: grid; grid-template-columns: 1fr auto; padding: 7px 0; font-size: 13.5px; color: var(--ink-2); }
.bill-total { display: grid; grid-template-columns: 1fr auto; padding: 14px 0 4px; font-size: 19px; font-weight: 800; border-top: 2px solid var(--ink); margin-top: 6px; }

/* Pharmacy stock low */
.stock-low { color: var(--red); font-weight: 700; }
.stock-ok  { color: var(--green); font-weight: 700; }

/* Print prescription / receipt */
.print-doc {
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 28px 30px; max-width: 760px; margin: 0 auto;
}
.print-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--teal); padding-bottom: 16px; margin-bottom: 18px; }
.print-hosp { font-size: 22px; font-weight: 800; color: var(--teal-dark); }
.print-hosp-sub { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }
.print-meta { text-align: right; font-size: 12.5px; color: var(--ink-2); }
.print-rx-sym { font-size: 30px; font-weight: 800; color: var(--teal-dark); margin: 6px 0 10px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(16,40,60,.45);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
  animation: fade .2s ease;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: 18px; width: 100%; max-width: 720px;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg);
  animation: pop .25s cubic-bezier(.2,1.1,.3,1);
}
.modal-head { display: flex; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line-2); }
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 700; }
.modal-close { margin-inline-start: auto; width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); display: grid; place-items: center; }
.modal-close:hover { background: var(--bg); }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line-2); display: flex; gap: 10px; justify-content: flex-end; }

/* Toast */
.toast-wrap { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 11px;
  background: var(--ink); color: #fff; padding: 13px 18px; border-radius: 12px;
  font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg);
  animation: slideIn .3s cubic-bezier(.2,1,.3,1);
}
.toast svg { width: 20px; height: 20px; color: #4ADE9B; flex: 0 0 auto; }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.wrap-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.text-muted { color: var(--ink-3); }
.text-right { text-align: right; }
.divider { height: 1px; background: var(--line-2); margin: 16px 0; }

/* Scrim for mobile sidebar */
.scrim { position: fixed; inset: 0; background: rgba(16,40,60,.4); z-index: 39; display: none; }
.scrim.show { display: block; }

/* ============================ RESPONSIVE ============================ */
@media (max-width: 1100px) {
  .cols-4 { grid-template-columns: repeat(2, 1fr); }
  .span-2 { grid-column: span 2; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; width: 280px;
    transform: translateX(-100%); transition: transform .25s ease;
    box-shadow: var(--shadow-lg);
  }
  html[dir] .sidebar { left: 0; }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: grid; }
  .cols-3 { grid-template-columns: 1fr; }
  .cols-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .vitals { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .page-wrap { padding: 16px; }
  .topbar { padding: 10px 14px; }
  .cols-4 { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .stat-val { font-size: 26px; }
  .demo-badge .lang-hi, .demo-badge .lang-en { display: none !important; }
  .demo-badge::after { content: "डेमो"; }
  .topbar-title { font-size: 16px; }
  .vitals { grid-template-columns: 1fr 1fr; }
  .modal-foot { flex-direction: column; }
  .modal-foot .btn { width: 100%; }
}

/* Print */
@media print {
  .sidebar, .topbar, .no-print, .toast-wrap { display: none !important; }
  .app { grid-template-columns: 1fr; }
  .page-wrap { padding: 0; }
  .print-doc { border: none; box-shadow: none; max-width: 100%; }
  body { background: #fff; }
}
