/* ================================================================
   SAMU AP-HP — Feuille de styles principale
   Palette : Bleu médical AP-HP, blanc, gris acier
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --blue-900: #001f5e;
  --blue-800: #002f8a;
  --blue-700: #0040b8;
  --blue-600: #005ce6;
  --blue-500: #1a74ff;
  --blue-400: #4d94ff;
  --blue-100: #e6f0ff;
  --blue-50:  #f0f5ff;

  --red-500:  #e03131;
  --red-100:  #ffe0e0;
  --orange-500:#e8830a;
  --green-600:#1d7a3e;
  --green-100:#d4f4e1;
  --yellow-500:#d4a017;

  --gray-900: #111827;
  --gray-700: #374151;
  --gray-500: #6b7280;
  --gray-300: #d1d5db;
  --gray-200: #e5e7eb;
  --gray-100: #f3f4f6;
  --gray-50:  #f9fafb;
  --white:    #ffffff;

  --sidebar-w: 260px;
  --header-h:  64px;
  --radius:    8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow:    0 4px 16px rgba(0,0,0,.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.14);

  --font-main: 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  --transition: 0.18s ease;
}

/* ── Reset & base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font-main);
  background: var(--gray-100);
  color: var(--gray-900);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--blue-600); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--blue-800); }

/* ── Layout principal ───────────────────────────────────────── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--blue-900);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .brand-logo {
  display: flex; align-items: center; gap: 12px;
  color: var(--white);
  font-weight: 700; font-size: 1rem;
}
.sidebar-brand .brand-logo img {
  width: 36px; height: 36px; object-fit: contain;
  filter: brightness(0) invert(1);
}
.sidebar-brand .brand-sub {
  font-size: .7rem; color: rgba(255,255,255,.5);
  margin-top: 4px; letter-spacing: .04em; text-transform: uppercase;
}

.sidebar-nav { padding: 12px 0; flex: 1; }

.sidebar-section-title {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(255,255,255,.35);
  padding: 16px 20px 6px;
  font-weight: 600;
}

.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,.72);
  font-size: .875rem;
  border-left: 3px solid transparent;
  transition: all var(--transition);
}
.sidebar-nav a i {
  width: 18px; text-align: center; font-size: .95rem;
  opacity: .8;
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
  color: var(--white);
  background: rgba(255,255,255,.07);
  border-left-color: var(--blue-400);
}
.sidebar-nav a.active { background: rgba(26,116,255,.18); }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-footer .user-info {
  display: flex; align-items: center; gap: 10px;
}
.sidebar-footer .user-avatar {
  width: 34px; height: 34px;
  background: var(--blue-600);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: .85rem; font-weight: 600;
  flex-shrink: 0;
}
.sidebar-footer .user-name { font-size: .8rem; color: rgba(255,255,255,.85); font-weight: 500; }
.sidebar-footer .user-role { font-size: .7rem; color: rgba(255,255,255,.45); }

/* ── Main content ───────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ── Header ─────────────────────────────────────────────────── */
.topbar {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
  gap: 16px;
}
.topbar-title { font-size: 1.05rem; font-weight: 600; color: var(--gray-900); flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }

.btn-icon {
  width: 36px; height: 36px;
  border: none; background: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  cursor: pointer; color: var(--gray-500);
  transition: all var(--transition);
  position: relative;
}
.btn-icon:hover { background: var(--gray-100); color: var(--blue-600); }
.badge-notif {
  position: absolute; top: 3px; right: 3px;
  width: 8px; height: 8px;
  background: var(--red-500);
  border-radius: 50%;
  border: 2px solid white;
}

/* ── Page content ───────────────────────────────────────────── */
.page-content {
  padding: 28px 28px;
  flex: 1;
}
.page-header {
  margin-bottom: 24px;
}
.page-header h1 {
  font-size: 1.4rem; font-weight: 700; color: var(--gray-900);
}
.page-header p { color: var(--gray-500); font-size: .9rem; margin-top: 4px; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
}
.card-header h5 {
  font-size: .95rem; font-weight: 600; color: var(--gray-900);
  display: flex; align-items: center; gap: 8px;
}
.card-header h5 i { color: var(--blue-600); }
.card-body { padding: 20px; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
}

/* ── Stat cards ─────────────────────────────────────────────── */
.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  padding: 20px;
  display: flex; align-items: flex-start; justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-card .stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
}
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label { font-size: .8rem; color: var(--gray-500); margin-top: 4px; }
.stat-card .stat-change { font-size: .78rem; margin-top: 6px; }
.stat-card .stat-change.up { color: var(--green-600); }
.stat-card .stat-change.down { color: var(--red-500); }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: .875rem; font-weight: 500;
  cursor: pointer; border: 1.5px solid transparent;
  transition: all var(--transition);
  font-family: var(--font-main);
  line-height: 1.4;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--blue-600); color: white;
  border-color: var(--blue-600);
}
.btn-primary:hover { background: var(--blue-800); border-color: var(--blue-800); color: white; }

.btn-outline {
  background: transparent; color: var(--blue-600);
  border-color: var(--blue-600);
}
.btn-outline:hover { background: var(--blue-50); }

.btn-danger {
  background: var(--red-500); color: white;
  border-color: var(--red-500);
}
.btn-danger:hover { background: #b91c1c; }

.btn-success {
  background: var(--green-600); color: white;
  border-color: var(--green-600);
}

.btn-sm { padding: 5px 11px; font-size: .8rem; }
.btn-lg { padding: 11px 22px; font-size: 1rem; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-label {
  font-size: .82rem; font-weight: 500;
  color: var(--gray-700); margin-bottom: 5px; display: block;
}
.form-label .required { color: var(--red-500); margin-left: 2px; }

.form-control, .form-select {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: .875rem; font-family: var(--font-main);
  color: var(--gray-900);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus, .form-select:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(26,116,255,.12);
}
.form-control:read-only { background: var(--gray-50); color: var(--gray-500); }
textarea.form-control { resize: vertical; min-height: 90px; }

.form-group { margin-bottom: 16px; }
.form-row { display: grid; gap: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 16px;
}
.alert-danger  { background: var(--red-100);  color: #7f1d1d; border: 1px solid #fecaca; }
.alert-success { background: var(--green-100); color: #14532d; border: 1px solid #bbf7d0; }
.alert-warning { background: #fef3c7; color: #78350f; border: 1px solid #fde68a; }
.alert-info    { background: var(--blue-100); color: var(--blue-900); border: 1px solid #bfdbfe; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: .72rem; font-weight: 600;
  letter-spacing: .02em;
}
.badge-primary { background: var(--blue-100); color: var(--blue-800); }
.badge-danger  { background: var(--red-100);  color: var(--red-500); }
.badge-success { background: var(--green-100); color: var(--green-600); }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-gray    { background: var(--gray-200); color: var(--gray-700); }

.badge-urgence-P0 { background: #1a1a2e; color: #ff6b6b; }
.badge-urgence-P1 { background: var(--red-100); color: var(--red-500); }
.badge-urgence-P2 { background: #fef3c7; color: #92400e; }
.badge-urgence-P3 { background: var(--green-100); color: var(--green-600); }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
table.data-table {
  width: 100%; border-collapse: collapse;
  font-size: .875rem;
}
table.data-table thead th {
  padding: 10px 14px;
  background: var(--gray-50);
  font-weight: 600; font-size: .78rem;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--gray-500);
  border-bottom: 1.5px solid var(--gray-200);
  white-space: nowrap;
}
table.data-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
  color: var(--gray-700);
}
table.data-table tbody tr:hover td { background: var(--blue-50); }
table.data-table tbody tr:last-child td { border-bottom: none; }

/* ── Search bar ─────────────────────────────────────────────── */
.search-bar {
  display: flex; align-items: center;
  background: var(--white);
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 0 12px;
  gap: 8px;
  transition: border-color var(--transition);
}
.search-bar:focus-within { border-color: var(--blue-500); }
.search-bar input {
  border: none; outline: none;
  font-size: .875rem; padding: 8px 4px;
  flex: 1; font-family: var(--font-main);
  color: var(--gray-900);
  background: transparent;
}
.search-bar i { color: var(--gray-400); }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(3px);
  z-index: 900;
  display: none; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-backdrop.active { display: flex; }
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn .2s ease;
}
.modal-lg { max-width: 900px; }
.modal-header {
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h5 { font-size: 1rem; font-weight: 600; }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--gray-200);
  display: flex; justify-content: flex-end; gap: 10px;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-12px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

/* ── Urgence indicator ──────────────────────────────────────── */
.urgence-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 5px;
}
.urgence-dot.P0 { background: #ff4444; box-shadow: 0 0 0 2px rgba(255,68,68,.25); animation: pulse-red 1s infinite; }
.urgence-dot.P1 { background: var(--red-500); }
.urgence-dot.P2 { background: var(--orange-500); }
.urgence-dot.P3 { background: var(--green-600); }

@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 2px rgba(255,68,68,.25); }
  50% { box-shadow: 0 0 0 5px rgba(255,68,68,.1); }
}

/* ── Tabs ───────────────────────────────────────────────────── */
.tabs-nav {
  display: flex; gap: 4px;
  border-bottom: 1.5px solid var(--gray-200);
  margin-bottom: 20px;
}
.tab-btn {
  padding: 9px 16px;
  font-size: .875rem; font-weight: 500;
  color: var(--gray-500);
  cursor: pointer; border: none;
  background: none; border-bottom: 2.5px solid transparent;
  margin-bottom: -1.5px;
  transition: all var(--transition);
  font-family: var(--font-main);
  display: flex; align-items: center; gap: 7px;
}
.tab-btn:hover { color: var(--blue-600); }
.tab-btn.active {
  color: var(--blue-600);
  border-bottom-color: var(--blue-600);
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Constantes grid ────────────────────────────────────────── */
.constante-box {
  background: var(--gray-50);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 12px 14px;
  text-align: center;
}
.constante-box .c-value {
  font-size: 1.5rem; font-weight: 700;
  font-family: var(--font-mono);
  color: var(--gray-900); line-height: 1;
}
.constante-box .c-label { font-size: .72rem; color: var(--gray-500); margin-top: 4px; text-transform: uppercase; letter-spacing: .06em; }
.constante-box .c-unit  { font-size: .7rem; color: var(--gray-400); }
.constante-box.alert-range { border-color: var(--red-500); background: var(--red-100); }
.constante-box.alert-range .c-value { color: var(--red-500); }

/* ── Timeline ───────────────────────────────────────────────── */
.timeline {
  position: relative;
  padding-left: 28px;
}
.timeline::before {
  content: '';
  position: absolute; left: 9px; top: 0; bottom: 0;
  width: 2px; background: var(--gray-200);
}
.timeline-item {
  position: relative;
  margin-bottom: 20px;
}
.timeline-item::before {
  content: '';
  position: absolute; left: -23px; top: 5px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--blue-500);
  border: 2px solid white;
  box-shadow: 0 0 0 2px var(--blue-200);
}
.timeline-item .tl-time { font-size: .72rem; color: var(--gray-500); margin-bottom: 3px; }
.timeline-item .tl-title { font-weight: 600; font-size: .875rem; }
.timeline-item .tl-body { font-size: .8rem; color: var(--gray-600); margin-top: 4px; }

/* ── Decision tree ──────────────────────────────────────────── */
.decision-node {
  background: var(--white);
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 12px;
  transition: border-color var(--transition);
}
.decision-node.question { border-left: 4px solid var(--blue-500); }
.decision-node.action   { border-left: 4px solid var(--green-600); }
.decision-node.alert    { border-left: 4px solid var(--red-500); background: var(--red-100); }

/* ── Chart wrapper ──────────────────────────────────────────── */
.chart-container { position: relative; width: 100%; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .form-row.cols-4 { grid-template-columns: 1fr 1fr; }
  .form-row.cols-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-260px); }
  .sidebar.open { transform: translateX(0); --sidebar-w: 260px; }
  .main-content { margin-left: 0; }
  .form-row.cols-2,
  .form-row.cols-3,
  .form-row.cols-4 { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
}

/* ── Utilities ──────────────────────────────────────────────── */
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--gray-500); font-size: .875rem; }
.text-sm  { font-size: .8rem; }
.text-danger { color: var(--red-500); }
.text-success { color: var(--green-600); }
.fw-600 { font-weight: 600; }
.w-100 { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 900px) { .grid-4, .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }
