/* ================================================================
   SafeMedAI — Premium Healthcare Dashboard
   Aesthetic: Clinical Precision + Luminous Depth

   Navy-slate sidebar, frosted glass panels, teal pulse accents,
   soft warm background with micro-grain texture, breathing
   animations on critical elements.
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;0,9..40,800;1,9..40,400&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* ── Core palette ── */
  --accent: #0d9488;
  --accent-light: #2dd4bf;
  --accent-glow: rgba(13,148,136,.15);
  --accent-deep: #0f766e;
  --navy: #0f172a;
  --navy-light: #1e293b;
  --navy-mid: #334155;

  /* ── Semantic ── */
  --success: #10b981;
  --success-bg: rgba(16,185,129,.1);
  --warning: #f59e0b;
  --warning-bg: rgba(245,158,11,.1);
  --danger: #ef4444;
  --danger-bg: rgba(239,68,68,.1);
  --info: #3b82f6;
  --info-bg: rgba(59,130,246,.1);

  /* ── Neutrals (warm-shifted) ── */
  --g50: #fafaf9;
  --g100: #f5f5f4;
  --g200: #e7e5e4;
  --g300: #d6d3d1;
  --g400: #a8a29e;
  --g500: #78716c;
  --g600: #57534e;
  --g700: #44403c;
  --g800: #292524;
  --g900: #1c1917;

  /* ── Layout ── */
  --sidebar-w: 264px;
  --topbar-h: 0px; /* topbar merged into content area */
  --r: 16px;
  --r-sm: 10px;
  --r-xs: 6px;

  /* ── Glass ── */
  --glass: rgba(255,255,255,.72);
  --glass-border: rgba(255,255,255,.35);
  --glass-shadow: 0 4px 24px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.08);
  --glass-hover: 0 8px 32px rgba(15,23,42,.1), 0 2px 6px rgba(15,23,42,.06);
}

/* ── Reset & base ───────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--g100);
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(13,148,136,.04) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(59,130,246,.03) 0%, transparent 50%);
  color: var(--g800);
  margin: 0;
  min-height: 100vh;
  font-size: .9375rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--g300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--g400); }

/* ── Entrance animation ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.25); }
  50%      { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.main-content > * {
  animation: fadeUp .4s ease both;
}
.main-content > *:nth-child(2) { animation-delay: .06s; }
.main-content > *:nth-child(3) { animation-delay: .12s; }
.main-content > *:nth-child(4) { animation-delay: .18s; }

/* ================================================================
   SIDEBAR
   ================================================================ */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--navy) 0%, #0c1222 100%);
  color: #fff;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  border-right: 1px solid rgba(255,255,255,.04);
}

/* ── Brand ── */
.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem 1rem;
  margin: .75rem;
  background: linear-gradient(135deg, rgba(255,255,255,.08) 0%, rgba(255,255,255,.03) 100%);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  position: relative;
  overflow: hidden;
}
.sidebar-brand::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 30% 0%, rgba(45,212,191,.1) 0%, transparent 70%);
  pointer-events: none;
}
.sidebar-logo {
  width: 170px;
  height: auto;
  object-fit: contain;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,.3));
}

/* ── Navigation ── */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: .75rem 0;
}
.sidebar-nav .nav-section {
  padding: .75rem 1.5rem .4rem;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: rgba(255,255,255,.28);
  margin-top: .25rem;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem 1.5rem;
  margin: 1px .5rem;
  color: rgba(255,255,255,.55);
  text-decoration: none;
  font-size: .8375rem;
  font-weight: 500;
  border-radius: var(--r-sm);
  transition: all .2s ease;
  position: relative;
}
.sidebar-nav a:hover {
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.9);
}
.sidebar-nav a.active {
  background: linear-gradient(135deg, rgba(13,148,136,.2), rgba(13,148,136,.08));
  color: var(--accent-light);
  font-weight: 600;
}
.sidebar-nav a.active::before {
  content: '';
  position: absolute;
  left: -0.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent-light);
  border-radius: 0 4px 4px 0;
  box-shadow: 0 0 12px rgba(45,212,191,.4);
}
.sidebar-nav a .bi {
  font-size: 1.1rem;
  width: 1.25rem;
  text-align: center;
  opacity: .8;
}
.sidebar-nav a.active .bi { opacity: 1; }

/* ── User card ── */
.sidebar-user {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  gap: .75rem;
}
.sidebar-user .avatar {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .75rem;
  letter-spacing: .02em;
  box-shadow: 0 2px 8px rgba(13,148,136,.25);
}
.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name {
  font-weight: 600;
  font-size: .8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: rgba(255,255,255,.85);
}
.sidebar-user .user-role {
  font-size: .675rem;
  color: rgba(255,255,255,.35);
  text-transform: capitalize;
  font-weight: 500;
}

/* ================================================================
   TOP BAR
   ================================================================ */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: 64px;
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(1.5);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  border-bottom: 1px solid rgba(0,0,0,.05);
  display: flex;
  align-items: center;
  padding: 0 2rem;
  z-index: 1030;
  gap: 1rem;
}
.topbar-toggle {
  display: none;
  background: none;
  border: 1px solid var(--g200);
  border-radius: var(--r-xs);
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--g600);
  padding: .35rem .5rem;
  transition: all .15s;
}
.topbar-toggle:hover { background: var(--g100); }
.topbar .page-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--g800);
}
.topbar .spacer { flex: 1; }
.topbar .topbar-actions { display: flex; align-items: center; gap: .5rem; }
.topbar .btn-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  border: 1px solid var(--g200);
  background: #fff;
  color: var(--g500);
  font-size: 1rem;
  cursor: pointer;
  transition: all .2s;
}
.topbar .btn-icon:hover {
  background: var(--g50);
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ================================================================
   MAIN CONTENT
   ================================================================ */
.main-content {
  margin-left: var(--sidebar-w);
  margin-top: 64px;
  padding: 2rem;
  min-height: calc(100vh - 64px);
}

/* ================================================================
   STAT CARDS
   ================================================================ */
.stat-card {
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--r);
  padding: 1.35rem 1.5rem;
  box-shadow: var(--glass-shadow);
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  transition: all .25s cubic-bezier(.4,0,.2,1);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent-light), transparent);
  opacity: 0;
  transition: opacity .3s;
}
.stat-card:hover {
  box-shadow: var(--glass-hover);
  transform: translateY(-3px);
}
.stat-card:hover::before { opacity: 1; }

.stat-icon {
  width: 50px; height: 50px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.stat-icon.primary { background: var(--accent-glow); color: var(--accent); }
.stat-icon.success { background: var(--success-bg); color: var(--success); }
.stat-icon.warning { background: var(--warning-bg); color: var(--warning); }
.stat-icon.danger  { background: var(--danger-bg); color: var(--danger); animation: pulse-glow 2.5s infinite; }
.stat-icon.info    { background: var(--info-bg); color: var(--info); }

.stat-body .stat-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.15;
  color: var(--g900);
  letter-spacing: -.03em;
  font-family: 'DM Sans', sans-serif;
}
.stat-body .stat-label {
  font-size: .8rem;
  color: var(--g500);
  font-weight: 500;
  margin-top: .1rem;
}

/* ================================================================
   CARDS & PANELS
   ================================================================ */
.card {
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--r);
  box-shadow: var(--glass-shadow);
  transition: box-shadow .2s;
}
.card:hover { box-shadow: var(--glass-hover); }
.card-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(0,0,0,.04);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
}
.card-header h5, .card-header h6 {
  margin: 0;
  font-weight: 700;
  font-size: .9rem;
  color: var(--g800);
  display: flex;
  align-items: center;
}
.card-header h6 .bi { color: var(--accent); }
.card-body { padding: 1.25rem 1.5rem; }

/* ================================================================
   TABLES
   ================================================================ */
.table-clean {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: .85rem;
}
.table-clean thead th {
  background: rgba(0,0,0,.015);
  color: var(--g500);
  font-weight: 600;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: .8rem 1rem;
  border-bottom: 1px solid rgba(0,0,0,.06);
  white-space: nowrap;
}
.table-clean tbody td {
  padding: .75rem 1rem;
  border-bottom: 1px solid rgba(0,0,0,.03);
  color: var(--g700);
  vertical-align: middle;
}
.table-clean tbody tr { transition: all .15s; }
.table-clean tbody tr:hover {
  background: rgba(13,148,136,.03);
}
.table-clean tbody tr:last-child td { border-bottom: none; }

/* ================================================================
   BADGES
   ================================================================ */
.badge-status {
  display: inline-flex;
  align-items: center;
  padding: .25rem .7rem;
  border-radius: var(--r-xs);
  font-size: .7rem;
  font-weight: 600;
  text-transform: capitalize;
  letter-spacing: .01em;
}
.badge-status.new, .badge-status.open, .badge-status.pending, .badge-status.submitted
  { background: var(--info-bg); color: var(--info); }
.badge-status.in_progress, .badge-status.in_analysis
  { background: var(--warning-bg); color: var(--warning); }
.badge-status.under_review { background: rgba(245,158,11,.08); color: #b45309; }
.badge-status.completed, .badge-status.approved, .badge-status.verified
  { background: var(--success-bg); color: var(--success); }
.badge-status.closed   { background: rgba(0,0,0,.04); color: var(--g500); }
.badge-status.overdue, .badge-status.cancelled
  { background: var(--danger-bg); color: var(--danger); }
.badge-status.critical  { background: var(--danger-bg); color: var(--danger); font-weight: 700; }
.badge-status.high      { background: rgba(239,68,68,.08); color: #dc2626; }
.badge-status.medium    { background: var(--warning-bg); color: var(--warning); }
.badge-status.low       { background: var(--success-bg); color: var(--success); }
.badge-status.urgent    { background: var(--danger-bg); color: var(--danger); }
.badge-status.positive  { background: var(--success-bg); color: var(--success); }
.badge-status.negative  { background: var(--danger-bg); color: var(--danger); }
.badge-status.neutral   { background: rgba(0,0,0,.04); color: var(--g500); }
.badge-status.flagged   { background: var(--warning-bg); color: var(--warning); }
.badge-status.spam      { background: rgba(0,0,0,.04); color: var(--g400); text-decoration: line-through; }

/* ================================================================
   FORMS
   ================================================================ */
.form-card {
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--r);
  box-shadow: var(--glass-shadow);
  border: 1px solid var(--glass-border);
  padding: 2.25rem;
  max-width: 640px;
  margin: 0 auto;
}
.form-card label {
  display: block;
  font-weight: 600;
  font-size: .8rem;
  color: var(--g600);
  margin-bottom: .4rem;
}
.form-card .form-control,
.form-card .form-select {
  border-radius: var(--r-sm);
  border: 1px solid var(--g300);
  padding: .6rem .9rem;
  font-size: .875rem;
  font-family: 'DM Sans', sans-serif;
  background: rgba(255,255,255,.7);
  transition: all .2s;
}
.form-card .form-control:focus,
.form-card .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: #fff;
}
.form-card textarea.form-control { min-height: 110px; resize: vertical; }

/* ================================================================
   BUTTONS
   ================================================================ */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep)) !important;
  border: none !important;
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: .875rem;
  padding: .6rem 1.75rem;
  font-family: 'DM Sans', sans-serif;
  transition: all .25s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 2px 8px rgba(13,148,136,.2);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(13,148,136,.3) !important;
  background: linear-gradient(135deg, var(--accent-light), var(--accent)) !important;
}
.btn-outline-secondary {
  border-radius: var(--r-xs);
  font-weight: 500;
  font-size: .8rem;
  border-color: var(--g300);
  color: var(--g600);
  transition: all .2s;
}
.btn-outline-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}
.btn-outline-danger {
  border-radius: var(--r-xs);
}

/* ================================================================
   LOGIN PAGE
   ================================================================ */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  background-image:
    radial-gradient(ellipse at 30% 20%, rgba(13,148,136,.15) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(59,130,246,.1) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(255,255,255,.02) 0%, transparent 70%);
  padding: 1rem;
  position: relative;
  overflow: hidden;
}
.login-wrapper::before {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  top: -150px; right: -150px;
  background: radial-gradient(circle, rgba(13,148,136,.08), transparent 70%);
  border-radius: 50%;
  animation: float 8s ease-in-out infinite;
}
.login-wrapper::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  bottom: -100px; left: -100px;
  background: radial-gradient(circle, rgba(59,130,246,.06), transparent 70%);
  border-radius: 50%;
  animation: float 10s ease-in-out infinite reverse;
}
@keyframes float {
  0%, 100% { transform: translate(0, 0); }
  50%      { transform: translate(20px, -20px); }
}
.login-card {
  background: rgba(255,255,255,.06);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 32px 64px rgba(0,0,0,.3);
  padding: 2.75rem;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
  animation: fadeUp .6s ease;
}
.login-logo {
  width: 90px;
  height: 90px;
  object-fit: contain;
  background: #fff;
  border-radius: 20px;
  padding: 10px;
  margin-bottom: 1rem;
  box-shadow: 0 8px 32px rgba(0,0,0,.2), 0 0 40px rgba(45,212,191,.15);
}
.login-card .brand { text-align: center; margin-bottom: 2rem; }
.login-card .brand h2 {
  font-weight: 800;
  font-size: 1.75rem;
  color: #fff;
  margin-bottom: .3rem;
  letter-spacing: -.03em;
}
.login-card .brand p { color: rgba(255,255,255,.45); font-size: .875rem; }
.login-card label { color: rgba(255,255,255,.6) !important; }
.login-card .form-control {
  background: rgba(255,255,255,.07) !important;
  border: 1px solid rgba(255,255,255,.12) !important;
  color: #fff !important;
  border-radius: var(--r-sm) !important;
}
.login-card .form-control::placeholder { color: rgba(255,255,255,.25); }
.login-card .form-control:focus {
  background: rgba(255,255,255,.1) !important;
  border-color: var(--accent-light) !important;
  box-shadow: 0 0 0 3px rgba(45,212,191,.15) !important;
}
.login-card .input-group-text {
  background: rgba(255,255,255,.05) !important;
  border: 1px solid rgba(255,255,255,.12) !important;
  border-right: none !important;
  color: rgba(255,255,255,.3) !important;
}
.login-card .input-group .form-control {
  border-left: none !important;
}
.login-card .btn-primary {
  box-shadow: 0 4px 16px rgba(13,148,136,.3);
}
.login-card .alert-danger {
  background: rgba(239,68,68,.12) !important;
  border: 1px solid rgba(239,68,68,.2) !important;
  color: #fca5a5 !important;
  border-radius: var(--r-sm) !important;
}
.login-card .text-muted { color: rgba(255,255,255,.25) !important; }

/* ================================================================
   DETAIL PAGES
   ================================================================ */
.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: .75rem;
}
.detail-header h4 {
  margin: 0;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--g900);
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
}
.detail-field label {
  display: block;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--g400);
  margin-bottom: .3rem;
}
.detail-field .value {
  font-size: .9375rem;
  color: var(--g800);
  word-break: break-word;
  font-weight: 500;
}

/* ================================================================
   MISC
   ================================================================ */
.stars { color: var(--warning); font-size: .85rem; }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--g400);
}
.empty-state .bi {
  font-size: 2.5rem;
  margin-bottom: .5rem;
  opacity: .4;
}
.empty-state p { margin: 0; font-size: .875rem; }

/* Back links */
a.text-muted {
  font-size: .8125rem;
  transition: color .15s;
}
a.text-muted:hover { color: var(--accent) !important; }

/* Alert overrides */
.alert { border-radius: var(--r-sm); border: none; }
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-danger { background: var(--danger-bg); color: var(--danger); }

/* Form controls outside form-card */
.form-select, .form-control {
  font-family: 'DM Sans', sans-serif;
}
.form-select-sm {
  border-radius: var(--r-xs);
  font-size: .8125rem;
  border-color: var(--g300);
}
.form-select-sm:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Pagination */
.pagination .page-link {
  border-radius: var(--r-xs);
  font-size: .8rem;
  margin: 0 2px;
  border: 1px solid var(--g200);
  color: var(--g600);
}
.pagination .page-item.active .page-link {
  background: var(--accent);
  border-color: var(--accent);
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 992px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .topbar { left: 0; }
  .topbar-toggle { display: flex; }
  .main-content { margin-left: 0; }
}
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(4px);
  z-index: 1035;
}
.sidebar-overlay.show { display: block; }
