/* ═══════════════════════════════════════════════════════════════
   DentaFHIR — Modern Australian Dental EHR Theme
   Clean teal/white clinical design language
   ═══════════════════════════════════════════════════════════════ */

/* ── Google Font ─────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── CSS Variables ───────────────────────────────────────────── */
:root {
  --ehr-teal:          #0891b2;
  --ehr-teal-dark:     #0e7490;
  --ehr-teal-mid:      #06b6d4;
  --ehr-teal-light:    #e0f2fe;
  --ehr-teal-xlight:   #f0f9ff;
  --ehr-emerald:       #059669;
  --ehr-emerald-light: #d1fae5;
  --ehr-amber:         #d97706;
  --ehr-amber-light:   #fef3c7;
  --ehr-rose:          #e11d48;
  --ehr-rose-light:    #ffe4e6;
  --ehr-violet:        #7c3aed;
  --ehr-bg:            #f1f5f9;
  --ehr-bg-alt:        #f8fafc;
  --ehr-card:          #ffffff;
  --ehr-border:        #e2e8f0;
  --ehr-border-mid:    #cbd5e1;
  --ehr-text:          #0f172a;
  --ehr-text-sub:      #334155;
  --ehr-muted:         #64748b;
  --ehr-muted-light:   #94a3b8;
  /* Coding standard colours */
  --ehr-snomed:        #0e7490;
  --ehr-snomed-bg:     #ecfeff;
  --ehr-snomed-border: #a5f3fc;
  --ehr-icd:           #065f46;
  --ehr-icd-bg:        #d1fae5;
  --ehr-icd-border:    #6ee7b7;
  --ehr-cdt:           #92400e;
  --ehr-cdt-bg:        #fef3c7;
  --ehr-cdt-border:    #fcd34d;
  /* Layout */
  --sidebar-width:     230px;
  --topbar-height:     56px;
}

/* ── BASE ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: var(--ehr-bg);
  color: var(--ehr-text);
  font-size: 13.5px;
  line-height: 1.5;
  margin: 0;
}

/* ── TOP BAR ─────────────────────────────────────────────────── */
.ehr-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-height);
  background: var(--ehr-teal-dark);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  z-index: 1000;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  gap: 1rem;
}

.ehr-topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.ehr-topbar-brand .brand-icon {
  width: 28px; height: 28px;
  background: rgba(255,255,255,0.18);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.95rem;
}

.ehr-topbar-brand .brand-sub {
  font-size: 0.65rem;
  font-weight: 400;
  opacity: 0.7;
  letter-spacing: 0.03em;
  line-height: 1;
  display: block;
}

.ehr-topbar-divider {
  width: 1px;
  height: 24px;
  background: rgba(255,255,255,0.2);
  flex-shrink: 0;
}

.ehr-topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ehr-session-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.85);
}

.ehr-session-badge .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #4ade80;
  animation: pulse-dot 2s infinite;
  flex-shrink: 0;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── PAGE BODY (below topbar) ────────────────────────────────── */
.ehr-layout {
  display: flex;
  padding-top: var(--topbar-height);
  min-height: 100vh;
}

/* ── SIDEBAR ─────────────────────────────────────────────────── */
.ehr-sidebar {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--topbar-height));
  background: var(--ehr-card);
  border-right: 1px solid var(--ehr-border);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  z-index: 900;
}

.ehr-sidebar-section {
  padding: 0.75rem 0.75rem 0;
}

.ehr-sidebar-label {
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ehr-muted-light);
  padding: 0.5rem 0.75rem 0.35rem;
  display: block;
}

.ehr-sidebar-nav {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ehr-sidebar-nav li { margin-bottom: 2px; }

.ehr-nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.52rem 0.85rem;
  border-radius: 8px;
  color: var(--ehr-text-sub);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
}

.ehr-nav-link:hover {
  background: var(--ehr-teal-xlight);
  color: var(--ehr-teal-dark);
}

.ehr-nav-link.active {
  background: var(--ehr-teal-light);
  color: var(--ehr-teal-dark);
  font-weight: 600;
}

.ehr-nav-link .nav-icon {
  width: 18px;
  text-align: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.ehr-nav-link.fhir-link {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--ehr-muted);
  padding-top: 0.38rem;
  padding-bottom: 0.38rem;
}

.ehr-nav-link.fhir-link:hover {
  color: var(--ehr-teal-dark);
  background: var(--ehr-teal-xlight);
}

.ehr-sidebar-divider {
  height: 1px;
  background: var(--ehr-border);
  margin: 0.6rem 0.75rem;
}

.ehr-sidebar-bottom {
  margin-top: auto;
  padding: 0.75rem;
  border-top: 1px solid var(--ehr-border);
}

.ehr-sidebar-standards {
  font-size: 0.7rem;
  color: var(--ehr-muted);
  line-height: 1.6;
}

/* ── MAIN CONTENT ────────────────────────────────────────────── */
.ehr-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 1.5rem 1.75rem;
  min-height: calc(100vh - var(--topbar-height));
  background: var(--ehr-bg);
}

/* ── SESSION BANNER ──────────────────────────────────────────── */
.ehr-session-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  border-left: 4px solid #059669;
  border-radius: 8px;
  padding: 0.6rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.83rem;
  color: #065f46;
}

/* ── PAGE HEADER ─────────────────────────────────────────────── */
.ehr-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.ehr-page-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ehr-text);
  margin: 0 0 0.15rem;
  letter-spacing: -0.01em;
}

.ehr-page-sub {
  font-size: 0.8rem;
  color: var(--ehr-muted);
  margin: 0;
}

.ehr-breadcrumb {
  font-size: 0.78rem;
  color: var(--ehr-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 0.35rem;
}

.ehr-breadcrumb:hover { color: var(--ehr-teal); }

/* ── STAT CARDS ──────────────────────────────────────────────── */
.ehr-stat-card {
  background: var(--ehr-card);
  border: 1px solid var(--ehr-border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.ehr-stat-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.ehr-stat-icon.teal    { background: var(--ehr-teal-light); color: var(--ehr-teal-dark); }
.ehr-stat-icon.emerald { background: var(--ehr-emerald-light); color: var(--ehr-emerald); }
.ehr-stat-icon.amber   { background: var(--ehr-amber-light); color: var(--ehr-amber); }
.ehr-stat-icon.rose    { background: var(--ehr-rose-light); color: var(--ehr-rose); }
.ehr-stat-icon.violet  { background: #ede9fe; color: var(--ehr-violet); }

.ehr-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ehr-text);
  line-height: 1;
  margin-bottom: 0.15rem;
}

.ehr-stat-label {
  font-size: 0.75rem;
  color: var(--ehr-muted);
  font-weight: 500;
}

/* ── CARDS ───────────────────────────────────────────────────── */
.ehr-card {
  background: var(--ehr-card);
  border: 1px solid var(--ehr-border);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  overflow: hidden;
}

.ehr-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--ehr-border);
  background: var(--ehr-bg-alt);
}

.ehr-card-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ehr-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
}

.ehr-card-header-primary {
  background: var(--ehr-teal-dark);
  color: #fff;
  padding: 0.7rem 1rem;
  border-bottom: none;
}

.ehr-card-header-primary .ehr-card-title {
  color: #fff;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.88rem;
}

/* Bootstrap card override */
.card {
  border: 1px solid var(--ehr-border) !important;
  border-radius: 10px !important;
  background: var(--ehr-card) !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05) !important;
}

.card-header {
  background-color: var(--ehr-bg-alt) !important;
  border-bottom: 1px solid var(--ehr-border) !important;
  color: var(--ehr-muted) !important;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.75rem 1rem;
  border-radius: 10px 10px 0 0 !important;
}

.card-header.bg-primary,
.card-header.bg-dark {
  background-color: var(--ehr-teal-dark) !important;
  color: #fff !important;
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.88rem;
}

.card-header.bg-success {
  background-color: var(--ehr-emerald) !important;
  color: #fff !important;
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.88rem;
}

.card-header.bg-warning {
  background-color: #92400e !important;
  color: #fff !important;
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.88rem;
}

.card-header.bg-danger {
  background-color: var(--ehr-rose) !important;
  color: #fff !important;
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.88rem;
}

.card-header.bg-info {
  background-color: var(--ehr-teal) !important;
  color: #fff !important;
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.88rem;
}

/* White card header (override Bootstrap bg-white) */
.card-header.bg-white {
  background-color: var(--ehr-bg-alt) !important;
  color: var(--ehr-text-sub) !important;
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.84rem;
  font-weight: 600;
}

/* ── TABLES ──────────────────────────────────────────────────── */
.table {
  font-size: 0.83rem;
}

.table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  color: var(--ehr-muted);
  border-bottom-width: 1px !important;
  padding: 0.6rem 0.85rem;
  white-space: nowrap;
}

.table td {
  padding: 0.65rem 0.85rem;
  vertical-align: middle;
  border-color: var(--ehr-border);
  color: var(--ehr-text-sub);
}

.table-hover > tbody > tr:hover > td {
  background-color: var(--ehr-teal-xlight);
}

/* table-dark thead → teal */
.table-dark,
thead.table-dark,
.table > thead.table-dark > tr > th {
  background-color: var(--ehr-teal-dark) !important;
  color: #ffffff !important;
  border-color: rgba(255,255,255,0.15) !important;
}

.table > thead.table-dark > tr > th {
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.07em;
  font-weight: 700;
  padding: 0.65rem 0.85rem;
}

.table-light th {
  background-color: var(--ehr-bg-alt) !important;
  color: var(--ehr-muted) !important;
}

/* ── BUTTONS ─────────────────────────────────────────────────── */
.btn { font-size: 0.83rem; font-weight: 500; }

.btn-primary {
  background-color: var(--ehr-teal-dark) !important;
  border-color: var(--ehr-teal-dark) !important;
  color: #fff !important;
}
.btn-primary:hover, .btn-primary:focus {
  background-color: var(--ehr-teal) !important;
  border-color: var(--ehr-teal) !important;
}

.btn-outline-primary {
  color: var(--ehr-teal-dark) !important;
  border-color: var(--ehr-teal-dark) !important;
}
.btn-outline-primary:hover {
  background-color: var(--ehr-teal-dark) !important;
  color: #fff !important;
}

.btn-success {
  background-color: var(--ehr-emerald) !important;
  border-color: var(--ehr-emerald) !important;
  color: #fff !important;
}
.btn-success:hover { filter: brightness(1.08); }

.btn-outline-success {
  color: var(--ehr-emerald) !important;
  border-color: var(--ehr-emerald) !important;
}
.btn-outline-success:hover {
  background-color: var(--ehr-emerald) !important;
  color: #fff !important;
}

.btn-outline-info {
  color: var(--ehr-teal) !important;
  border-color: var(--ehr-teal) !important;
}
.btn-outline-info:hover {
  background-color: var(--ehr-teal) !important;
  color: #fff !important;
}

.btn-outline-dark {
  color: var(--ehr-text-sub) !important;
  border-color: var(--ehr-border-mid) !important;
}
.btn-outline-dark:hover {
  background-color: var(--ehr-teal-dark) !important;
  border-color: var(--ehr-teal-dark) !important;
  color: #fff !important;
}

.btn-outline-secondary {
  color: var(--ehr-muted) !important;
  border-color: var(--ehr-border-mid) !important;
}
.btn-outline-secondary:hover {
  background-color: var(--ehr-bg) !important;
  color: var(--ehr-teal-dark) !important;
  border-color: var(--ehr-teal) !important;
}

.btn-warning {
  background-color: var(--ehr-amber) !important;
  border-color: var(--ehr-amber) !important;
  color: #fff !important;
}
.btn-warning:hover { filter: brightness(1.08); }

.btn-outline-warning {
  color: var(--ehr-amber) !important;
  border-color: var(--ehr-amber) !important;
}
.btn-outline-warning:hover {
  background-color: var(--ehr-amber) !important;
  color: #fff !important;
}

.btn-outline-danger {
  color: var(--ehr-rose) !important;
  border-color: var(--ehr-rose) !important;
}
.btn-outline-danger:hover {
  background-color: var(--ehr-rose) !important;
  color: #fff !important;
}

.btn-danger {
  background-color: var(--ehr-rose) !important;
  border-color: var(--ehr-rose) !important;
  color: #fff !important;
}

/* Small button adjustments */
.btn-sm { font-size: 0.76rem; padding: 0.28rem 0.65rem; }

/* ── BADGES ──────────────────────────────────────────────────── */
.badge { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.02em; }

.badge.bg-primary  { background-color: var(--ehr-teal-dark) !important; }
.badge.bg-success  { background-color: var(--ehr-emerald) !important; }
.badge.bg-info     { background-color: var(--ehr-teal) !important; }
.badge.bg-warning  { background-color: var(--ehr-amber) !important; color: #fff !important; }
.badge.bg-danger   { background-color: var(--ehr-rose) !important; }
.badge.bg-secondary { background-color: var(--ehr-muted) !important; }

/* Coding standard badges */
.badge-snomed {
  background-color: var(--ehr-snomed-bg);
  color: var(--ehr-snomed);
  border: 1px solid var(--ehr-snomed-border);
  font-weight: 600;
}
.badge-icd {
  background-color: var(--ehr-icd-bg);
  color: var(--ehr-icd);
  border: 1px solid var(--ehr-icd-border);
  font-weight: 600;
}
.badge-cdt {
  background-color: var(--ehr-cdt-bg);
  color: var(--ehr-cdt);
  border: 1px solid var(--ehr-cdt-border);
  font-weight: 600;
}

/* ── ALERTS ──────────────────────────────────────────────────── */
.alert-warning {
  background-color: #fef3c7 !important;
  border-color: #fcd34d !important;
  color: #92400e !important;
}

.alert-success {
  background-color: #ecfdf5 !important;
  border-color: #6ee7b7 !important;
  color: #065f46 !important;
}

.alert-info {
  background-color: var(--ehr-teal-xlight) !important;
  border-color: #bae6fd !important;
  color: var(--ehr-teal-dark) !important;
}

.border-warning  { border-color: #fcd34d !important; }
.border-success  { border-color: #6ee7b7 !important; }
.border-primary  { border-color: var(--ehr-teal-dark) !important; }
.border-info     { border-color: var(--ehr-teal) !important; }

/* ── TABS ────────────────────────────────────────────────────── */
.nav-tabs {
  border-bottom: 2px solid var(--ehr-border);
}

.nav-tabs .nav-link {
  color: var(--ehr-muted);
  font-size: 0.83rem;
  font-weight: 500;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: 0.6rem 1rem;
  border-radius: 0;
  transition: color 0.12s, border-color 0.12s;
}

.nav-tabs .nav-link:hover {
  color: var(--ehr-teal-dark);
  border-bottom-color: var(--ehr-teal-light);
  background: none;
}

.nav-tabs .nav-link.active {
  color: var(--ehr-teal-dark);
  font-weight: 600;
  border-bottom: 2px solid var(--ehr-teal-dark);
  background: none;
}

.tab-content {
  background: var(--ehr-card);
  border: 1px solid var(--ehr-border);
  border-top: none;
  border-radius: 0 0 10px 10px;
}

/* ── FORMS ───────────────────────────────────────────────────── */
.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ehr-text-sub);
  margin-bottom: 0.3rem;
}

.form-control, .form-select {
  font-size: 0.84rem;
  border-color: var(--ehr-border-mid);
  border-radius: 7px;
  color: var(--ehr-text);
}

.form-control:focus, .form-select:focus {
  border-color: var(--ehr-teal);
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.12);
}

.form-control::placeholder { color: var(--ehr-muted-light); }

.form-text {
  font-size: 0.73rem;
  color: var(--ehr-muted);
}

/* ── MODALS ──────────────────────────────────────────────────── */
.modal-content {
  border-radius: 12px;
  border: 1px solid var(--ehr-border);
  box-shadow: 0 10px 40px rgba(0,0,0,0.18);
}

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--ehr-border);
}

.modal-header.bg-dark {
  background-color: var(--ehr-teal-dark) !important;
  border-radius: 12px 12px 0 0;
}

.modal-header.bg-warning {
  background-color: #fef3c7 !important;
  color: #92400e !important;
}

/* ── TYPOGRAPHY ──────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 { color: var(--ehr-text); }

.text-primary   { color: var(--ehr-teal-dark) !important; }
.text-success   { color: var(--ehr-emerald) !important; }
.text-info      { color: var(--ehr-teal) !important; }
.text-muted     { color: var(--ehr-muted) !important; }
.text-warning   { color: var(--ehr-amber) !important; }
.text-danger    { color: var(--ehr-rose) !important; }

code {
  color: var(--ehr-teal-dark);
  background: var(--ehr-teal-xlight);
  padding: 0.1em 0.35em;
  border-radius: 4px;
  font-size: 0.85em;
}

pre {
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-all;
}

a { color: var(--ehr-teal-dark); }
a:hover { color: var(--ehr-teal); }

/* ── HERO BANNER ─────────────────────────────────────────────── */
.ehr-hero {
  background: linear-gradient(135deg, #0c4a6e 0%, #0e7490 55%, #0891b2 100%);
  border-radius: 12px;
  padding: 2rem 2.25rem;
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
}

.ehr-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.04;
  background-image: repeating-linear-gradient(45deg, #fff 0, #fff 1px, transparent 0, transparent 50%);
  background-size: 12px 12px;
}

.ehr-hero-content { position: relative; }

/* ── PROGRESS BARS ───────────────────────────────────────────── */
.progress { background-color: var(--ehr-border); }
.progress-bar.bg-success { background-color: var(--ehr-emerald) !important; }

/* ── INVOICE SUMMARY MINI-CARDS ──────────────────────────────── */
.inv-summary-box {
  background: var(--ehr-bg-alt);
  border: 1px solid var(--ehr-border);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  text-align: center;
}

.inv-summary-box .val {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
}

/* ── FHIR CODE BLOCK ─────────────────────────────────────────── */
.fhir-pre {
  background: #0f172a;
  color: #4ade80;
  border-radius: 8px;
  font-size: 0.72rem;
  padding: 0.85rem;
  overflow: auto;
  max-height: 70vh;
}

/* ── DE-ID NOTICE ────────────────────────────────────────────── */
.deid-notice {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-left: 4px solid var(--ehr-amber);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 1rem;
  font-size: 0.82rem;
  color: #78350f;
}

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .ehr-sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s;
  }
  .ehr-main {
    margin-left: 0;
    padding: 1rem;
  }
}
