/* OHMS — hospital admin theme on Bootstrap 5.3 */
:root {
  --ohms-primary: #0b6e75;
  --ohms-primary-dark: #08555b;
  --ohms-primary-soft: #e3f2f2;
  --ohms-accent: #1d6fb8;
  --ohms-sidebar-bg: #0e2a3b;
  --ohms-sidebar-fg: #b9cad6;
  --ohms-sidebar-active: #13a3a9;
  --ohms-body-bg: #f2f5f8;
  --ohms-border: #dfe6ec;
  --ohms-sidebar-w: 256px;
  --bs-primary: var(--ohms-primary);
  --bs-primary-rgb: 11, 110, 117;
  --bs-link-color: var(--ohms-accent);
  --bs-link-color-rgb: 29, 111, 184;
  --bs-body-font-family: "Inter", "Noto Sans Tamil", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-body-font-size: 0.925rem;
}

html[lang="ta"] { --bs-body-font-family: "Noto Sans Tamil", "Inter", system-ui, sans-serif; }

body { background: var(--ohms-body-bg); color: #1f2d3a; overflow-x: hidden; }
a { text-decoration: none; }
a:hover { text-decoration: underline; }
.ohms-nav a:hover, .card.text-decoration-none:hover, .btn:hover, .dropdown-item:hover, .perm-chip:hover { text-decoration: none; }
.ohms-main { min-width: 0; }
.ohms-content { min-width: 0; }

.btn-primary {
  --bs-btn-bg: var(--ohms-primary); --bs-btn-border-color: var(--ohms-primary);
  --bs-btn-hover-bg: var(--ohms-primary-dark); --bs-btn-hover-border-color: var(--ohms-primary-dark);
  --bs-btn-active-bg: var(--ohms-primary-dark); --bs-btn-active-border-color: var(--ohms-primary-dark);
  --bs-btn-disabled-bg: var(--ohms-primary); --bs-btn-disabled-border-color: var(--ohms-primary);
}
.btn-outline-primary {
  --bs-btn-color: var(--ohms-primary); --bs-btn-border-color: var(--ohms-primary);
  --bs-btn-hover-bg: var(--ohms-primary); --bs-btn-hover-border-color: var(--ohms-primary);
  --bs-btn-active-bg: var(--ohms-primary-dark); --bs-btn-active-border-color: var(--ohms-primary-dark);
}
.text-primary { color: var(--ohms-primary) !important; }
.bg-primary-soft { background: var(--ohms-primary-soft) !important; }
.form-check-input:checked { background-color: var(--ohms-primary); border-color: var(--ohms-primary); }
.form-control:focus, .form-select:focus { border-color: #5fb3b8; box-shadow: 0 0 0 .2rem rgba(11, 110, 117, .15); }

/* ---------- Layout ---------- */
.ohms-sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--ohms-sidebar-w);
  background: var(--ohms-sidebar-bg); color: var(--ohms-sidebar-fg);
  display: flex; flex-direction: column; z-index: 1040; transition: transform .2s ease;
}
.ohms-brand {
  display: flex; align-items: center; gap: .65rem; padding: 1rem 1.1rem;
  color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.07); min-height: 64px;
}
.ohms-brand:hover { color: #fff; }
.ohms-brand img { width: 38px; height: 38px; object-fit: contain; background: #fff; border-radius: 8px; padding: 2px; }
.ohms-brand .brand-mark {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: var(--ohms-sidebar-active); color: #fff; font-size: 1.2rem; flex: none;
}
.ohms-brand .brand-name { font-weight: 600; line-height: 1.15; font-size: .95rem; }
.ohms-brand .brand-sub { font-size: .72rem; color: var(--ohms-sidebar-fg); }

.ohms-nav { overflow-y: auto; padding: .75rem .6rem 1.5rem; flex: 1; }
.ohms-nav .nav-section { font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: #6f8898; padding: .9rem .75rem .35rem; }
.ohms-nav a, .ohms-nav button.nav-group {
  display: flex; align-items: center; gap: .7rem; width: 100%; padding: .55rem .75rem;
  color: var(--ohms-sidebar-fg); text-decoration: none; border: 0; background: none;
  border-radius: 8px; font-size: .9rem; text-align: left;
}
.ohms-nav a:hover, .ohms-nav button.nav-group:hover { background: rgba(255,255,255,.06); color: #fff; }
.ohms-nav a.active { background: var(--ohms-sidebar-active); color: #fff; font-weight: 500; }
.ohms-nav .bi { font-size: 1.05rem; width: 1.25rem; text-align: center; }
.ohms-nav .nav-group .chev { margin-left: auto; transition: transform .2s; font-size: .8rem; }
.ohms-nav .nav-group[aria-expanded="true"] .chev { transform: rotate(90deg); }
.ohms-nav .sub a { padding-left: 2.7rem; font-size: .86rem; }
.ohms-nav .sub a.active { background: rgba(19,163,169,.18); color: #fff; }

.ohms-main { margin-left: var(--ohms-sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.ohms-topbar {
  position: sticky; top: 0; z-index: 1030; height: 64px; background: #fff;
  border-bottom: 1px solid var(--ohms-border); display: flex; align-items: center; gap: .75rem; padding: 0 1.25rem;
}
.ohms-topbar .clock { font-variant-numeric: tabular-nums; color: #5b6b78; font-size: .85rem; }
.ohms-content { padding: 1.25rem; flex: 1; }
.ohms-footer { padding: .9rem 1.25rem; color: #7a8a97; font-size: .8rem; border-top: 1px solid var(--ohms-border); background: #fff; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center;
  background: var(--ohms-primary-soft); color: var(--ohms-primary); font-weight: 600; font-size: .85rem;
}

@media (max-width: 991.98px) {
  .ohms-sidebar { transform: translateX(-100%); }
  body.sidebar-open .ohms-sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  body.sidebar-open .ohms-backdrop { display: block; }
  .ohms-main { margin-left: 0; }
  .ohms-content { padding: 1rem; }
}
.ohms-backdrop { display: none; position: fixed; inset: 0; background: rgba(10,20,30,.45); z-index: 1035; }

/* ---------- Page elements ---------- */
.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.1rem; }
.page-header h1 { font-size: 1.35rem; font-weight: 600; margin: 0; }
.page-header .breadcrumb { margin: .15rem 0 0; font-size: .8rem; }

.card { border: 1px solid var(--ohms-border); border-radius: 12px; box-shadow: 0 1px 2px rgba(16,40,60,.04); }
.card-header { background: #fff; border-bottom: 1px solid var(--ohms-border); font-weight: 600; padding: .85rem 1.1rem; border-radius: 12px 12px 0 0 !important; }
.card-body { padding: 1.1rem; }

.stat-card { display: flex; align-items: center; gap: .9rem; }
.stat-card .stat-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.35rem; flex: none; }
.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-card .stat-label { font-size: .8rem; color: #64748b; }
.tone-teal { background: #e0f2f1; color: #0b6e75; }
.tone-blue { background: #e3eefa; color: #1d6fb8; }
.tone-amber { background: #fdf3dc; color: #a16207; }
.tone-red { background: #fde7e7; color: #b42318; }
.tone-slate { background: #eef2f6; color: #475569; }
.tone-green { background: #e5f6ea; color: #15803d; }

.table > :not(caption) > * > * { padding: .6rem .75rem; }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: #5b6b78; font-weight: 600; background: #f7f9fb; white-space: nowrap; }
.dl-grid { display: grid; grid-template-columns: minmax(110px, 34%) minmax(0, 1fr); gap: .45rem 1rem; margin: 0; }
.dl-grid dt { color: #64748b; font-weight: 500; }
.dl-grid dd { margin: 0; overflow-wrap: anywhere; min-width: 0; }
@media (max-width: 575.98px) { .dl-grid { grid-template-columns: minmax(0, 1fr); gap: .1rem; } .dl-grid dd { margin-bottom: .45rem; } }

.perm-matrix th, .perm-matrix td { vertical-align: middle; }
.perm-matrix .form-check-input { cursor: pointer; }
.perm-matrix .group-row td { background: var(--ohms-primary-soft); font-weight: 600; color: var(--ohms-primary-dark); }
.perm-chip { display: inline-flex; align-items: center; gap: .3rem; border: 1px solid var(--ohms-border); border-radius: 999px; padding: .15rem .6rem; font-size: .78rem; margin: .15rem; background: #fff; }
.perm-chip.sensitive { border-color: #f3c4a3; background: #fff7f0; }

.code-box { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: #f7f9fb; border: 1px dashed var(--ohms-border); border-radius: 8px; padding: .75rem; }
.json-view { font-family: ui-monospace, Consolas, monospace; font-size: .8rem; white-space: pre-wrap; word-break: break-all; margin: 0; }

.nav-tabs .nav-link { color: #475569; }
.nav-tabs .nav-link.active { color: var(--ohms-primary); font-weight: 600; }

.select2-container--bootstrap-5 .select2-selection { min-height: calc(1.5em + .75rem + 2px); }
div.dt-container .dt-search input { min-width: 220px; }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero {
  background: linear-gradient(150deg, #0b6e75 0%, #0e2a3b 100%); color: #e6f4f4;
  padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-hero h2 { color: #fff; font-weight: 700; }
.auth-hero .feature { display: flex; gap: .75rem; margin-bottom: 1rem; }
.auth-hero .feature .bi { font-size: 1.3rem; color: #7fdcdf; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; background: #fff; }
.auth-card { width: 100%; max-width: 400px; }
@media (max-width: 991.98px) { .auth-wrap { grid-template-columns: 1fr; } .auth-hero { display: none; } }

/* ---------- Print ---------- */
@media print {
  .ohms-sidebar, .ohms-topbar, .ohms-footer, .no-print, .dt-search, .dt-length, .dt-paging, .btn { display: none !important; }
  .ohms-main { margin: 0; }
  .ohms-content { padding: 0; }
  body { background: #fff; }
  .card { border: 0; box-shadow: none; }
}

/* ---------------------------------------------------------------- Handwriting pad (prescriptions) */
.hw-page { position: relative; background-color: #fff; border: 1px solid var(--bs-border-color); border-radius: .5rem; overflow: hidden;
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--hw-line, 30px) - 1px), #dbe7f0 calc(var(--hw-line, 30px) - 1px), #dbe7f0 var(--hw-line, 30px)); }
.hw-canvas { display: block; cursor: crosshair; touch-action: none; user-select: none; -webkit-user-select: none; }
.hw-canvas.hw-erasing { cursor: cell; }
.hw-hint { position: absolute; top: 45%; left: 0; right: 0; text-align: center; color: #9aa8b4; font-size: 1.1rem; pointer-events: none; }
.hw-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: middle; }
.hw-line { display: inline-block; width: 18px; background: currentColor; border-radius: 2px; vertical-align: middle; }
.hw-wrap.hw-full, .hw-wrap:fullscreen { position: fixed; inset: 0; z-index: 2000; background: #f3f6f9; padding: 12px; overflow: auto; }
.hw-wrap.hw-full .hw-page, .hw-wrap:fullscreen .hw-page { max-width: 1100px; margin: 0 auto; }
.hw-wrap.hw-full .hw-toolbar, .hw-wrap:fullscreen .hw-toolbar { max-width: 1100px; margin: 0 auto .5rem; position: sticky; top: 0; z-index: 1; background: #f3f6f9; padding: .25rem 0; }
.rx-hw-img { max-width: 100%; border: 1px solid var(--bs-border-color); border-radius: .375rem; background: #fff; }
