/* AP-HP La Pitie Salpetriere - SIH v3 - Clinical Precision */
@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&family=Instrument+Serif:ital@0;1&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --navy: #0C1B33; --navy-mid: #162340; --navy-light: #1E3056;
  --red: #C8102E; --red-hover: #A80D26; --red-bg: #FEE2E2;
  --blue: #1B5FA8; --blue-light: #2876CF; --blue-bg: #DBEAFE;
  --teal: #0E7490;
  --green: #15803D; --green-bg: #DCFCE7;
  --orange: #B45309; --orange-bg: #FEF3C7;
  --bg: #F2F5F9; --white: #FFFFFF; --card: #FFFFFF;
  --border: #DDE3EC; --border-light: #EEF1F6;
  --ink: #111827; --ink-mid: #374151; --ink-light: #6B7280; --ink-faint: #9CA3AF;
  --sb-w: 240px; --sb-bg: #0C1B33;
  --sb-hover: rgba(255,255,255,.06); --sb-active: rgba(200,16,46,.18);
  --sb-active-br: #C8102E; --sb-text: rgba(255,255,255,.72); --sb-text-dim: rgba(255,255,255,.4);
  --font: 'Instrument Sans', system-ui, sans-serif;
  --font-serif: 'Instrument Serif', Georgia, serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius: 8px; --radius-lg: 12px; --radius-xl: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.12), 0 4px 8px rgba(0,0,0,.06);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); line-height: 1.6; min-height: 100vh; display: flex; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; vertical-align: middle; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
textarea { resize: vertical; }

/* === SIDEBAR === */
.sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: var(--sb-w); background: var(--sb-bg); display: flex; flex-direction: column; z-index: 100; overflow-y: auto; overflow-x: hidden; }
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 2px; }
.sb-brand { display: flex; align-items: center; gap: 12px; padding: 22px 16px 18px; border-bottom: 1px solid rgba(255,255,255,.08); text-decoration: none; }
.sb-brand:hover { text-decoration: none; }
.sb-logo { width: 36px; height: 36px; background: var(--red); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; box-shadow: 0 2px 10px rgba(200,16,46,.45); }
.sb-brand-name { font-family: var(--font-serif); font-size: .92rem; color: #fff; font-style: italic; letter-spacing: .01em; line-height: 1.25; }
.sb-brand-sub { font-size: .64rem; color: var(--sb-text-dim); text-transform: uppercase; letter-spacing: .09em; font-weight: 600; }
.sb-nav { flex: 1; padding: 10px 8px; display: flex; flex-direction: column; gap: 1px; }
.sb-section { font-size: .63rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--sb-text-dim); padding: 14px 10px 4px; }
.sb-link { display: flex; align-items: center; gap: 9px; padding: 9px 11px; border-radius: var(--radius); color: var(--sb-text); font-size: .84rem; font-weight: 500; text-decoration: none; transition: background .12s, color .12s; border-left: 2px solid transparent; }
.sb-link:hover { background: var(--sb-hover); color: #fff; text-decoration: none; }
.sb-link.active { background: var(--sb-active); color: #fff; border-left-color: var(--sb-active-br); }
.sb-icon { font-size: .95rem; width: 18px; text-align: center; opacity: .75; flex-shrink: 0; }
.sb-link.active .sb-icon { opacity: 1; }
.sb-user { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; gap: 10px; }
.sb-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,.15); flex-shrink: 0; }
.sb-avatar-ph { width: 32px; height: 32px; border-radius: 50%; background: var(--navy-light); display: flex; align-items: center; justify-content: center; font-size: .95rem; flex-shrink: 0; }
.sb-user-info { flex: 1; min-width: 0; }
.sb-user-name { font-size: .8rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.25; }
.sb-user-role { font-size: .66rem; color: var(--sb-text-dim); }
.sb-logout { color: var(--sb-text-dim); font-size: .7rem; text-decoration: none; padding: 5px 7px; border-radius: 5px; transition: background .12s, color .12s; white-space: nowrap; flex-shrink: 0; }
.sb-logout:hover { background: rgba(200,16,46,.2); color: #ff6b6b; text-decoration: none; }
.sb-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 99; }
.sb-overlay.show { display: block; }

/* === MAIN === */
.main-wrap { margin-left: var(--sb-w); flex: 1; min-height: 100vh; display: flex; flex-direction: column; }
.page-header { background: var(--white); border-bottom: 1px solid var(--border); padding: 0 32px; height: 54px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; }
.page-header-title { font-family: var(--font-serif); font-size: 1.1rem; color: var(--ink); font-style: italic; letter-spacing: -.01em; }
.mobile-toggle { display: none; background: none; border: none; color: var(--ink-mid); font-size: 1.1rem; cursor: pointer; padding: 6px; border-radius: 6px; }
.mobile-toggle:hover { background: var(--bg); }
.page-wrap { padding: 28px 32px; flex: 1; }
.flash-wrap { padding: 12px 32px 0; }
.page-title { font-family: var(--font-serif); font-size: 1.45rem; font-style: italic; color: var(--ink); margin-bottom: 22px; letter-spacing: -.01em; }
.page-title small { font-size: .78rem; font-style: normal; font-family: var(--font); color: var(--ink-light); margin-left: 10px; font-weight: 400; }

/* === CARDS === */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border-light); background: #FAFBFD; }
.card-title { font-weight: 600; font-size: .88rem; color: var(--ink); }
.card > .table-wrap { margin: 0; }
.card > .empty-state { border-radius: 0; border: none; box-shadow: none; }
.card-red { border-left: 3px solid var(--red); }
.card-blue { border-left: 3px solid var(--blue); }
.card-green { border-left: 3px solid var(--green); }
.card-orange { border-left: 3px solid #D97706; }

/* === BOUTONS === */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 15px; border-radius: var(--radius); font-weight: 600; font-size: .81rem; cursor: pointer; border: 1px solid transparent; transition: all .13s; text-decoration: none; white-space: nowrap; line-height: 1.4; }
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-primary:hover { background: var(--blue-light); border-color: var(--blue-light); }
.btn-secondary { background: var(--white); color: var(--ink-mid); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); border-color: #C0C8D5; }
.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover { background: var(--red-hover); }
.btn-success { background: var(--green); color: #fff; border-color: var(--green); }
.btn-success:hover { background: #166534; }
.btn-sm { padding: 5px 11px; font-size: .77rem; }
.btn-xs { padding: 3px 8px; font-size: .73rem; }
.btn-lg { padding: 11px 22px; font-size: .9rem; }
.w-100 { width: 100%; justify-content: center; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mb-3 { margin-bottom: 12px; }

/* === FORMULAIRES === */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-weight: 600; font-size: .78rem; color: var(--ink-mid); margin-bottom: 5px; letter-spacing: .01em; }
.form-req { color: var(--red); margin-left: 2px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=tel], input[type=url], input[type=color], select, textarea { display: block; width: 100%; padding: 8px 11px; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); color: var(--ink); font-size: .83rem; transition: border-color .13s, box-shadow .13s; outline: none; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(27,95,168,.1); }
input[type=color] { padding: 3px 5px; height: 34px; cursor: pointer; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='7'%3E%3Cpath d='M.5.5l5 5 5-5' stroke='%236B7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 15px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 0 15px; }
small.text-muted { font-size: .74rem; color: var(--ink-faint); display: block; margin-top: 3px; }

/* === ALERTES === */
.alert { padding: 11px 14px; border-radius: var(--radius); font-size: .82rem; border: 1px solid transparent; line-height: 1.5; }
.alert-info { background: var(--blue-bg); border-color: #BFDBFE; color: #1E40AF; }
.alert-ok { background: var(--green-bg); border-color: #BBF7D0; color: #15803D; }
.alert-danger { background: var(--red-bg); border-color: #FECACA; color: #B91C1C; }
.alert-warn { background: var(--orange-bg); border-color: #FDE68A; color: #92400E; }

/* === BADGES === */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 99px; font-size: .7rem; font-weight: 600; letter-spacing: .01em; white-space: nowrap; }
.badge-blue { background: var(--blue-bg); color: #1E40AF; }
.badge-green { background: var(--green-bg); color: #15803D; }
.badge-red { background: var(--red-bg); color: #B91C1C; }
.badge-orange { background: var(--orange-bg); color: #92400E; }
.badge-gray { background: #F3F4F6; color: #4B5563; }
.badge-navy { background: var(--navy); color: #fff; }

/* === TABLEAUX === */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .82rem; }
thead tr { background: #F8F9FB; border-bottom: 2px solid var(--border); }
th { padding: 10px 13px; text-align: left; font-weight: 600; font-size: .73rem; color: var(--ink-mid); text-transform: uppercase; letter-spacing: .07em; white-space: nowrap; }
td { padding: 11px 13px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FAFBFC; }
.fw-bold { font-weight: 600; }

/* === TABS === */
.tabs { display: flex; gap: 2px; margin-bottom: 20px; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 4px; overflow-x: auto; }
.tab-btn { padding: 7px 13px; border-radius: var(--radius); font-weight: 600; font-size: .78rem; cursor: pointer; background: transparent; border: none; color: var(--ink-light); white-space: nowrap; transition: all .12s; }
.tab-btn:hover { background: var(--bg); color: var(--ink); }
.tab-btn.active { background: var(--navy); color: #fff; box-shadow: var(--shadow); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* === MODALES === */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(12,27,51,.55); backdrop-filter: blur(3px); z-index: 200; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.open { display: flex; }
.modal { background: var(--white); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; animation: modalIn .18s ease; }
.modal-lg { max-width: 760px; }
@keyframes modalIn { from { transform: scale(.95) translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 19px 22px 14px; border-bottom: 1px solid var(--border-light); }
.modal-title { font-weight: 700; font-size: .95rem; color: var(--ink); }
.modal-close { background: var(--bg); border: none; border-radius: 6px; width: 28px; height: 28px; cursor: pointer; font-size: .95rem; color: var(--ink-light); display: flex; align-items: center; justify-content: center; transition: background .12s; }
.modal-close:hover { background: var(--red-bg); color: var(--red); }
.modal-body { padding: 18px 22px; }
.modal-footer { padding: 13px 22px 18px; display: flex; justify-content: flex-end; gap: 8px; }

/* === ETAT VIDE === */
.empty-state { padding: 40px 24px; text-align: center; color: var(--ink-faint); font-size: .85rem; }
.empty-state .icon { font-size: 2.2rem; margin-bottom: 10px; opacity: .5; }

/* === ITEMS LISTE === */
.patient-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border-light); transition: background .1s; font-size: .82rem; }
.patient-item:last-child { border-bottom: none; }
.patient-item:hover { background: var(--bg); }
.patient-item.active { background: #EFF6FF; border-left: 3px solid var(--blue); padding-left: 11px; }

/* Utilitaires texte */
.text-muted { color: var(--ink-light); } .text-sm { font-size: .78rem; }
.text-red { color: var(--red); } .text-blue { color: var(--blue); }
.text-green { color: var(--green); } .text-orange { color: var(--orange); }

/* Layout helpers */
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.d-none { display: none !important; }

/* Fiche patient */
.fiche-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(185px,1fr)); gap: 10px; margin-bottom: 16px; }
.fiche-item { background: var(--bg); border: 1px solid var(--border-light); border-radius: var(--radius); padding: 10px 12px; }
.fiche-item label { display: block; font-size: .69rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-faint); margin-bottom: 3px; }
.fiche-item span { font-size: .85rem; font-weight: 600; color: var(--ink); }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(115px,1fr)); gap: 10px; padding: 16px; }
.stat-card { background: var(--bg); border: 1px solid var(--border-light); border-radius: var(--radius); padding: 13px 12px; }
.stat-num { font-size: 1.65rem; font-weight: 700; color: var(--blue); line-height: 1; font-family: var(--font-serif); }
.stat-label { font-size: .71rem; color: var(--ink-light); margin-top: 4px; font-weight: 500; }

/* Code */
code { font-family: var(--font-mono); font-size: .8rem; background: var(--bg); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border); }
pre { font-family: var(--font-mono); font-size: .8rem; background: var(--bg); padding: 14px; border-radius: var(--radius); overflow-x: auto; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #B0BBC9; }

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* === PAGE ACCUEIL PUBLIQUE === */
.hero-section { min-height: 100vh; background: var(--navy); display: flex; flex-direction: column; }
.hero-nav { display: flex; align-items: center; padding: 20px 48px; border-bottom: 1px solid rgba(255,255,255,.07); }
.hero-logo { display: flex; align-items: center; gap: 14px; }
.hero-logo-icon { width: 42px; height: 42px; background: var(--red); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; box-shadow: 0 4px 16px rgba(200,16,46,.4); }
.hero-logo-name { font-family: var(--font-serif); font-style: italic; font-size: 1.05rem; color: #fff; line-height: 1.25; }
.hero-logo-sub { font-size: .68rem; color: rgba(255,255,255,.4); text-transform: uppercase; letter-spacing: .1em; font-weight: 600; }
.hero-body { flex: 1; display: flex; align-items: center; justify-content: center; padding: 60px 32px; }
.hero-content { max-width: 560px; text-align: center; }
.hero-eyebrow { font-size: .77rem; font-weight: 700; text-transform: uppercase; letter-spacing: .14em; color: var(--red); margin-bottom: 18px; }
.hero-title { font-family: var(--font-serif); font-style: italic; font-size: 2.8rem; color: #fff; line-height: 1.15; margin-bottom: 16px; letter-spacing: -.02em; }
.hero-subtitle { font-size: .95rem; color: rgba(255,255,255,.55); margin-bottom: 36px; line-height: 1.75; }
.hero-btn { display: inline-flex; align-items: center; gap: 10px; padding: 13px 30px; background: var(--red); color: #fff; border-radius: var(--radius-lg); font-weight: 700; font-size: .92rem; text-decoration: none; transition: all .18s; box-shadow: 0 4px 20px rgba(200,16,46,.4); }
.hero-btn:hover { background: var(--red-hover); transform: translateY(-2px); box-shadow: 0 8px 28px rgba(200,16,46,.5); text-decoration: none; color: #fff; }
.hero-features { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-top: 52px; }
.hero-feature { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); border-radius: var(--radius-lg); padding: 16px; text-align: left; }
.hero-feature-icon { font-size: 1.3rem; margin-bottom: 8px; }
.hero-feature-name { font-weight: 600; font-size: .79rem; color: #fff; margin-bottom: 4px; }
.hero-feature-desc { font-size: .73rem; color: rgba(255,255,255,.42); line-height: 1.5; }

/* === RESPONSIVE === */
@media (max-width: 900px) {
  :root { --sb-w: 220px; }
  .page-wrap { padding: 20px; } .page-header { padding: 0 20px; } .flash-wrap { padding: 12px 20px 0; }
  .form-grid-2 { grid-template-columns: 1fr; } .form-grid-3 { grid-template-columns: 1fr 1fr; }
  .hero-features { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s; }
  .sidebar.open { transform: none; }
  .main-wrap { margin-left: 0; }
  .mobile-toggle { display: block; }
  .page-wrap { padding: 16px; } .flash-wrap { padding: 10px 16px 0; }
}
