/* ═══════════════════════════════════════════════════════════
   MediCore — Premium Medical SaaS CSS
   Color Palette:
     Primary Blue:  #1a3c5e
     Teal Accent:   #00b4b4
     Light:         #f0f4f8
     Card BG:       #ffffff
   ═══════════════════════════════════════════════════════════ */

:root {
  --primary:       #1a3c5e;
  --primary-light: #2a5c8e;
  --teal:          #00b4b4;
  --teal-dark:     #008a8a;
  --teal-light:    #e0f7f7;
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 68px;
  --topbar-height: 64px;
  --border-radius: 12px;
  --shadow-sm:     0 2px 8px rgba(26,60,94,0.08);
  --shadow-md:     0 4px 20px rgba(26,60,94,0.12);
  --shadow-lg:     0 8px 40px rgba(26,60,94,0.16);
  --transition:    all 0.25s cubic-bezier(0.4,0,0.2,1);
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body.medicore-body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f0f4f8;
  color: #1e293b;
  margin: 0;
  overflow-x: hidden;
}

[data-bs-theme="dark"] body.medicore-body,
[data-bs-theme="dark"] {
  --bs-body-bg: #0f172a;
  --bs-body-color: #e2e8f0;
  background: #0f172a !important;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #1a3c5e 0%, #0d2540 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: var(--transition);
  box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  min-height: 72px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  overflow: hidden;
}

.brand-icon {
  color: var(--teal);
  font-size: 1.5rem;
  flex-shrink: 0;
}

.brand-text {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: 0.5px;
  transition: var(--transition);
}

.sidebar.collapsed .brand-text { opacity: 0; width: 0; }

.sidebar-toggle-btn {
  background: rgba(255,255,255,0.08);
  border: none;
  color: #fff;
  border-radius: 8px;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}
.sidebar-toggle-btn:hover { background: rgba(255,255,255,0.18); }

/* User info block */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  overflow: hidden;
}

.sidebar-avatar, .sidebar-avatar-placeholder {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--teal);
}

.sidebar-avatar-placeholder {
  background: linear-gradient(135deg, var(--teal), var(--teal-dark));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem;
}

.sidebar-user-info { overflow: hidden; white-space: nowrap; transition: var(--transition); }
.sidebar-user-name { font-weight: 600; font-size: 0.85rem; }
.sidebar-user-role { font-size: 0.65rem; letter-spacing: 0.8px; }
.sidebar.collapsed .sidebar-user-info { opacity: 0; width: 0; }

/* Sidebar nav */
.sidebar-nav {
  list-style: none;
  margin: 0; padding: 12px 0;
  overflow-y: auto;
  flex: 1;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

.nav-section-title {
  padding: 10px 18px 4px;
  font-size: 0.65rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  font-weight: 600;
  white-space: nowrap;
  transition: var(--transition);
}
.sidebar.collapsed .nav-section-title { opacity: 0; }

.sidebar-item { margin: 2px 10px; border-radius: 8px; transition: var(--transition); }
.sidebar-item.active { background: linear-gradient(90deg, var(--teal), var(--teal-dark)); }
.sidebar-item:not(.active):hover { background: rgba(255,255,255,0.08); }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 8px;
  transition: var(--transition);
  white-space: nowrap;
}
.sidebar-item.active .sidebar-link { color: #fff; }
.sidebar-link i { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar.collapsed .sidebar-link span { opacity: 0; width: 0; overflow: hidden; }
.text-danger-soft { color: #ff7b7b !important; }
.text-teal { color: var(--teal) !important; }

/* ── Main Wrapper ────────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-width);
  transition: var(--transition);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.main-wrapper.sidebar-collapsed { margin-left: var(--sidebar-collapsed-width); }

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid rgba(26,60,94,0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 900;
  box-shadow: var(--shadow-sm);
}

[data-bs-theme="dark"] .topbar {
  background: #1e293b;
  border-color: rgba(255,255,255,0.06);
}

.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }

.topbar-toggle, .topbar-btn {
  background: transparent;
  border: none;
  color: #64748b;
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition);
}
.topbar-toggle:hover, .topbar-btn:hover { background: #f1f5f9; color: var(--primary); }

.breadcrumb { font-size: 0.8rem; }
.breadcrumb-item a { color: var(--teal); text-decoration: none; }

/* Search bar */
.topbar-search { flex: 1; max-width: 340px; }
.search-wrap { position: relative; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #94a3b8; font-size: 0.85rem; }
.search-input {
  width: 100%;
  padding: 8px 14px 8px 36px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.85rem;
  background: #f8fafc;
  transition: var(--transition);
  outline: none;
}
.search-input:focus { border-color: var(--teal); background: #fff; box-shadow: 0 0 0 3px rgba(0,180,180,0.1); }

/* Topbar avatar */
.topbar-avatar-btn {
  background: transparent; border: none; cursor: pointer; padding: 0;
}
.topbar-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 2px solid var(--teal); }
.topbar-avatar-text {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--teal), var(--primary));
  color: #fff; font-size: 0.75rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--teal);
}

/* ── Page Content ────────────────────────────────────────── */
.page-content {
  padding: 28px;
  flex: 1;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
  border: none !important;
  border-radius: var(--border-radius) !important;
  box-shadow: var(--shadow-sm) !important;
  transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-md) !important; }

/* Stat Cards */
.stat-card {
  border-radius: var(--border-radius);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.stat-card::after {
  content: '';
  position: absolute;
  right: -20px; top: -20px;
  width: 100px; height: 100px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
}
.stat-card-blue  { background: linear-gradient(135deg, #1a3c5e, #2a5c8e); }
.stat-card-teal  { background: linear-gradient(135deg, #00b4b4, #007a7a); }
.stat-card-green { background: linear-gradient(135deg, #059669, #047857); }
.stat-card-purple{ background: linear-gradient(135deg, #7c3aed, #5b21b6); }

.stat-card-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: rgba(255,255,255,0.18);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.stat-card-info .stat-value {
  font-size: 2rem; font-weight: 700;
  font-family: 'Poppins', sans-serif;
  line-height: 1;
}
.stat-card-info .stat-label {
  font-size: 0.8rem; opacity: 0.85;
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-top: 4px;
}

/* ── Page Header ─────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title {
  font-family: 'Poppins', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
}
[data-bs-theme="dark"] .page-title { color: #e2e8f0; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn-primary { background: var(--primary) !important; border-color: var(--primary) !important; }
.btn-primary:hover { background: var(--primary-light) !important; border-color: var(--primary-light) !important; }
.btn-teal { background: var(--teal) !important; border-color: var(--teal) !important; color: #fff !important; }
.btn-teal:hover { background: var(--teal-dark) !important; border-color: var(--teal-dark) !important; }
.btn { border-radius: 8px !important; font-weight: 500; }

/* ── Tables ──────────────────────────────────────────────── */
.table { --bs-table-hover-bg: rgba(0,180,180,0.04); }
.table th {
  background: #f8fafc;
  color: var(--primary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
  border-bottom: 2px solid #e2e8f0;
}
[data-bs-theme="dark"] .table th { background: #1e293b; color: #94a3b8; }
.table td { vertical-align: middle; font-size: 0.875rem; }

/* ── Badges ──────────────────────────────────────────────── */
.bg-teal { background-color: var(--teal) !important; }
.badge { border-radius: 6px; font-weight: 600; letter-spacing: 0.3px; }

/* ── Forms ───────────────────────────────────────────────── */
.form-control, .form-select {
  border-radius: 8px !important;
  border: 1.5px solid #e2e8f0;
  font-size: 0.875rem;
  transition: var(--transition);
}
.form-control:focus, .form-select:focus {
  border-color: var(--teal) !important;
  box-shadow: 0 0 0 3px rgba(0,180,180,0.12) !important;
}
.form-label { font-weight: 600; font-size: 0.8rem; color: var(--primary); margin-bottom: 4px; }
[data-bs-theme="dark"] .form-label { color: #94a3b8; }

/* ── Doctor Card ─────────────────────────────────────────── */
.doctor-card {
  border-radius: var(--border-radius);
  overflow: hidden;
  transition: var(--transition);
  border: none;
  box-shadow: var(--shadow-sm);
}
.doctor-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.doctor-card-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  padding: 24px;
  text-align: center;
  color: #fff;
}
.doctor-avatar-ring {
  width: 80px; height: 80px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.5);
  object-fit: cover;
  margin: 0 auto 12px;
  display: block;
  background: rgba(255,255,255,0.1);
}
.doctor-avatar-placeholder {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--teal), var(--teal-dark));
  color: #fff;
  font-size: 1.8rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
  border: 3px solid rgba(255,255,255,0.3);
}

/* ── Prescription Print ──────────────────────────────────── */
@media print {
  .sidebar, .topbar, .no-print, .page-header .btn, nav { display: none !important; }
  .main-wrapper { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }
  body { background: #fff !important; }
  .rx-header { background: var(--primary) !important; -webkit-print-color-adjust: exact; }
  .card { box-shadow: none !important; border: 1px solid #dee2e6 !important; }
}

/* ── Visit Timeline ──────────────────────────────────────── */
.visit-timeline { position: relative; }
.visit-timeline::before {
  content: '';
  position: absolute;
  left: 20px; top: 0; bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, var(--teal), transparent);
}
.visit-card-wrapper { position: relative; padding-left: 50px; margin-bottom: 20px; }
.visit-dot {
  position: absolute;
  left: 12px; top: 16px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--teal);
  border: 3px solid #fff;
  box-shadow: 0 0 0 3px rgba(0,180,180,0.25);
}

/* ── Loading spinner ─────────────────────────────────────── */
.spinner-overlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.spinner-ring {
  width: 48px; height: 48px;
  border: 4px solid #e2e8f0;
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Alert overdue ───────────────────────────────────────── */
.overdue-badge { animation: pulse 2s infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-wrapper { margin-left: 0 !important; }
  .page-content { padding: 16px; }
  .topbar { padding: 0 14px; }
  .topbar-search { display: none; }
}

/* ── Prescription PDF ────────────────────────────────────── */
.rx-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  padding: 24px 32px;
  border-radius: var(--border-radius) var(--border-radius) 0 0;
}
.rx-symbol {
  font-family: 'Georgia', serif;
  font-size: 3rem;
  font-weight: 900;
  color: var(--teal);
  line-height: 1;
}
.rx-medicine-table th { background: var(--primary); color: #fff; }

/* ── Misc Utilities ──────────────────────────────────────── */
.bg-primary-soft { background: rgba(26,60,94,0.06); }
.bg-teal-soft { background: rgba(0,180,180,0.06); }
.text-primary-custom { color: var(--primary); }
.rounded-xl { border-radius: var(--border-radius) !important; }
.fs-xs { font-size: 0.75rem; }
.fs-sm { font-size: 0.85rem; }
.fw-600 { font-weight: 600; }
.shadow-custom { box-shadow: var(--shadow-md); }
