/* IBR Hospital — Dashboard */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow-x: hidden; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background: #f0f4f8;
  display: flex;
  color: #0d1f3c;
  overflow-x: hidden;
}

/* ════ SIDEBAR ════ */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: #060f1e;
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform .3s ease;
}

.sidebar-brand {
  padding: 28px 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand-logo { display: flex; flex-direction: column; line-height: 1; margin-bottom: 6px; }
.brand-ibr { font-size: 1.8rem; font-weight: 800; color: #fff; letter-spacing: -.03em; }
.brand-hosp { font-size: .58rem; font-weight: 700; letter-spacing: .25em; text-transform: uppercase; color: #5a9ef0; margin-top: 1px; }
.brand-sub { font-size: .72rem; color: rgba(255,255,255,.3); }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-section { margin-bottom: 8px; }
.nav-section-label {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: rgba(255,255,255,.25);
  padding: 12px 12px 6px;
  display: block;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,.55);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  transition: all .2s;
  margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: rgba(255,255,255,.9); }
.nav-item.active { background: #1a5ccc; color: #fff; font-weight: 600; }
.nav-item svg { flex-shrink: 0; }
.nav-item span:first-of-type { flex: 1; }
.nav-badge {
  font-size: .68rem;
  font-weight: 700;
  background: rgba(255,255,255,.15);
  color: #fff;
  padding: 2px 7px;
  border-radius: 50px;
  min-width: 20px;
  text-align: center;
}
.nav-badge--red { background: #ef4444; }
.nav-badge:empty, .nav-badge[data-count="0"] { display: none; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #1a5ccc;
  color: #fff;
  font-weight: 700;
  font-size: .9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: .82rem; font-weight: 600; color: rgba(255,255,255,.85); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .72rem; color: rgba(255,255,255,.35); }
.btn-logout {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  color: rgba(255,255,255,.4);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all .2s;
  flex-shrink: 0;
}
.btn-logout:hover { background: #ef4444; border-color: #ef4444; color: #fff; }

/* ════ MAIN ════ */
.main {
  margin-left: 260px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0; /* ✅ fix scroll */
  overflow-x: hidden; /* ✅ fix scroll */
}

/* ── Topbar ── */
.topbar {
  background: #fff;
  border-bottom: 1px solid #e8edf5;
  padding: 16px 32px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 16px; min-width: 0; } /* ✅ fix scroll */
.btn-toggle-sidebar {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: #f0f4f8;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #3d5175;
  transition: all .2s;
  flex-shrink: 0;
}
.btn-toggle-sidebar:hover { background: #e2e8f0; }
.page-title { font-size: 1.05rem; font-weight: 700; color: #0d1f3c; }
.page-sub { font-size: .75rem; color: #7a90b3; margin-top: 1px; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; } /* ✅ fix scroll */
.btn-site {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f0f4f8;
  border: 1px solid #e2e8f0;
  color: #3d5175;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 600;
  text-decoration: none;
  transition: all .2s;
}
.btn-site:hover { background: #deeafd; border-color: #1a5ccc; color: #1a5ccc; }

/* ── Content ── */
.content { padding: 28px 32px; flex: 1; overflow-x: hidden; } /* ✅ fix scroll */

/* ── Stats ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 1px 4px rgba(13,32,68,.06);
  border: 1px solid #e8edf5;
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-card--blue .stat-icon { background: #deeafd; color: #1a5ccc; }
.stat-card--green .stat-icon { background: #d1fae5; color: #059669; }
.stat-card--orange .stat-icon { background: #ffedd5; color: #ea580c; }
.stat-card--red .stat-icon { background: #fee2e2; color: #dc2626; }
.stat-num { font-size: 1.8rem; font-weight: 800; color: #0d1f3c; line-height: 1; }
.stat-label { font-size: .78rem; color: #7a90b3; margin-top: 3px; }

/* ── Quick cards ── */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.quick-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
  border: 1.5px solid #e8edf5;
  transition: all .2s;
  box-shadow: 0 1px 4px rgba(13,32,68,.06);
}
.quick-card:hover { border-color: #1a5ccc; box-shadow: 0 4px 16px rgba(26,92,204,.12); transform: translateY(-2px); }
.quick-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: #f0f6ff;
  border: 1.5px solid #deeafd;
  display: flex; align-items: center; justify-content: center;
  color: #1a5ccc;
  flex-shrink: 0;
}
.quick-card:hover .quick-icon { background: #1a5ccc; border-color: #1a5ccc; color: #fff; }
.quick-card strong { display: block; font-size: .95rem; font-weight: 700; color: #0d1f3c; }
.quick-card p { font-size: .8rem; color: #7a90b3; margin-top: 2px; }

/* ════ TABLE ════ */
.table-wrap {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e8edf5;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(13,32,68,.06);
}
.table-header {
  padding: 18px 24px;
  border-bottom: 1px solid #e8edf5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.table-header h2 { font-size: 1rem; font-weight: 700; color: #0d1f3c; }
.table-actions { display: flex; gap: 8px; align-items: center; }

table { width: 100%; border-collapse: collapse; }
th {
  background: #f8fafc;
  padding: 11px 16px;
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #7a90b3;
  border-bottom: 1px solid #e8edf5;
}
td {
  padding: 13px 16px;
  font-size: .875rem;
  color: #3d5175;
  border-bottom: 1px solid #f0f4f8;
  vertical-align: middle;
  max-width: 250px; /* ✅ fix scroll */
  overflow: hidden; /* ✅ fix scroll */
  text-overflow: ellipsis; /* ✅ fix scroll */
  white-space: nowrap; /* ✅ fix scroll */
}
td strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } /* ✅ fix scroll */
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 50px;
  font-size: .72rem;
  font-weight: 700;
}
.badge--green { background: #d1fae5; color: #059669; }
.badge--red { background: #fee2e2; color: #dc2626; }
.badge--blue { background: #deeafd; color: #1a5ccc; }
.badge--gray { background: #f0f4f8; color: #7a90b3; }
.badge--orange { background: #ffedd5; color: #ea580c; }

/* ════ BUTTONS ════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 8px;
  font-size: .85rem; font-weight: 600; font-family: inherit;
  cursor: pointer; border: none; transition: all .2s; text-decoration: none;
}
.btn--primary { background: #1a5ccc; color: #fff; }
.btn--primary:hover { background: #2e7ae0; box-shadow: 0 3px 10px rgba(26,92,204,.3); }
.btn--outline { background: #fff; color: #3d5175; border: 1.5px solid #e2e8f0; }
.btn--outline:hover { border-color: #1a5ccc; color: #1a5ccc; }
.btn--danger { background: #fff; color: #dc2626; border: 1.5px solid #fecaca; }
.btn--danger:hover { background: #dc2626; color: #fff; }
.btn--sm { padding: 6px 10px; font-size: .78rem; }
.btn--icon { padding: 7px; border-radius: 7px; }

/* ════ MODAL / FORM ════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(6,15,30,.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 16px;
  width: 100%; max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid #e8edf5;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 1rem; font-weight: 700; color: #0d1f3c; }
.modal-close {
  width: 32px; height: 32px;
  border-radius: 8px; background: #f0f4f8; border: none;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: #7a90b3; transition: all .2s;
}
.modal-close:hover { background: #fee2e2; color: #dc2626; }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid #e8edf5;
  display: flex; justify-content: flex-end; gap: 10px;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .78rem; font-weight: 700; color: #3d5175; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid #e2e8f0; border-radius: 8px;
  font-size: .9rem; font-family: inherit; color: #0d1f3c;
  background: #fafbfc; transition: all .2s; outline: none;
  resize: vertical;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: #1a5ccc; background: #fff; box-shadow: 0 0 0 3px rgba(26,92,204,.1); }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #0d1f3c; color: #fff;
  padding: 12px 20px; border-radius: 10px;
  font-size: .875rem; font-weight: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,.25);
  z-index: 500; display: none;
  align-items: center; gap: 10px;
  max-width: 360px;
}
.toast.show { display: flex; animation: slideIn .3s ease; }
.toast--success { border-left: 4px solid #059669; }
.toast--error { border-left: 4px solid #dc2626; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Empty ── */
.empty-state {
  text-align: center; padding: 56px 24px; color: #7a90b3;
}
.empty-state svg { opacity: .3; margin-bottom: 12px; }
.empty-state p { font-size: .9rem; }

/* ── Loading ── */
.skeleton { background: linear-gradient(90deg, #f0f4f8 25%, #e8edf5 50%, #f0f4f8 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 6px; height: 20px; }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .quick-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-260px); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .quick-grid { grid-template-columns: 1fr; }
  .content { padding: 20px 16px; }
  .topbar { padding: 0 16px; }
  .form-row { grid-template-columns: 1fr; }
  td { max-width: 150px; }
}