/* =====================================================
   Hôpital Général de la Paix - Main Stylesheet v3.0
   Full Bug Fix + UI Improvements
   ===================================================== */

:root {
  --primary: #0066cc;
  --primary-dark: #004d99;
  --primary-light: #e8f0fe;
  --secondary: #00a86b;
  --secondary-dark: #007a4d;
  --secondary-light: #e8f8f2;
  --danger: #dc3545;
  --warning: #ffc107;
  --info: #0dcaf0;
  --sidebar-width: 260px;
  --header-height: 64px;
  --bg: #f0f4f8;
  --card-bg: #ffffff;
  --text-primary: #1a2332;
  --text-secondary: #6b7a8d;
  --border: #e2e8f0;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.14);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: all 0.25s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

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

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4, h5 { font-weight: 600; letter-spacing: -0.02em; }

/* ===== VIEWS ===== */
.view { display: none; min-height: 100vh; }
.view.active { display: block; }

/* ===== LOGIN PAGE ===== */
#login-view {
  background: linear-gradient(135deg, #0066cc 0%, #004080 50%, #00a86b 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.login-bg-shapes { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.login-shape {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
}
.login-shape.s1 { width: 500px; height: 500px; top: -150px; right: -100px; }
.login-shape.s2 { width: 350px; height: 350px; bottom: -100px; left: -80px; }
.login-shape.s3 { width: 200px; height: 200px; top: 40%; left: 10%; background: rgba(255,255,255,0.04); }

.login-card {
  background: rgba(255,255,255,0.98);
  backdrop-filter: blur(20px);
  border-radius: 24px;
  padding: 48px 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.3);
  position: relative;
  z-index: 10;
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .logo-icon {
  width: 72px; height: 72px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: white;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(0,102,204,0.35);
}
.login-logo h1 { font-size: 20px; color: var(--text-primary); margin-bottom: 4px; }
.login-logo p { color: var(--text-secondary); font-size: 13px; }
.form-control {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 15px;
  transition: var(--transition);
  width: 100%;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(0,102,204,0.12);
  outline: none;
}
.btn-login {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 32px;
  font-weight: 600;
  font-size: 16px;
  width: 100%;
  transition: var(--transition);
  letter-spacing: 0.02em;
  cursor: pointer;
}
.btn-login:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,102,204,0.4); }
.btn-login:disabled { opacity: 0.7; transform: none; cursor: not-allowed; }
.quick-login-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.quick-btn {
  flex: 1;
  min-width: 90px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.quick-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.quick-btn.admin { background: #e8f0fe; color: var(--primary); border-color: rgba(0,102,204,0.2); }
.quick-btn.medecin { background: var(--secondary-light); color: var(--secondary); border-color: rgba(0,168,107,0.2); }
.quick-btn.secretaire { background: #fff3e0; color: #e65100; border-color: rgba(230,81,0,0.2); }

/* ===== MAIN APP LAYOUT ===== */
#app-view {
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(160deg, #0a1628 0%, #1a2d4d 100%);
  min-height: 100vh;
  position: fixed;
  left: 0; top: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  overflow: hidden;
}
.sidebar-brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.brand-icon {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0,102,204,0.4);
}
.brand-text { overflow: hidden; }
.brand-text h2 { color: white; font-size: 13px; font-weight: 700; line-height: 1.2; }
.brand-text p { color: rgba(255,255,255,0.4); font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; }

.sidebar-nav { padding: 10px 10px; flex: 1; overflow-y: auto; }
.nav-section { margin-bottom: 6px; }
.nav-section-label {
  color: rgba(255,255,255,0.28);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 8px 12px 4px;
  font-weight: 700;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 13px;
  border-radius: 10px;
  color: rgba(255,255,255,0.58);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 2px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  position: relative;
  user-select: none;
}
.nav-item:hover {
  background: rgba(255,255,255,0.09);
  color: rgba(255,255,255,0.9);
}
.nav-item.active {
  background: linear-gradient(135deg, rgba(0,102,204,0.85), rgba(0,168,107,0.5));
  color: white;
  box-shadow: 0 4px 12px rgba(0,102,204,0.3);
}
.nav-item .nav-icon { width: 20px; text-align: center; font-size: 15px; flex-shrink: 0; }
.nav-item .nav-label { flex: 1; }
.nav-badge {
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

/* ===== SIDEBAR FOOTER ===== */
.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 8px;
}
.sidebar-user-info:hover { background: rgba(255,255,255,0.1); }

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.avatar-admin { background: linear-gradient(135deg, #7c3aed, #4f46e5); color: white; }
.avatar-medecin { background: linear-gradient(135deg, var(--secondary), #059669); color: white; }
.avatar-secretaire { background: linear-gradient(135deg, #f59e0b, #d97706); color: white; }

.sidebar-user-text { flex: 1; overflow: hidden; }
.sidebar-user-text .u-name { color: white; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-text .u-role { color: rgba(255,255,255,0.4); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.online-dot { width: 8px; height: 8px; background: var(--secondary); border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 6px var(--secondary); animation: pulse-dot 2s ease infinite; }
.online-dot-small { display: inline-block; width: 7px; height: 7px; background: var(--secondary); border-radius: 50%; margin-right: 5px; box-shadow: 0 0 4px var(--secondary); }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ===== LOGOUT BUTTON - Always visible, always works ===== */
.logout-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(220,53,69,0.12);
  border: 1.5px solid rgba(220,53,69,0.25);
  color: #ff8a9a;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  justify-content: center;
  letter-spacing: 0.02em;
}
.logout-btn:hover {
  background: rgba(220,53,69,0.25);
  border-color: rgba(220,53,69,0.5);
  color: #ffb3bd;
  transform: translateY(-1px);
}
.logout-btn:active { transform: translateY(0); }

/* ===== TOPBAR LOGOUT BUTTON ===== */
.topbar-logout {
  border-color: rgba(220,53,69,0.3) !important;
  color: var(--danger) !important;
}
.topbar-logout:hover {
  background: var(--danger) !important;
  border-color: var(--danger) !important;
  color: white !important;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ===== TOPBAR ===== */
.topbar {
  background: var(--card-bg);
  height: var(--header-height);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}
.page-title { flex: 1; min-width: 0; }
.page-title h2 { font-size: 18px; font-weight: 700; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-title p { font-size: 12px; color: var(--text-secondary); margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.topbar-btn {
  width: 38px; height: 38px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition);
  position: relative;
  font-size: 15px;
  flex-shrink: 0;
}
.topbar-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.notif-badge {
  position: absolute;
  top: -5px; right: -5px;
  background: var(--danger);
  color: white;
  font-size: 9px;
  font-weight: 700;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}
.search-bar {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  gap: 8px;
  width: 220px;
  transition: var(--transition);
}
.search-bar:focus-within { border-color: var(--primary); background: white; }
.search-bar i { color: var(--text-secondary); font-size: 13px; flex-shrink: 0; }
.search-bar input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  color: var(--text-primary);
  width: 100%;
  min-width: 0;
}

/* ===== PAGE CONTENT ===== */
.page-content { padding: 24px; flex: 1; }

/* ===== WELCOME BANNER ===== */
.welcome-banner {
  background: linear-gradient(135deg, var(--primary), #004080, var(--secondary));
  border-radius: var(--radius);
  padding: 24px 28px;
  color: white;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  overflow: hidden;
  position: relative;
}
.welcome-content h3 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.welcome-content p { opacity: 0.8; font-size: 13px; }
.welcome-icon { font-size: 64px; opacity: 0.12; flex-shrink: 0; }

/* ===== STATS CARDS ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 18px; margin-bottom: 24px; }
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px 18px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
  transition: var(--transition);
  border: 1.5px solid transparent;
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 0 0 var(--radius) var(--radius);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-icon {
  width: 50px; height: 50px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-card.blue .stat-icon { background: var(--primary-light); color: var(--primary); }
.stat-card.blue::after { background: var(--primary); }
.stat-card.green .stat-icon { background: var(--secondary-light); color: var(--secondary); }
.stat-card.green::after { background: var(--secondary); }
.stat-card.orange .stat-icon { background: #fff3e0; color: #e65100; }
.stat-card.orange::after { background: #ff6d00; }
.stat-card.purple .stat-icon { background: #f3e8ff; color: #7c3aed; }
.stat-card.purple::after { background: #7c3aed; }
.stat-card.red .stat-icon { background: #fee2e2; color: var(--danger); }
.stat-card.red::after { background: var(--danger); }
.stat-card.teal .stat-icon { background: #e0f7fa; color: #00796b; }
.stat-card.teal::after { background: #00796b; }
.stat-info { flex: 1; min-width: 0; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--text-primary); line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; font-weight: 500; }
.stat-sub { font-size: 11px; color: var(--text-secondary); margin-top: 6px; opacity: 0.7; }

/* ===== CARDS ===== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1.5px solid transparent;
  overflow: hidden;
  transition: var(--transition);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.card-header h5 { font-size: 15px; font-weight: 700; color: var(--text-primary); margin: 0; }
.card-body { padding: 20px; }

/* ===== TABLES ===== */
.table-card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.table-toolbar {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.table-toolbar h5 { font-size: 15px; font-weight: 700; margin: 0; }
.table-search {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  gap: 8px;
  min-width: 200px;
  transition: var(--transition);
}
.table-search:focus-within { border-color: var(--primary); background: white; }
.table-search i { color: var(--text-secondary); flex-shrink: 0; }
.table-search input {
  border: none; background: transparent; outline: none;
  font-size: 14px; color: var(--text-primary); width: 100%;
}
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th {
  background: #f8fafc;
  padding: 11px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tbody tr {
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.15s ease;
}
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table td {
  padding: 13px 14px;
  font-size: 14px;
  color: var(--text-primary);
  vertical-align: middle;
}
.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-secondary);
}
.empty-state i { font-size: 44px; margin-bottom: 14px; opacity: 0.25; display: block; }
.empty-state p { font-size: 15px; }

/* ===== COUNT BADGES ===== */
.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  min-width: 24px;
  margin-left: 6px;
}
.count-badge-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  min-width: 22px;
}

/* ===== PATIENT CARD ===== */
.patient-name { font-weight: 600; color: var(--text-primary); font-size: 14px; }
.patient-id { color: var(--text-secondary); font-size: 12px; }
.patient-avatar {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.pa-homme { background: #dbeafe; color: #1d4ed8; }
.pa-femme { background: #fce7f3; color: #be185d; }
.sexe-homme { color: #1d4ed8; font-size: 13px; }
.sexe-femme { color: #be185d; font-size: 13px; }

/* ===== BADGES ===== */
.badge-role {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge-admin { background: #ede9fe; color: #6d28d9; }
.badge-medecin { background: var(--secondary-light); color: #065f46; }
.badge-secretaire { background: #fef3c7; color: #92400e; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.status-online { background: var(--secondary-light); color: #065f46; }
.status-offline { background: #f1f5f9; color: var(--text-secondary); }

.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.status-online .status-dot { background: var(--secondary); }
.status-offline .status-dot { background: #94a3b8; }

.examen-status {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  display: inline-block;
}
.status-attente { background: #fef3c7; color: #92400e; }
.status-cours { background: #dbeafe; color: #1e40af; }
.status-termine { background: var(--secondary-light); color: #065f46; }
.status-annule { background: #fee2e2; color: #991b1b; }

.rdv-status { padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; display: inline-block; }
.rdv-planifie { background: #dbeafe; color: #1e40af; }
.rdv-confirme { background: var(--secondary-light); color: #065f46; }
.rdv-termine { background: #f1f5f9; color: var(--text-secondary); }
.rdv-annule { background: #fee2e2; color: #991b1b; }

.dossier-status { padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; display: inline-block; }
.dossier-actif { background: var(--secondary-light); color: #065f46; }
.dossier-archive { background: #fef3c7; color: #92400e; }
.dossier-ferme { background: #fee2e2; color: #991b1b; }

.blood-group {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 24px;
  background: #fee2e2;
  color: #991b1b;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  padding: 0 6px;
}

.badge-type {
  background: var(--primary-light);
  color: var(--primary);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  display: inline-block;
}

/* Action badges for historique */
.action-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.action-login { background: var(--secondary-light); color: #065f46; }
.action-logout { background: #fee2e2; color: #991b1b; }

/* ===== BUTTONS ===== */
.btn-primary-custom {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary-custom:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(0,102,204,0.35); }
.btn-primary-custom:disabled { opacity: 0.7; transform: none; cursor: not-allowed; }

.btn-secondary-custom {
  background: white;
  color: var(--text-primary);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-secondary-custom:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

.btn-danger-custom {
  background: #fee2e2;
  color: var(--danger);
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-danger-custom:hover { background: var(--danger); color: white; transform: translateY(-1px); }

.btn-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 13px;
}
.btn-icon-edit { background: var(--primary-light); color: var(--primary); }
.btn-icon-edit:hover { background: var(--primary); color: white; }
.btn-icon-delete { background: #fee2e2; color: var(--danger); }
.btn-icon-delete:hover { background: var(--danger); color: white; }
.btn-icon-view { background: var(--secondary-light); color: var(--secondary); }
.btn-icon-view:hover { background: var(--secondary); color: white; }
.btn-icon-add { background: #f3e8ff; color: #7c3aed; }
.btn-icon-add:hover { background: #7c3aed; color: white; }
.action-btns { display: flex; gap: 5px; align-items: center; }

/* ===== MODALS ===== */
.modal-content { border: none; border-radius: 16px; box-shadow: var(--shadow-lg); }
.modal-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-radius: 16px 16px 0 0;
  padding: 18px 22px;
  border-bottom: none;
}
.modal-header .btn-close { filter: brightness(10); }
.modal-title { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.modal-body { padding: 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); gap: 8px; }

/* ===== FORMS ===== */
.form-label { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 5px; display: block; }
.form-control, .form-select {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  transition: var(--transition);
  width: 100%;
  background-color: white;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,102,204,0.1);
  outline: none;
}
.form-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 16px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.col-12.form-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ===== DOSSIER DETAIL ===== */
.dossier-header {
  background: linear-gradient(135deg, var(--primary), #004080, var(--secondary));
  color: white;
  border-radius: var(--radius);
  padding: 26px;
  margin-bottom: 22px;
  position: relative;
  overflow: hidden;
}
.dossier-header::after {
  content: '';
  position: absolute;
  right: -40px; top: -40px;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  pointer-events: none;
}

.patient-card-detail {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.info-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.info-item {}
.info-label { font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; margin-bottom: 4px; }
.info-value { font-size: 14px; color: var(--text-primary); font-weight: 500; }

/* Inline alerts */
.alert-inline {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.alert-danger { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef3c7; color: #92400e; }

/* ===== CHARTS ===== */
.chart-container { position: relative; width: 100%; height: 220px; }

/* ===== ALERTS ===== */
.alert-custom {
  padding: 14px 18px;
  border-radius: 10px;
  border: none;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideDown 0.3s ease;
}
.alert-success { background: var(--secondary-light); color: #065f46; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef3c7; color: #92400e; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* ===== LOADING ===== */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast-notif {
  background: white;
  border-radius: 12px;
  padding: 14px 18px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  max-width: 380px;
  animation: slideInRight 0.3s ease;
  border-left: 4px solid var(--primary);
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: all;
}
.toast-notif.success { border-left-color: var(--secondary); }
.toast-notif.error { border-left-color: var(--danger); }
.toast-notif.warning { border-left-color: var(--warning); }
.toast-icon { font-size: 18px; flex-shrink: 0; }
.toast-notif.success .toast-icon { color: var(--secondary); }
.toast-notif.error .toast-icon { color: var(--danger); }
.toast-notif.warning .toast-icon { color: #d97706; }
.toast-notif .toast-icon { color: var(--primary); }
.toast-text { font-size: 14px; font-weight: 500; flex: 1; }
@keyframes slideInRight { from { opacity: 0; transform: translateX(100%); } to { opacity: 1; transform: translateX(0); } }

/* ===== PROFILE ===== */
.profile-header {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius);
  padding: 32px;
  color: white;
  text-align: center;
  margin-bottom: 22px;
}
.profile-avatar {
  width: 80px; height: 80px;
  border-radius: 20px;
  border: 4px solid rgba(255,255,255,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 800;
  margin: 0 auto 16px;
}

/* ===== CALENDAR / RDV ===== */
.rdv-item {
  padding: 12px 14px;
  border-radius: 10px;
  border-left: 4px solid var(--primary);
  background: var(--primary-light);
  margin-bottom: 10px;
  transition: var(--transition);
}
.rdv-item:hover { transform: translateX(4px); }
.rdv-time { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.rdv-patient { font-size: 14px; font-weight: 700; color: var(--text-primary); margin: 2px 0; }
.rdv-motif { font-size: 12px; color: var(--text-secondary); }

/* ===== RESPONSIVE / HAMBURGER ===== */
.hamburger {
  display: none;
  position: fixed;
  top: 13px; left: 13px;
  z-index: 1100;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 10px;
  width: 40px; height: 40px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,102,204,0.35);
  font-size: 16px;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 999;
  backdrop-filter: blur(2px);
}

@media (max-width: 768px) {
  .hamburger { display: flex; }
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .sidebar-overlay.active { display: block; }
  .main-content { margin-left: 0; }
  .topbar { padding: 0 14px 0 60px; }
  .page-content { padding: 14px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .info-grid { grid-template-columns: 1fr; }
  .search-bar { display: none; }
  .table-toolbar { flex-direction: column; align-items: stretch; }
  .welcome-banner { flex-direction: column; text-align: center; }
  .welcome-icon { display: none; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .login-card { padding: 32px 20px; }
  .quick-login-btns { flex-direction: column; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ===== MISC ===== */
.separator { height: 1px; background: var(--border); margin: 18px 0; }
.text-muted-sm { font-size: 12px; color: var(--text-secondary); }
.fw-600 { font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.mb-3 { margin-bottom: 12px !important; }
.mb-4 { margin-bottom: 18px !important; }
.mb-5 { margin-bottom: 24px !important; }
.mt-2 { margin-top: 8px !important; }
.mt-3 { margin-top: 12px !important; }
.mt-4 { margin-top: 18px !important; }
.ms-1 { margin-left: 4px !important; }
.ms-2 { margin-left: 8px !important; }
.me-1 { margin-right: 4px !important; }
.me-2 { margin-right: 8px !important; }

@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.page-fade-in { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.examen-table-result {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}
.result-normal { color: var(--secondary); }
.result-abnormal { color: var(--danger); }
.result-warning { color: #d97706; }

/* ===== PAGINATION ===== */
.pagination-custom {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px;
}
.page-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  transition: var(--transition);
}
.page-btn:hover, .page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ===== EXTRA UTILITIES ===== */
.p-0 { padding: 0 !important; }
