/* ============================================================
   Cabinet Médical – Feuille de style principale
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --sidebar-width: 260px;
  --sidebar-collapsed: 68px;
  --topbar-height: 58px;
  --primary: #0d6efd;
  --primary-dark: #0a58ca;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-hover: #1e293b;
  --sidebar-active: #0d6efd;
  --card-radius: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1);
}

/* ── Reset & base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f1f5f9;
  color: #334155;
  margin: 0;
  overflow-x: hidden;
}

/* ── SIDEBAR ─────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  overflow-y: auto;
  overflow-x: hidden;
  transition: width .25s ease;
  z-index: 1000;
  scrollbar-width: thin;
  scrollbar-color: #1e293b transparent;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .sidebar-brand span,
.sidebar.collapsed .sidebar-link span,
.sidebar.collapsed .sidebar-category { display: none; }
.sidebar.collapsed .sidebar-link { justify-content: center; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}
.sidebar-brand i { font-size: 1.4rem; flex-shrink: 0; }

.sidebar-divider {
  border-color: #1e293b;
  margin: 6px 16px;
}
.sidebar-category {
  padding: 8px 20px 4px;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #475569;
  font-weight: 600;
}
.sidebar-nav { list-style: none; padding: 0; margin: 0; }
.sidebar-item { margin: 2px 8px; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  transition: all .15s;
  white-space: nowrap;
}
.sidebar-link i { font-size: 1.1rem; flex-shrink: 0; min-width: 20px; text-align: center; }
.sidebar-link:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.sidebar-link.active { background: var(--sidebar-active); color: #fff; box-shadow: 0 4px 12px rgba(13,110,253,.35); }

/* ── TOPBAR ──────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 900;
  transition: left .25s ease;
  box-shadow: var(--shadow-sm);
}
.sidebar.collapsed ~ .main-wrapper .topbar { left: var(--sidebar-collapsed); }
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 8px; }

/* ── MAIN WRAPPER & PAGE CONTENT ────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-width);
  transition: margin-left .25s ease;
  min-height: 100vh;
}
.sidebar.collapsed ~ .main-wrapper { margin-left: var(--sidebar-collapsed); }
.page-content {
  padding: calc(var(--topbar-height) + 24px) 24px 24px;
  max-width: 1400px;
}

/* ── USER MENU ───────────────────────────────────────────────── */
.user-menu-btn {
  display: flex;
  align-items: center;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 4px 10px;
  color: #334155;
  font-size: .875rem;
}
.user-menu-btn:hover { background: #f1f5f9; }

.user-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, #0d6efd, #0891b2);
  color: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .75rem;
  flex-shrink: 0;
}

/* ── NOTIFICATIONS ───────────────────────────────────────────── */
.notif-dropdown { width: 340px; max-height: 440px; overflow-y: auto; }
.notif-badge { font-size: .6rem; }
.notif-item {
  display: flex;
  gap: 10px;
  padding: 10px 16px;
  align-items: flex-start;
  border-bottom: 1px solid #f1f5f9;
  white-space: normal;
}
.notif-item.unread { background: #eff6ff; }
.notif-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 2px; }
.notif-info    { color: #0d6efd; }
.notif-succes  { color: #198754; }
.notif-avertissement { color: #f59e0b; }
.notif-erreur  { color: #dc3545; }
.notif-content { font-size: .825rem; }

/* ── CARDS ───────────────────────────────────────────────────── */
.card {
  border: 1px solid #e2e8f0;
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 16px 20px;
  border-radius: var(--card-radius) var(--card-radius) 0 0 !important;
  font-weight: 600;
}

/* ── STAT CARDS ──────────────────────────────────────────────── */
.stat-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: var(--card-radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s;
}
.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: 1.4rem;
  flex-shrink: 0;
}
.stat-label { font-size: .8rem; color: #64748b; margin-bottom: 2px; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; color: #0f172a; }
.stat-change { font-size: .78rem; }

/* ── TABLES ──────────────────────────────────────────────────── */
.table { font-size: .875rem; }
.table thead th {
  background: #f8fafc;
  color: #64748b;
  font-weight: 600;
  text-transform: uppercase;
  font-size: .73rem;
  letter-spacing: .05em;
  border-bottom: 2px solid #e2e8f0;
  padding: 12px 16px;
}
.table td { padding: 12px 16px; vertical-align: middle; }
.table tbody tr:hover { background: #f8fafc; }

/* ── FORMS ───────────────────────────────────────────────────── */
.form-label { font-weight: 500; font-size: .875rem; color: #475569; }
.form-control, .form-select {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: .875rem;
  padding: .5rem .75rem;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
  border-color: #0d6efd;
  box-shadow: 0 0 0 3px rgba(13,110,253,.12);
}

/* ── BUTTONS ─────────────────────────────────────────────────── */
.btn { border-radius: 8px; font-size: .875rem; font-weight: 500; }
.btn-sm { border-radius: 6px; }
.btn-action { padding: .25rem .5rem; }

/* ── PAGE HEADER ─────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title { font-size: 1.4rem; font-weight: 700; color: #0f172a; margin: 0; }
.page-subtitle { font-size: .85rem; color: #64748b; margin: 4px 0 0; }

/* ── FILE D'ATTENTE ──────────────────────────────────────────── */
.queue-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: var(--card-radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all .2s;
}
.queue-card.active-patient {
  border-color: #0d6efd;
  background: #eff6ff;
  box-shadow: 0 0 0 2px rgba(13,110,253,.15);
}
.queue-position {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: #64748b;
  flex-shrink: 0;
}
.queue-position.current { background: #0d6efd; color: #fff; }

/* ── PATIENT DOSSIER ─────────────────────────────────────────── */
.dossier-section {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: var(--card-radius);
  margin-bottom: 20px;
}
.dossier-section-header {
  padding: 14px 20px;
  border-bottom: 1px solid #e2e8f0;
  font-weight: 600;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 8px;
}
.dossier-section-body { padding: 20px; }

/* ── BADGES ──────────────────────────────────────────────────── */
.badge { font-size: .75rem; font-weight: 500; padding: .35em .65em; border-radius: 6px; }

/* ── CALENDAR ────────────────────────────────────────────────── */
.fc { font-size: .85rem; }
.fc .fc-button { border-radius: 6px !important; }
.fc .fc-button-primary { background: #0d6efd !important; border-color: #0d6efd !important; }
.fc .fc-today-button:not(:disabled) { background: #0891b2 !important; border-color: #0891b2 !important; }
.fc .fc-daygrid-day.fc-day-today { background: #eff6ff !important; }
.fc-event { border-radius: 4px !important; font-size: .78rem !important; }

/* ── UPLOAD ZONE ─────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: #f8fafc;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: #0d6efd;
  background: #eff6ff;
}

/* ── LOGIN PAGE ──────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: 20px;
  padding: 48px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 50px rgba(0,0,0,.25);
}
.login-logo {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, #0d6efd, #0891b2);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: #fff;
  margin: 0 auto 20px;
}

/* ── TV DISPLAY ──────────────────────────────────────────────── */
.tv-screen {
  min-height: 100vh;
  background: #0f172a;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
}
.tv-current-name {
  font-size: 5vw;
  font-weight: 800;
  color: #38bdf8;
  line-height: 1.1;
  text-shadow: 0 0 40px rgba(56,189,248,.3);
}
.tv-waiting-list { margin-top: 40px; opacity: .7; }
.tv-waiting-item { font-size: 1.5vw; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,.1); }

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 0; }
  .sidebar.mobile-open { width: var(--sidebar-width); }
  .main-wrapper { margin-left: 0; }
  .topbar { left: 0; }
  .page-content { padding: calc(var(--topbar-height) + 16px) 16px 16px; }
  .login-card { padding: 32px 24px; }
}

/* ── ANIMATIONS ───────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn .3s ease forwards; }

.pulse-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #22c55e;
  animation: pulse 1.5s infinite;
  display: inline-block;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34,197,94,.4); }
  50% { box-shadow: 0 0 0 6px rgba(34,197,94,0); }
}

/* ── SCROLLBAR ────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── UTILITIES ────────────────────────────────────────────────── */
.text-xs { font-size: .75rem; }
.text-sm { font-size: .875rem; }
.fw-600 { font-weight: 600; }
.rounded-xl { border-radius: 12px !important; }
.border-start-4 { border-left-width: 4px !important; }
.cursor-pointer { cursor: pointer; }

.bg-gradient-primary { background: linear-gradient(135deg, #0d6efd, #0891b2); }
.bg-gradient-success { background: linear-gradient(135deg, #198754, #16a34a); }
.bg-gradient-warning { background: linear-gradient(135deg, #f59e0b, #d97706); }
.bg-gradient-danger  { background: linear-gradient(135deg, #dc3545, #b91c1c); }
.bg-gradient-info    { background: linear-gradient(135deg, #0891b2, #0284c7); }

/* ── Améliorations complémentaires v2 ──────────────────────── */

/* Stat card link sans décoration */
a .stat-card { color: inherit; }
a:hover .stat-card { transform: translateY(-3px); box-shadow: var(--shadow-md); }

/* Sidebar search link actif */
.sidebar-link.active { background: var(--sidebar-active) !important; }

/* Charts */
#activityChart { max-height: 220px; }
#statutsChart { max-width: 200px; max-height: 200px; }

/* Page de recherche */
.search-result-row:hover { background: #f8fafc; }

/* Consultation edit sticky panel */
@media (max-width: 992px) {
  [style*="position:sticky"] { position: relative !important; top: auto !important; }
}

/* Badges actions */
.btn-action { min-width: 32px; }

/* File d'attente – animation entrée patient */
.queue-card { animation: slideIn .3s ease; }
@keyframes slideIn {
  from { opacity:0; transform:translateX(-10px); }
  to   { opacity:1; transform:translateX(0); }
}

/* Dossier patient – onglets */
.nav-tabs .nav-link { font-size: .85rem; padding: .5rem .9rem; }
.nav-tabs .badge { font-size: .65rem; }

/* Impression (masquer éléments non imprimables) */
@media print {
  .sidebar, .topbar, .page-header .btn, .btn-group, 
  .alert-dismissible .btn-close, .no-print { display: none !important; }
  .main-wrapper { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #dee2e6 !important; }
}

/* Barre de progression dans les stats */
.mini-progress {
  height: 4px;
  background: #e2e8f0;
  border-radius: 2px;
  overflow: hidden;
  margin-top: 6px;
}
.mini-progress-bar {
  height: 100%;
  border-radius: 2px;
  transition: width .6s ease;
}

/* Loader overlay */
.page-loader {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.page-loader.active { opacity: 1; pointer-events: all; }

/* Notification toast */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 1100; }

/* IMC color classes */
.imc-normal  { color: #16a34a; }
.imc-surpoids { color: #f59e0b; }
.imc-obese   { color: #dc3545; }
.imc-maigre  { color: #f59e0b; }
