/* SOS TUN — design d'après openai.com/business :
   fond dégradé bleu-gris clair, hero géant avec ligne bleue encadrée,
   boutons pill noirs, bordures fines, typographie Inter serrée. */

:root {
  --bg-top: #eef3f9;
  --bg: #ffffff;
  --text: #0d0d0d;
  --text-2: #5d6b7a;
  --border: #e4e9ef;
  --surface: #f2f5f9;
  --radius: 18px;
  --blue: #69a9f0;
  --blue-ink: #175cd3;
  --blue-bg: #eff6ff;
  --red: #d92d20;
  --red-bg: #fef3f2;
  --amber: #b54708;
  --amber-bg: #fffaeb;
  --green: #067647;
  --green-bg: #ecfdf3;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  background: #ffffff;
  min-height: 100vh;
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
html[lang="ar"] body,
html[lang="ar"] input, html[lang="ar"] select, html[lang="ar"] textarea, html[lang="ar"] button {
  font-family: 'Noto Sans Arabic', 'Inter', 'Segoe UI', Tahoma, Arial, sans-serif;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; color: inherit; }

.container { max-width: 680px; margin: 0 auto; padding: 0 20px 96px; }

/* ---------- entête ---------- */

header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-in {
  max-width: 1080px; margin: 0 auto; padding: 13px 20px;
  display: flex; align-items: center; gap: 10px;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 700; letter-spacing: -0.04em; font-size: 19px;
}
.brand .logo {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: var(--text); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.header-spacer { flex: 1; }
.back-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 999px; flex: none;
  border: 1px solid var(--border); font-size: 17px; background: #fff;
}
[dir="rtl"] .back-link span { display: inline-block; transform: scaleX(-1); }

.pill-ghost {
  border: none; background: rgba(13, 13, 13, 0.06); color: var(--text);
  border-radius: 999px; padding: 9px 16px; font-size: 14px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
}
.pill-ghost:hover { background: rgba(13, 13, 13, 0.1); }
.pill-dark {
  border: none; background: var(--text); color: #fff;
  border-radius: 999px; padding: 9px 18px; font-size: 14px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
}
.pill-dark:hover { opacity: 0.85; }
.avatar {
  width: 24px; height: 24px; border-radius: 999px; flex: none;
  background: var(--blue); color: #fff; font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ---------- hero (comme la capture : ligne bleue encadrée + ligne noire) ---------- */

.hero { padding: 56px 0 12px; text-align: center; }
.hero h1 {
  font-size: clamp(34px, 9.5vw, 58px);
  font-weight: 600; letter-spacing: -0.04em; line-height: 1.12;
}
.hero .hl-boxed {
  display: inline-block;
  color: var(--blue);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0.45em;
  padding: 0.02em 0.3em;
  margin-bottom: 0.08em;
}
.hero p {
  color: var(--text-2); margin: 18px auto 0; font-size: 17px;
  max-width: 52ch; line-height: 1.6;
}
.hero-cta {
  display: flex; align-items: center; justify-content: center;
  gap: 22px; margin-top: 28px; flex-wrap: wrap;
}
.hero-link { font-weight: 600; font-size: 15.5px; display: inline-flex; align-items: center; gap: 5px; }
.hero-link:hover { opacity: 0.7; }
[dir="rtl"] .hero-link .chev { display: inline-block; transform: scaleX(-1); }

/* ---------- typographie ---------- */

h2.section {
  font-size: 24px; font-weight: 600; letter-spacing: -0.025em;
  margin: 34px 0 6px; line-height: 1.2;
}
.section-sub { color: var(--text-2); font-size: 15px; margin-bottom: 16px; }

/* ---------- boutons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 999px; padding: 13px 26px;
  font-size: 15.5px; font-weight: 600; border: 1px solid transparent;
  transition: opacity 0.15s, border-color 0.15s, background 0.15s;
  text-align: center; letter-spacing: -0.01em;
}
.btn:active { opacity: 0.75; }
.btn-primary { background: var(--text); color: #fff; }
.btn-primary:hover { opacity: 0.85; }
.btn-outline { background: #fff; border-color: #cfd6de; color: var(--text); }
.btn-outline:hover { border-color: var(--text); }
.btn-danger { background: var(--red); color: #fff; }
.btn-block { display: flex; width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 13.5px; }
.btn-lg { padding: 16px 32px; font-size: 16.5px; }

/* Bouton d'urgence médicale */
.emergency-btn {
  display: flex; align-items: center; gap: 15px;
  width: 100%; margin: 34px 0 8px;
  background: var(--red); color: #fff;
  border: none; border-radius: var(--radius);
  padding: 19px 22px; text-align: start;
  box-shadow: 0 10px 28px rgba(217, 45, 32, 0.22);
}
.emergency-btn .t { font-size: 17.5px; font-weight: 700; letter-spacing: -0.015em; }
.emergency-btn .s { font-size: 13px; opacity: 0.88; margin-top: 3px; }
.emergency-btn .ic { font-size: 26px; }
.emergency-btn:active { opacity: 0.88; }

/* Grandes cartes-boutons */
.nav-card {
  display: flex; align-items: center; gap: 16px;
  width: 100%; margin-top: 12px;
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 21px 20px;
  text-align: start; transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.nav-card:hover { border-color: #b9c2cc; box-shadow: 0 4px 14px rgba(16, 24, 40, 0.07); }
.nav-card .ic {
  width: 46px; height: 46px; border-radius: 13px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: #fff; border: 1px solid var(--border); font-size: 22px;
}
.nav-card .t { font-size: 16.5px; font-weight: 600; letter-spacing: -0.015em; }
.nav-card .s { font-size: 13.5px; color: var(--text-2); margin-top: 2px; }
.nav-card .arrow { margin-inline-start: auto; color: var(--text-2); font-size: 18px; }
[dir="rtl"] .nav-card .arrow, [dir="rtl"] .linkrow .arrow { transform: scaleX(-1); }

.linkrow {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 2px; border-bottom: 1px solid var(--border);
  font-size: 15.5px; font-weight: 600; width: 100%; background: none;
  border-top: 0; border-left: 0; border-right: 0; text-align: start;
  letter-spacing: -0.01em;
}
.linkrow .arrow { margin-inline-start: auto; color: var(--text-2); }

/* ---------- cartes & badges ---------- */

.card {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 19px; margin-top: 12px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.card.clickable { transition: border-color 0.15s, box-shadow 0.15s; display: block; width: 100%; text-align: start; }
.card.clickable:hover { border-color: #b9c2cc; box-shadow: 0 4px 14px rgba(16, 24, 40, 0.07); }
.card.medical { border-color: #fecdca; background: #fffbfa; }

.card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-title { font-weight: 600; font-size: 16.5px; letter-spacing: -0.015em; }
.card-meta { color: var(--text-2); font-size: 13.5px; margin-top: 7px; }
.card-body { font-size: 14.5px; margin-top: 9px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  border-radius: 999px; padding: 4px 11px;
  font-size: 12px; font-weight: 600; letter-spacing: 0;
  background: var(--surface); color: var(--text-2);
}
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.blue { background: var(--blue-bg); color: var(--blue-ink); }
.badge.solid-red { background: var(--red); color: #fff; }

.count-badge {
  background: var(--red); color: #fff; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; padding: 2px 9px;
}

/* ---------- formulaires ---------- */

form { margin-top: 8px; }
.field { margin-top: 17px; }
.field label {
  display: block; font-size: 14px; font-weight: 600;
  margin-bottom: 7px; letter-spacing: -0.01em;
}
.field .hint { font-size: 12.5px; color: var(--text-2); font-weight: 400; }

input[type="text"], input[type="tel"], input[type="password"], select, textarea {
  width: 100%; font: inherit; font-size: 16px;
  border: 1px solid #cfd6de; border-radius: 13px;
  padding: 13px 15px; background: #fff; color: var(--text);
  appearance: none; -webkit-appearance: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235d6b7a' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 15px center;
  padding-inline-end: 38px;
}
[dir="rtl"] select { background-position: left 15px center; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(13, 13, 13, 0.07);
}
textarea { min-height: 84px; resize: vertical; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg .seg-btn {
  border: 1px solid #cfd6de; background: #fff; border-radius: 999px;
  padding: 10px 19px; font-size: 14px; font-weight: 600;
}
.seg .seg-btn.on { background: var(--text); color: #fff; border-color: var(--text); }

/* Sélecteur de profil (inscription) */
.role-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.role-card {
  border: 1.5px solid var(--border); background: #fff; border-radius: var(--radius);
  padding: 18px 14px; text-align: center; transition: border-color 0.15s, background 0.15s;
}
.role-card .ic { font-size: 26px; display: block; margin-bottom: 8px; }
.role-card .t { font-weight: 600; font-size: 14.5px; letter-spacing: -0.01em; display: block; }
.role-card .s { font-size: 12px; color: var(--text-2); margin-top: 4px; display: block; }
.role-card.on { border-color: var(--text); background: #fff; box-shadow: 0 0 0 1px var(--text); }

.checks { display: flex; flex-direction: column; gap: 4px; }
.check {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 2px; font-size: 15px;
}
.check input { width: 19px; height: 19px; accent-color: var(--text); flex: none; }

.form-actions { margin-top: 26px; display: flex; flex-direction: column; gap: 10px; }

/* ---------- encadrés ---------- */

.notice {
  border-radius: 13px; padding: 14px 16px;
  font-size: 13.5px; line-height: 1.6; margin-top: 16px;
}
.notice.warn { background: var(--amber-bg); color: var(--amber); }
.notice.danger { background: var(--red-bg); color: #912018; }
.notice.info { background: #fff; border: 1px solid var(--border); color: var(--text-2); }
.notice.ok { background: var(--green-bg); color: var(--green); }
.notice b { font-weight: 600; }

.footnote {
  color: var(--text-2); font-size: 12.5px; line-height: 1.65;
  margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--border);
}

/* ---------- filtres ---------- */

.filters { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.filters select { flex: 1; min-width: 140px; padding: 10px 13px; font-size: 14.5px; border-radius: 11px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid #cfd6de; background: #fff; border-radius: 999px;
  padding: 8px 16px; font-size: 13.5px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip.on { background: var(--text); color: #fff; border-color: var(--text); }
.chip.on.red { background: var(--red); border-color: var(--red); }
.chip.on.green { background: var(--green); border-color: var(--green); }

/* ---------- divers ---------- */

.empty {
  text-align: center; color: var(--text-2); font-size: 14.5px;
  padding: 52px 16px;
}
.empty .ic { font-size: 36px; display: block; margin-bottom: 10px; }

.detail-list { margin-top: 4px; }
.detail-list .dl-row {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
  font-size: 14.5px;
}
.detail-list .dl-row:last-child { border-bottom: 0; }
.detail-list .k { color: var(--text-2); flex: none; }
.detail-list .v { font-weight: 500; text-align: end; overflow-wrap: anywhere; }

.actions-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 15px; }

.tabs { display: flex; gap: 8px; margin: 18px 0 6px; flex-wrap: wrap; }
.tab-btn {
  border: 1px solid var(--border); background: #fff; border-radius: 999px;
  padding: 9px 17px; font-size: 14px; font-weight: 600;
}
.tab-btn.on { background: var(--text); color: #fff; border-color: var(--text); }

/* Carte d'authentification */
.auth-card {
  background: #fff; border: 1px solid var(--border); border-radius: 22px;
  padding: 28px 24px; margin-top: 22px;
  box-shadow: 0 6px 24px rgba(16, 24, 40, 0.06);
}
.auth-switch { text-align: center; margin-top: 18px; font-size: 14px; color: var(--text-2); }
.auth-switch a { font-weight: 600; color: var(--text); text-decoration: underline; }

#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; border-radius: 999px;
  padding: 13px 24px; font-size: 14.5px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
  max-width: calc(100vw - 40px); text-align: center; z-index: 50;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
#toast.show { opacity: 1; }

.spinner { text-align: center; color: var(--text-2); padding: 44px 0; font-size: 14.5px; }

/* ---------- carte immersive ---------- */

.map-wrap {
  position: relative;
  margin: 14px -20px -96px;
  height: calc(100vh - 118px);
  border-top: 1px solid var(--border);
  overflow: hidden;
}
#map { position: absolute; inset: 0; z-index: 0; }

.map-top {
  position: absolute; top: 12px; inset-inline: 12px; z-index: 1000;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.map-top .chips, .map-selects { pointer-events: auto; }
.map-chip {
  border: 1px solid var(--border); background: #fff; border-radius: 999px;
  padding: 8px 15px; font-size: 13px; font-weight: 600;
  box-shadow: 0 2px 10px rgba(16, 24, 40, 0.10);
  display: inline-flex; align-items: center; gap: 5px; opacity: 0.55;
}
.map-chip.on { opacity: 1; }
.map-chip.on.red { background: var(--red); color: #fff; border-color: var(--red); }
.map-chip.on.green { background: var(--green); color: #fff; border-color: var(--green); }
.map-chip.on.amber { background: #f79009; color: #fff; border-color: #f79009; }
.map-chip.on:not(.red):not(.green):not(.amber) { background: var(--text); color: #fff; border-color: var(--text); }

.map-selects { display: flex; gap: 8px; }
.map-selects select {
  width: auto; border-radius: 999px; padding: 9px 36px 9px 14px;
  font-size: 13.5px; font-weight: 600; border: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(16, 24, 40, 0.10); background-color: #fff;
}
[dir="rtl"] .map-selects select { padding: 9px 14px 9px 36px; }

.map-locate {
  position: absolute; bottom: 110px; inset-inline-end: 14px; z-index: 1000;
  width: 48px; height: 48px; border-radius: 999px;
  background: #fff; border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(16, 24, 40, 0.14); font-size: 20px;
}

.stat-pill {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 1000; background: var(--text); color: #fff;
  border-radius: 999px; padding: 10px 20px;
  font-size: 13.5px; font-weight: 600; white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

.sheet {
  position: absolute; bottom: 0; inset-inline: 0; z-index: 1100;
  background: #fff; border-radius: 22px 22px 0 0;
  box-shadow: 0 -12px 44px rgba(16, 24, 40, 0.20);
  padding: 22px 20px; max-height: 62%; overflow-y: auto;
}
.sheet-title { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.sheet-sub { color: var(--text-2); font-size: 13.5px; margin-top: 4px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.sheet-actions .btn { flex: 1; min-width: 130px; }
.sheet-close {
  position: absolute; top: 14px; inset-inline-end: 14px;
  width: 34px; height: 34px; border-radius: 999px;
  border: 1px solid var(--border); background: #fff; font-size: 14px;
}
.stat-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.stat-tiles .tile { border: 1px solid var(--border); border-radius: 14px; padding: 13px 15px; }
.stat-tiles .n { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.stat-tiles .l { font-size: 12px; color: var(--text-2); margin-top: 2px; }

/* ---------- grilles ---------- */

.card-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 12px; }
.card-grid .card { margin-top: 0; }
.card-grid .empty, .card-grid .spinner { grid-column: 1 / -1; }

.nav-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 12px; }
.nav-grid .nav-card { margin-top: 0; }

.avail-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 8px; }

@media (min-width: 480px) {
  .form-actions { flex-direction: row; }
  .form-actions .btn { flex: 1; }
}

/* ---------- grand écran : mise en page élargie ---------- */

@media (min-width: 900px) {
  body { font-size: 17px; }
  .container { max-width: 1024px; }
  h2.section { font-size: 28px; }
  .hero { padding: 80px 0 24px; }
  .hero h1 { font-size: clamp(48px, 6vw, 76px); }
  .hero p { font-size: 19px; }
  .card-grid { grid-template-columns: 1fr 1fr; }
  .nav-grid { grid-template-columns: repeat(3, 1fr); }
  .nav-grid .nav-card { flex-direction: column; align-items: flex-start; gap: 14px; padding: 28px 24px; }
  .nav-grid .nav-card .arrow { display: none; }
  .narrow { max-width: 720px; margin-inline: auto; }
  #app > form { max-width: 720px; }
  .map-wrap {
    margin: 18px 0 -80px; height: calc(100vh - 170px);
    border: 1px solid var(--border); border-radius: 18px;
  }
  .sheet {
    inset-inline-start: auto; inset-inline-end: 18px; bottom: 18px;
    max-width: 460px; border-radius: 20px;
  }
  .emergency-btn { padding: 24px 26px; }
  .emergency-btn .t { font-size: 19px; }
}
