/* ============================================================
   RONCE MEDICAL CENTER — Main Stylesheet v2
   Theme: Medical Blue/Teal with clean white cards
   ============================================================ */
:root {
  --primary:      #1c4f82;
  --primary-dark: #153d66;
  --primary-light:#2a6aad;
  --accent:       #17a2b8;
  --accent-light: #e8f7fa;
  --success:      #28a745;
  --warning:      #ffc107;
  --danger:       #dc3545;
  --sidebar-bg:   #0f2942;
  --sidebar-w:    260px;
  --topbar-h:     64px;
  --bg:           #f0f4f8;
  --card:         #ffffff;
  --border:       #dde3ec;
  --text:         #2c3e50;
  --muted:        #6c7a8a;
  --radius:       10px;
  --shadow:       0 2px 12px rgba(28,79,130,.09);
  --shadow-md:    0 4px 24px rgba(28,79,130,.14);
  --transition:   .18s ease;
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  margin: 0;
  overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-light); }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #b0bec5; border-radius: 3px; }

/* ============================================================
   SIDEBAR
   ============================================================ */
#sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  z-index: 1040;
  display: flex; flex-direction: column;
  transition: transform var(--transition);
  overflow: hidden;
}
#sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 20px;
  background: rgba(255,255,255,.04);
  border-bottom: 1px solid rgba(255,255,255,.07);
  min-height: var(--topbar-h);
}
#sidebar-brand img {
  width: 40px; height: 40px; border-radius: 8px; object-fit: cover;
  background: #fff;
}
#sidebar-brand .brand-text { flex: 1; overflow: hidden; }
#sidebar-brand .brand-name {
  color: #fff; font-weight: 700; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#sidebar-brand .brand-sub { color: rgba(255,255,255,.45); font-size: 11px; }

#sidebar-menu {
  flex: 1; overflow-y: auto; padding: 12px 0;
}
#sidebar-menu::-webkit-scrollbar { width: 3px; }

.menu-section-label {
  color: rgba(255,255,255,.3);
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  padding: 14px 20px 6px;
}

.sidebar-item { position: relative; }

.sidebar-link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 20px;
  color: rgba(255,255,255,.72);
  font-size: 13.5px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  border-radius: 0;
  user-select: none;
}
.sidebar-link i { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-link .link-label { flex: 1; }
.sidebar-link .arrow {
  font-size: 11px; transition: transform var(--transition);
  color: rgba(255,255,255,.3);
}
.sidebar-link:hover, .sidebar-link.active {
  background: rgba(255,255,255,.08);
  color: #fff;
}
.sidebar-link.active { border-left: 3px solid var(--accent); }
.sidebar-link.parent-active { color: #fff; }
.sidebar-link.parent-active .arrow { transform: rotate(90deg); }

.sidebar-submenu {
  display: none;
  background: rgba(0,0,0,.18);
  padding: 4px 0;
}
.sidebar-submenu.open { display: block; }
.sidebar-submenu a {
  display: block;
  padding: 8px 20px 8px 52px;
  color: rgba(255,255,255,.6);
  font-size: 13px;
  transition: color var(--transition), background var(--transition);
}
.sidebar-submenu a:hover, .sidebar-submenu a.active {
  color: #fff;
  background: rgba(255,255,255,.05);
}

/* ============================================================
   TOPBAR
   ============================================================ */
#topbar {
  position: fixed; top: 0; left: var(--sidebar-w); right: 0;
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  z-index: 1030;
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
#sidebar-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 20px; padding: 4px;
  display: none;
}
#topbar .page-title-bar {
  flex: 1;
  font-size: 16px; font-weight: 600; color: var(--text);
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* User dropdown — pushed right of sidebar, not hidden by it */
.user-dropdown-wrapper { position: relative; }
.user-dropdown-btn {
  display: flex; align-items: center; gap: 10px;
  background: none; border: none; cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius);
  transition: background var(--transition);
}
.user-dropdown-btn:hover { background: var(--bg); }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary);
  color: #fff; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-info { text-align: left; line-height: 1.3; }
.user-info .uname { font-size: 13.5px; font-weight: 600; color: var(--text); }
.user-info .urole { font-size: 11.5px; color: var(--muted); }
.user-dropdown-menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 180px;
  display: none; z-index: 2000;
}
.user-dropdown-menu.show { display: block; }
.user-dropdown-menu a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  color: var(--text); font-size: 13.5px;
  transition: background var(--transition);
}
.user-dropdown-menu a:hover { background: var(--bg); }
.user-dropdown-menu .divider { border-top: 1px solid var(--border); margin: 4px 0; }

/* Notification bell */
.notif-btn {
  position: relative; background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 18px; padding: 6px;
  border-radius: 8px; transition: background var(--transition), color var(--transition);
}
.notif-btn:hover { background: var(--bg); color: var(--primary); }
.notif-badge {
  position: absolute; top: 3px; right: 3px;
  background: var(--danger); color: #fff;
  font-size: 9px; font-weight: 700;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}

/* ============================================================
   CONTENT AREA
   ============================================================ */
#content-wrapper {
  margin-left: var(--sidebar-w);
  padding-top: var(--topbar-h);
  min-height: 100vh;
  display: flex; flex-direction: column;
}
#main-content { flex: 1; padding: 24px; }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.page-header h4 { margin: 0; font-size: 20px; font-weight: 700; color: var(--text); }
.breadcrumb-bar {
  font-size: 12.5px; color: var(--muted);
  margin-bottom: 16px;
}
.breadcrumb-bar a { color: var(--muted); }
.breadcrumb-bar a:hover { color: var(--primary); }
.breadcrumb-bar .sep { margin: 0 6px; }

/* ============================================================
   CARDS
   ============================================================ */
.card-box {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card-box .card-title {
  font-size: 15px; font-weight: 700;
  color: var(--text);
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.card-box .card-title i { color: var(--accent); }

/* Stat widgets */
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 22px;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 52px; height: 52px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-icon.blue   { background: #e8f0fb; color: var(--primary); }
.stat-icon.teal   { background: var(--accent-light); color: var(--accent); }
.stat-icon.green  { background: #e8f8ee; color: var(--success); }
.stat-icon.orange { background: #fff3e0; color: #f57c00; }
.stat-icon.red    { background: #fdecea; color: var(--danger); }
.stat-icon.purple { background: #f3e8fd; color: #7b1fa2; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--text); line-height: 1; }
.stat-label { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

/* ============================================================
   TABLES
   ============================================================ */
.table-responsive { overflow-x: auto; }
.table {
  width: 100%; border-collapse: collapse;
  font-size: 13.5px; color: var(--text);
}
.table thead th {
  background: #f6f9fc;
  border-bottom: 2px solid var(--border);
  font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted);
  padding: 10px 14px;
  white-space: nowrap;
}
.table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f0f3f8;
  vertical-align: middle;
}
.table tbody tr:hover { background: #f8fafd; }
.table-sm td, .table-sm th { padding: 7px 12px; }

/* ============================================================
   FORMS
   ============================================================ */
.form-label { font-weight: 600; font-size: 13px; color: var(--text); margin-bottom: 5px; display: block; }
.form-control, .form-select {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 13.5px;
  color: var(--text);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(28,79,130,.1);
}
.form-control.is-invalid { border-color: var(--danger); }
.invalid-feedback { color: var(--danger); font-size: 12px; margin-top: 3px; }
.form-group { margin-bottom: 16px; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px;
  font-size: 13.5px; font-weight: 600;
  border-radius: 7px; border: none; cursor: pointer;
  transition: all var(--transition);
  text-decoration: none; white-space: nowrap;
  line-height: 1.4;
}
.btn:active { transform: scale(.97); }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-accent    { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #138496; color: #fff; }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { background: #218838; color: #fff; }
.btn-warning   { background: var(--warning); color: #212529; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #bd2130; color: #fff; }
.btn-secondary { background: #e9edf2; color: var(--text); }
.btn-secondary:hover { background: #dde3ea; }
.btn-outline-primary { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }
.btn-outline-danger { background: transparent; border: 1.5px solid var(--danger); color: var(--danger); }
.btn-outline-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12.5px; border-radius: 6px; }
.btn-xs { padding: 3px 9px; font-size: 11.5px; border-radius: 5px; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { padding: 7px; border-radius: 7px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600;
}
.badge-primary   { background: #dbeafe; color: var(--primary); }
.badge-success   { background: #d1fae5; color: #065f46; }
.badge-warning   { background: #fef3c7; color: #92400e; }
.badge-danger    { background: #fee2e2; color: #991b1b; }
.badge-info      { background: var(--accent-light); color: #0e7490; }
.badge-secondary { background: #f1f5f9; color: var(--muted); }
.badge-dark      { background: #1e293b; color: #fff; }
.badge-purple    { background: #f3e8fd; color: #6b21a8; }
.badge-orange    { background: #fff3e0; color: #b45309; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  padding: 12px 16px; border-radius: 8px;
  margin-bottom: 16px; font-size: 13.5px;
  display: flex; align-items: flex-start; gap: 10px;
}
.alert i { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.alert .btn-close { margin-left: auto; background: none; border: none; cursor: pointer; opacity: .5; font-size: 16px; }
.alert .btn-close:hover { opacity: 1; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: var(--accent-light); color: #0e7490; border: 1px solid #a5f3fc; }

/* ============================================================
   STATUS PILLS (pipeline tracking)
   ============================================================ */
.status-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
  cursor: pointer; text-decoration: none;
}
.status-pill:hover { filter: brightness(.92); }
.status-registered        { background: #dbeafe; color: #1e40af; }
.status-awaiting_triage   { background: #fef3c7; color: #92400e; }
.status-awaiting_doctor   { background: #f3e8fd; color: #6b21a8; }
.status-awaiting_lab      { background: var(--accent-light); color: #0e7490; }
.status-lab_in_progress   { background: #cffafe; color: #155e75; }
.status-awaiting_dispensing { background: #fef3c7; color: #92400e; }
.status-admitted          { background: #d1fae5; color: #065f46; }
.status-discharged, .status-completed { background: #f1f5f9; color: #475569; }
.status-referred          { background: #fff3e0; color: #b45309; }
.status-cancelled         { background: #fee2e2; color: #991b1b; }

/* ============================================================
   AUTH PAGES
   ============================================================ */
.auth-body {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark) 0%, #1a6a8a 100%);
}
.auth-card {
  background: #fff; border-radius: 14px;
  padding: 36px; width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.auth-card-header { text-align: center; margin-bottom: 28px; }
.auth-card-header h2 { color: var(--primary); font-weight: 800; margin-bottom: 4px; }
.auth-card-header p { color: var(--muted); font-size: 14px; margin: 0; }
.auth-logo { width: 60px; height: 60px; border-radius: 12px; margin-bottom: 12px; }
.auth-footer { text-align: center; margin-top: 16px; font-size: 13.5px; }
.auth-footer a { color: var(--primary); font-weight: 600; }

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
  #sidebar, #topbar, .no-print, .btn, .breadcrumb-bar { display: none !important; }
  #content-wrapper { margin: 0; padding: 0; }
  #main-content { padding: 0; }
  .card-box { box-shadow: none; border: 1px solid #ccc; }
  body { background: #fff; }
}

/* A4 print size */
.print-a4 { width: 210mm; min-height: 297mm; margin: auto; background: #fff; padding: 15mm; }
/* 80mm receipt printer */
.print-p80 { width: 80mm; margin: auto; background: #fff; padding: 4mm; font-size: 11px; }
.print-p80 .receipt-title { text-align: center; font-weight: 700; font-size: 13px; }
.print-p80 .receipt-divider { border-top: 1px dashed #000; margin: 4px 0; }
.print-p80 .receipt-row { display: flex; justify-content: space-between; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 991px) {
  #sidebar { transform: translateX(calc(-1 * var(--sidebar-w))); }
  #sidebar.open { transform: translateX(0); box-shadow: var(--shadow-md); }
  #content-wrapper { margin-left: 0; }
  #topbar { left: 0; }
  #sidebar-toggle { display: block; }
  .sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.4); z-index: 1039;
  }
  .sidebar-overlay.show { display: block; }
}
@media (max-width: 576px) {
  #main-content { padding: 16px; }
  .card-box { padding: 14px 16px; }
  .page-header h4 { font-size: 17px; }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger) !important; }
.text-warning { color: #c8941a !important; }
.text-muted   { color: var(--muted) !important; }
.text-accent  { color: var(--accent) !important; }
.fw-700 { font-weight: 700; }
.fw-600 { font-weight: 600; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.mt-0 { margin-top: 0 !important; }
.mt-2 { margin-top: 8px !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-2 { margin-bottom: 8px !important; }
.mb-3 { margin-bottom: 16px !important; }
.me-2 { margin-right: 8px !important; }
.p-0  { padding: 0 !important; }
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.text-center { text-align: center; }
.text-end { text-align: right; }
.w-100 { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
@media (min-width: 576px) and (max-width: 991px) {
  .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
}
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.info-row { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px solid #f0f3f8; font-size: 13.5px; }
.info-row .info-label { font-weight: 600; color: var(--muted); min-width: 140px; flex-shrink: 0; }
.info-row .info-val { color: var(--text); }
.vitals-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(130px,1fr)); gap: 10px; margin-top: 10px; }
.vital-card { background: #f6f9fc; border-radius: 8px; padding: 10px 12px; text-align: center; border: 1px solid var(--border); }
.vital-card .vital-val { font-size: 20px; font-weight: 800; color: var(--primary); }
.vital-card .vital-label { font-size: 11px; color: var(--muted); margin-top: 2px; }
.vital-card.abnormal { background: #fdecea; border-color: #fca5a5; }
.vital-card.abnormal .vital-val { color: var(--danger); }

/* Search box */
.search-box { position: relative; }
.search-box input { padding-left: 36px; }
.search-box i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }

/* Tabs */
.tab-nav { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 18px; }
.tab-link {
  padding: 9px 18px; font-size: 13.5px; font-weight: 600;
  color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
}
.tab-link.active, .tab-link:hover { color: var(--primary); border-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* Empty state */
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state i { font-size: 48px; margin-bottom: 12px; opacity: .35; display: block; }
.empty-state p { font-size: 14px; }

/* Timeline */
.timeline { padding: 0; list-style: none; }
.timeline-item { display: flex; gap: 14px; margin-bottom: 16px; }
.timeline-icon { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.timeline-body { flex: 1; }
.timeline-time { font-size: 11.5px; color: var(--muted); }
.timeline-text { font-size: 13.5px; }
