/* ========================
   MediCore HMS - App CSS
   Primary: #005454 (Teal)
   Accent: #E8A838 (Amber)
   ======================== */

:root {
  --primary: #005454;
  --primary-dark: #065252;
  --primary-light: #0A6E6E;
  --accent: #E8A838;
  --accent-dark: #C48A20;
  --sidebar-width: 240px;
  --topbar-height: 64px;
  --border-color: #D6E4E4;
  --bg-light: #F0F4F4;
  --text-muted: #8FA5A5;
  --success: #16A34A;
  --danger: #DC2626;
  --warning: #D97706;
  --info: #0284C7;
}

/* Body & Base */
* { box-sizing: border-box; }
body {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  background: #f7fafa;
  color: #181c1d;
  overflow-x: hidden;
}
.font-mono { font-family: 'JetBrains Mono', monospace; }

/* ---- SIDEBAR ---- */
.medicore-sidebar {
  position: fixed;
  left: 0; top: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background: #0A6E6E;
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: width 0.25s ease;
  overflow: hidden;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  min-height: var(--topbar-height);
}
.brand-logo {
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.15);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 18px;
  flex-shrink: 0;
}
.brand-name {
  font-size: 18px;
  font-weight: 700;
  color: white;
  letter-spacing: -0.3px;
}
.brand-sub {
  font-size: 10px;
  color: rgba(255,255,255,0.6);
  display: block;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.user-avatar {
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}
.sidebar-user .user-name {
  font-size: 13px;
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.sidebar-user .user-role {
  font-size: 11px;
  color: rgba(255,255,255,0.65);
  text-transform: capitalize;
}
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }
.nav-category {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 12px 20px 4px;
}
.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: 13.5px;
  border-left: 3px solid transparent;
  transition: all 0.15s ease;
  border-radius: 0;
  white-space: nowrap;
}
.sidebar-nav .nav-link:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}
.sidebar-nav .nav-link.active {
  background: rgba(255,255,255,0.15);
  border-left-color: var(--accent);
  color: white;
  font-weight: 600;
}
.sidebar-nav .nav-link i { font-size: 16px; flex-shrink: 0; }
.nav-sub-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 20px 7px 48px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 13px;
  transition: all 0.15s ease;
}
.nav-sub-link:hover { color: white; background: rgba(255,255,255,0.08); }
.nav-sub-link.active { color: white; font-weight: 500; }
.nav-accordion-body { display: none; }
.nav-accordion-body.open { display: block; }
.toggle-icon { transition: transform 0.2s ease; font-size: 12px !important; }
.nav-accordion.open .toggle-icon { transform: rotate(180deg); }

/* ---- TOPBAR ---- */
.medicore-topbar {
  position: fixed;
  top: 0; left: var(--sidebar-width); right: 0;
  height: var(--topbar-height);
  background: white;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  z-index: 1030;
  transition: left 0.25s ease;
}
.topbar-left { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.sidebar-toggle-btn { color: #6c757d; padding: 6px; line-height: 1; }
.sidebar-toggle-btn:hover { color: var(--primary); }
.topbar-brand { text-decoration: none; color: var(--primary); font-weight: 600; font-size: 15px; white-space: nowrap; }
.topbar-search { flex: 1; max-width: 480px; position: relative; }
.search-wrapper { position: relative; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search-input { padding-left: 36px; background: #f0f4f4; border-color: var(--border-color); border-radius: 8px; }
.search-input:focus { background: white; box-shadow: 0 0 0 3px rgba(0,84,84,0.1); border-color: var(--primary); }
.search-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: white; border: 1px solid var(--border-color);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  z-index: 1050; max-height: 360px; overflow-y: auto;
}
.topbar-right { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.topbar-btn { color: #6c757d; padding: 8px; position: relative; line-height: 1; }
.topbar-btn:hover { color: var(--primary); }
.notification-badge {
  position: absolute; top: 2px; right: 2px;
  font-size: 10px; min-width: 16px; height: 16px;
  padding: 0 4px; line-height: 16px;
}
.notification-menu { width: 360px; max-height: 480px; overflow-y: auto; }
.user-avatar-sm {
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 12px; font-weight: 600;
}
.user-meta { display: flex !important; flex-direction: column; gap: 2px;}
.user-display-name { font-size: 13px; font-weight: 600; color: #181c1d; line-height: 1; margin-bottom: 5px; }
.user-display-role { font-size: 11px; color: var(--text-muted); text-transform: capitalize; line-height: 1; }
.user-btn { display: flex; align-items: center; gap: 8px; }
.user-menu { min-width: 200px; }

/* ---- MAIN CONTENT ---- */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  padding: 24px;
  min-height: calc(100vh - var(--topbar-height));
  transition: margin-left 0.25s ease;
}

/* ---- SIDEBAR COLLAPSED STATE ---- */
.sidebar-collapsed .medicore-sidebar { width: 64px; }
.sidebar-collapsed .medicore-topbar { left: 64px; }
.sidebar-collapsed .main-content { margin-left: 64px; }
.sidebar-collapsed .brand-text,
.sidebar-collapsed .user-info,
.sidebar-collapsed .sidebar-nav .nav-link span,
.sidebar-collapsed .nav-category,
.sidebar-collapsed .nav-accordion-body { display: none; }
.sidebar-collapsed .sidebar-nav .nav-link { padding: 10px 0; justify-content: center; }
.sidebar-collapsed .sidebar-nav .nav-link i { font-size: 20px; }
.sidebar-collapsed .sidebar-user { justify-content: center; }

/* ---- PAGE HEADER ---- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  gap: 16px;
}
.page-title {
  font-size: 24px;
  font-weight: 700;
  color: #1A2E2E;
  margin: 0 0 4px;
  line-height: 1.2;
}
.page-subtitle { font-size: 14px; color: var(--text-muted); margin: 0; }
.page-header-actions { display: flex; gap: 8px; flex-shrink: 0; }
.breadcrumb { font-size: 12px; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--text-muted); }

/* ---- CARDS ---- */
.stat-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  border-left: 4px solid var(--primary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.stat-card-icon {
  width: 40px; height: 40px;
  background: #E6F4F4;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
  font-size: 20px;
}
.stat-card-value {
  font-size: 28px;
  font-weight: 700;
  color: #1A2E2E;
  line-height: 1;
}
.stat-card-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}
.content-card {
  background: white;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.content-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.content-card-title { font-size: 16px; font-weight: 600; color: #1A2E2E; margin: 0; }
.content-card-body { padding: 20px; }

/* ---- BUTTONS ---- */
.btn-primary {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: white;
}
.btn-primary:hover { background: var(--primary-dark) !important; border-color: var(--primary-dark) !important; }
.btn-outline-primary { color: var(--primary) !important; border-color: var(--primary) !important; }
.btn-outline-primary:hover { background: var(--primary) !important; color: white !important; }

/* ---- FORMS ---- */
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,84,84,0.1);
}
.form-label { font-size: 13px; font-weight: 500; color: #3e4948; margin-bottom: 4px; }
.form-section { margin-bottom: 28px; }
.form-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  padding-bottom: 8px;
  border-bottom: 2px solid #E6F4F4;
  margin-bottom: 16px;
}

/* ---- TABLES ---- */
.table thead th {
  background: #f7fafa;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border-color);
  vertical-align: middle;
}
.table tbody td { vertical-align: middle; padding: 12px 16px; }
.table tbody tr:hover { background: #f7fafa; }
.table-sm thead th,
.table-sm tbody td { padding: 8px 12px; }
.mrn-badge { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: #4A6060; }

/* ---- BADGES ---- */
.badge { font-size: 11px; font-weight: 500; padding: 4px 8px; border-radius: 4px; }

/* ---- AUTH PAGES ---- */
.auth-body { background: #f7fafa; min-height: 100vh; }
.auth-panel-left {
  background: #0A6E6E;
  min-height: 100vh;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px;
  overflow: hidden;
}
.auth-panel-right {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  background: white;
}
.auth-form-wrapper { width: 100%; max-width: 420px; }
.auth-title { font-size: 28px; font-weight: 700; color: #1A2E2E; margin-bottom: 6px; }
.auth-subtitle { font-size: 14px; color: var(--text-muted); margin-bottom: 32px; }

/* ---- BED MANAGEMENT ---- */
.bed-card {
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 12px;
}
.bed-card.available { background: #f0fdf4; border-color: #86efac; color: #15803d; }
.bed-card.occupied { background: #fef2f2; border-color: #fca5a5; color: #dc2626; }
.bed-card.maintenance { background: #fefce8; border-color: #fde047; color: #ca8a04; }
.bed-card.reserved { background: #eff6ff; border-color: #93c5fd; color: #1d4ed8; }
.bed-card:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }

/* ---- MISC ---- */
.avatar-circle {
  width: 38px; height: 38px;
  background: var(--primary);
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: white; font-size: 12px; font-weight: 600;
}
.filter-bar {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}
.timeline-item { border-left: 2px solid var(--border-color); padding-left: 20px; margin-bottom: 20px; position: relative; }
.timeline-item::before {
  content: '';
  position: absolute;
  left: -6px; top: 4px;
  width: 10px; height: 10px;
  background: var(--primary);
  border-radius: 50%;
}

/* ---- SEARCH RESULT ITEM ---- */
.search-result-item:hover { background: #f7fafa; }

/* ---- NOTIFICATION ITEM ---- */
.notification-item { white-space: normal; }

/* ---- Sidebar backdrop (mobile) ---- */
#sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1039;
}
.sidebar-open #sidebar-backdrop { display: block; }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .medicore-sidebar { transform: translateX(-100%); width: var(--sidebar-width); transition: transform .25s ease; z-index: 1040; }
  .medicore-topbar { left: 0; }
  .main-content { margin-left: 0; }
  .sidebar-open .medicore-sidebar { transform: translateX(0); }
  .topbar-search { display: none; }
  .page-header { flex-direction: column; }
  .page-header-actions { width: 100%; }
}
