/* ============================================================
   ReconMed — worker.css
   ------------------------------------------------------------
   Design bridge loaded AFTER style.css + app.css on all six
   worker-facing pages (dashboard, patient, reconciliation,
   approval, discharge, audit).

   Does NOT touch any JS-facing IDs, data attributes, or
   class names that render.js / app.js depend on.
   ============================================================ */

/* --- CSS variable overrides (maps style.css tokens → new palette) --- */
:root {
  --brand:        #65ae82;
  --brand-dark:   #4c8e69;
  --brand-light:  #eef6f1;
  --accent:       #7d8bba;
  --warn:         #b98a4e;
  --ok:           #4c8e69;
  --surface:      #ffffff;
  --bg:           #fbfbfe;
  --border:       #dde7e1;
  --text:         #0c1710;
  --muted:        #5c7a65;
  --radius:       12px;
  --shadow:       0 4px 20px -8px rgba(12, 23, 16, .14);
  --shadow-lg:    0 8px 32px -12px rgba(12, 23, 16, .18);

  /* Extra tokens used by the new components */
  --rm-primary:      #65ae82;
  --rm-primary-deep: #4c8e69;
  --rm-accent:       #7d8bba;
  --rm-secondary:    #9eccc8;
  --rm-text:         #0c1710;
  --rm-bg:           #fbfbfe;
  --rm-bg-tint:      #eef6f1;
  --rm-bg-tint-2:    #eef1f8;
  --rm-line:         #dde7e1;
  --rm-white:        #ffffff;
  --rm-caution:      #b98a4e;
  --rm-caution-tint: #f4eee9;

  /* Sidebar geometry */
  --sidebar-w: 228px;
}

/* --- Base typography --- */
html { font-size: 97%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  background: #f0f4f1; /* Light green-gray background tint */
  color: var(--rm-text);
  display: block;
  min-height: 100vh;
  margin: 0;
}

h1, h2, h3, h4, h5 {
  font-family: 'Fraunces', 'Markazi Text', 'Inter', serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 0;
}

a { color: var(--rm-primary-deep); }
a:hover { color: var(--rm-primary); }

/* ============================================================
   SIDEBAR — replaces the horizontal .navbar
   ============================================================ */

/* Hide the old flat navbar (still present in markup for fallback) */
.navbar { display: none !important; }

/* The new sidebar element - floating style matching the reference image */
.sidebar {
  position: fixed;
  top: 1.5rem;
  left: 1.5rem;
  width: var(--sidebar-w);
  height: calc(100vh - 3rem);
  background: var(--rm-primary);       /* #65ae82 — primary green */
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: 24px;
  box-shadow: 0 10px 30px -10px rgba(76, 142, 105, 0.3);
}

/* Logo lockup */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1.8rem 1.5rem 1.4rem;
  font-family: 'Fraunces', 'Markazi Text', serif;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--rm-white);
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  text-decoration: none;
  flex-shrink: 0;
}
.sidebar-logo:hover { text-decoration: none; color: var(--rm-white); }
.sidebar-logo span { color: rgba(255, 255, 255, 0.85); }

/* Nav item list */
.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1.2rem 0.6rem;
  gap: 0.4rem;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.75rem 1rem;
  border-radius: 16px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.sidebar-nav a:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--rm-white);
  text-decoration: none;
}

/* Active state: White card background with primary color text */
.sidebar-nav a.active {
  background: var(--rm-white);
  color: var(--rm-primary-deep);
  font-weight: 700;
  box-shadow: 0 8px 20px -6px rgba(12, 23, 16, 0.15);
}

.sidebar-nav a svg {
  flex-shrink: 0;
  opacity: .85;
}

.sidebar-nav a.active svg {
  opacity: 1;
  color: var(--rm-primary-deep);
}

.sidebar-nav a:hover svg  { opacity: 1; }

/* Section divider inside nav */
.sidebar-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.15);
  margin: 0.5rem 1rem;
}

/* Footer / role badge */
.sidebar-footer {
  padding: 1.2rem 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
}

.sidebar-role {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
  letter-spacing: 0.02em;
}

.sidebar-role .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
  flex-shrink: 0;
}

/* ============================================================
   MAIN CONTENT AREA
   ============================================================ */
.page-wrap {
  margin: 1.5rem 1.5rem 1.5rem calc(var(--sidebar-w) + 3rem);
  background: var(--rm-white);
  border-radius: 28px;
  padding: 2.2rem 2.5rem 4rem;
  box-shadow: 0 10px 40px -15px rgba(12, 23, 16, 0.05);
  min-height: calc(100vh - 3rem);
  max-width: 1400px;
}

/* ============================================================
   PAGE CHROME (header, breadcrumb)
   ============================================================ */
.page-header {
  margin-bottom: 1.8rem;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--rm-line);
}

.page-header h1 {
  font-size: clamp(1.4rem, 2vw + 0.8rem, 1.9rem);
  color: var(--rm-text);
}

.page-header p {
  color: var(--muted);
  font-size: 0.92rem;
  margin-top: 0.3rem;
  line-height: 1.55;
}

.page-header .header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.breadcrumb {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 1.2rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.breadcrumb a {
  color: var(--rm-primary-deep);
  font-weight: 600;
}

.breadcrumb a:hover { color: var(--rm-primary); text-decoration: none; }
.breadcrumb .sep { color: var(--rm-line); }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--rm-white);
  border: 1px solid var(--rm-line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.card-body  { padding: 1.3rem 1.5rem; }

.card-header {
  padding: 0.95rem 1.5rem;
  border-bottom: 1px solid var(--rm-line);
  border-radius: 18px 18px 0 0;
}

.card-header h2 {
  font-size: 1rem;
  font-family: 'Fraunces', 'Markazi Text', serif;
  font-weight: 600;
  color: var(--rm-text);
}

.card-footer {
  padding: 0.75rem 1.5rem;
  border-top: 1px solid var(--rm-line);
  background: var(--rm-bg);
  border-radius: 0 0 18px 18px;
}

.card-header-dark {
  background: var(--rm-text);
  color: var(--rm-white);
  border-radius: 18px 18px 0 0;
}
.card-header-dark h2,
.card-header-dark h3 { color: var(--rm-white); }
.card-header-dark .sub { color: rgba(255,255,255,.68); font-size: 0.84rem; }

/* ============================================================
   TABLES
   ============================================================ */
table { font-size: 0.89rem; }

thead tr { background: var(--rm-bg-tint); }

th {
  color: var(--rm-primary-deep);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom-color: var(--rm-line);
  padding: 0.65rem 0.9rem;
}

td {
  padding: 0.75rem 0.9rem;
  border-bottom-color: var(--rm-line);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--rm-bg-tint); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  border-radius: 999px;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 0.875rem;
  padding: 0.55rem 1.2rem;
  min-height: 2.2rem;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.btn-primary {
  background: var(--rm-primary);
  border-color: var(--rm-primary);
  color: #fff;
  box-shadow: 0 6px 18px -8px rgba(101, 174, 130, 0.5);
}
.btn-primary:hover {
  background: var(--rm-primary-deep);
  border-color: var(--rm-primary-deep);
  text-decoration: none;
  box-shadow: 0 8px 22px -8px rgba(101, 174, 130, 0.6);
}

.btn-outline {
  background: transparent;
  color: var(--rm-primary-deep);
  border-color: var(--rm-primary);
}
.btn-outline:hover {
  background: var(--rm-bg-tint);
  text-decoration: none;
}

.btn-success {
  background: var(--rm-primary-deep);
  border-color: var(--rm-primary-deep);
  color: #fff;
}
.btn-success:hover {
  background: #3a6e53;
  border-color: #3a6e53;
  text-decoration: none;
}

.btn-danger  { border-radius: 999px; }
.btn-warn    { border-radius: 999px; background: var(--rm-caution); border-color: var(--rm-caution); }
.btn-sm { padding: 0.35rem 0.85rem; font-size: 0.78rem; }
.btn-lg { padding: 0.75rem 1.6rem; font-size: 0.97rem; }

/* ============================================================
   BADGES
   ============================================================ */
.badge-green { background: var(--rm-bg-tint);   color: var(--rm-primary-deep); }
.badge-blue  { background: var(--rm-bg-tint-2); color: var(--rm-accent); }
.badge-amber { background: var(--rm-caution-tint); color: var(--rm-caution); }

.status-pill {
  border-radius: 999px;
  font-size: 0.72rem;
}

/* ============================================================
   SCORE RING
   ============================================================ */
.score-ring {
  border-radius: 50%;
  border-width: 4px;
}
.score-high   { border-color: #c0392b; color: #c0392b; background: #fde8e2; }
.score-medium { border-color: var(--rm-caution); color: var(--rm-caution); background: var(--rm-caution-tint); }
.score-low    { border-color: var(--rm-primary); color: var(--rm-primary-deep); background: var(--rm-bg-tint); }
.score-label  { font-size: 9px; font-weight: 700; }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-card {
  border-radius: 18px;
  border-color: var(--rm-line);
}
.stat-card .stat-val  { color: var(--rm-primary-deep); }
.stat-card .stat-label{ color: var(--muted); font-size: 0.82rem; }

/* ============================================================
   DISCREPANCY ROWS (reconciliation flags)
   ============================================================ */
.disc-row { border-radius: 14px; }
.disc-row .disc-header { border-radius: 14px 14px 0 0; }
.disc-row.sev-low    { border-left-color: var(--rm-primary); }
.disc-row.is-resolved .disc-header { background: var(--rm-bg-tint); }

/* ============================================================
   SOURCE CELLS
   ============================================================ */
.source-cell {
  border-radius: 10px;
}
.source-cell.match { border-color: var(--rm-primary); background: var(--rm-bg-tint); }
.source-cell.missing { border-color: var(--rm-caution); background: var(--rm-caution-tint); }

/* ============================================================
   ALERTS
   ============================================================ */
.alert-ok   { background: var(--rm-bg-tint);   border-color: var(--rm-primary);       color: var(--rm-primary-deep); }
.alert-info { background: var(--rm-bg-tint-2); border-color: var(--rm-accent);        color: #4a5490; }
.alert-warn { background: var(--rm-caution-tint); border-color: var(--rm-caution);    color: #7a5a30; }

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress { border-radius: 999px; height: 6px; }
.progress-bar { background: var(--rm-primary); border-radius: 999px; }
.progress-bar.is-complete { background: var(--rm-primary-deep); }

/* ============================================================
   TABS
   ============================================================ */
.tab-btn:hover          { color: var(--rm-primary); }
.tab-btn.active         { color: var(--rm-primary-deep); border-bottom-color: var(--rm-primary); font-weight: 700; }
.tabs                   { border-bottom-color: var(--rm-line); }

/* ============================================================
   TIMELINE
   ============================================================ */
.tl-dot       { background: var(--rm-primary); }
.tl-dot-ok    { background: var(--rm-primary-deep) !important; }
.tl-dot-warn  { background: var(--rm-caution) !important; }
.tl-line      { background: var(--rm-line); }
.tl-actor.is-system     { background: var(--rm-bg-tint);   color: var(--rm-primary-deep); }
.tl-actor.is-pharmacist { background: var(--rm-bg-tint-2); color: var(--rm-accent); }
.tl-actor.is-physician  { background: var(--rm-bg-tint);   color: var(--rm-primary-deep); }
.tl-actor.is-engine     { background: var(--rm-caution-tint); color: var(--rm-caution); }

/* ============================================================
   CONTEXT BAR
   ============================================================ */
.context-bar { border-radius: 12px; border-color: var(--rm-line); }
.context-bar .ctx-back { color: var(--rm-primary-deep); }
.context-bar .ctx-sep  { background: var(--rm-line); }

/* ============================================================
   PATIENT BAR
   ============================================================ */
.patient-bar {
  border-radius: 16px;
  border-color: var(--rm-line);
  background: var(--rm-white);
}
.patient-bar .avatar {
  background: var(--rm-bg-tint);
  color: var(--rm-primary-deep);
}
.patient-bar .pdivider { background: var(--rm-line); }

/* ============================================================
   WORKLIST LEGEND
   ============================================================ */
.worklist-legend { border-bottom-color: var(--rm-line); background: var(--rm-bg-tint); }

/* ============================================================
   SEPARATOR LABEL
   ============================================================ */
.sep-label { color: var(--rm-primary-deep); }
.sep-label::before, .sep-label::after { background: var(--rm-line); }

/* ============================================================
   FORM CONTROLS
   ============================================================ */
.form-control {
  border-color: var(--rm-line);
  border-radius: 10px;
  background: var(--rm-white);
  font-family: 'Inter', sans-serif;
}
.form-control:focus { border-color: var(--rm-primary); }
.form-group label { color: var(--muted); font-size: 0.8rem; font-weight: 700; }

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  background: transparent;
  color: var(--muted);
  text-align: center;
  padding: 1.5rem;
  margin-left: calc(var(--sidebar-w) + 3rem);
  margin-top: 0;
}

/* ============================================================
   RESPONSIVE — collapse sidebar on small screens
   ============================================================ */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    width: 260px;
    height: 100vh;
    top: 0;
    left: 0;
    border-radius: 0 24px 24px 0;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    z-index: 1000;
  }
  
  .sidebar.is-open {
    transform: translateX(0);
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.25s ease;
  }
  
  .sidebar-overlay.is-visible {
    display: block;
    opacity: 1;
  }

  .page-wrap {
    margin: 1rem;
    border-radius: 16px;
    padding: 1.4rem 1rem 3rem;
  }

  .footer { margin-left: 0; }
  
  /* Mobile Header */
  .mobile-header {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    background: var(--rm-white);
    padding: 12px 1rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 900;
  }
  
  .mobile-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
  }
  
  .mobile-hamburger {
    background: transparent;
    border: none;
    color: var(--rm-primary-deep);
    padding: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .mobile-page-title {
    font-size: 1.1rem;
    font-weight: 700;
    font-family: 'Fraunces', 'Markazi Text', serif;
    color: var(--rm-primary-deep);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .mobile-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
  }
  
  body {
    padding-top: 0; /* Let sticky header flow naturally */
  }
}

