/* ============================================================
   Mon Appa — feuille de style principale (mobile-first)
   ============================================================ */

:root {
  --blue: #1D4ED8;
  --blue-dark: #1E3A8A;
  --sky: #0EA5E9;
  --blue-soft: #EEF4FF;
  --ink: #0F172A;
  --ink-2: #334155;
  --muted: #64748B;
  --line: #E2E8F0;
  --bg: #F6F8FC;
  --white: #FFFFFF;
  --green: #16A34A;
  --green-soft: #E8F7EE;
  --amber: #D97706;
  --amber-soft: #FEF3E2;
  --red: #DC2626;
  --red-soft: #FDECEC;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .08);
  --admin: #0F172A;
  --admin-2: #1E293B;
  --admin-soft: #475569;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0 0 8px; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.18rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 12px; }
small { font-size: .82rem; }

/* ---------------- Barre de titre ---------------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px;
  background: linear-gradient(135deg, var(--blue) 0%, var(--sky) 100%);
  color: #fff;
  box-shadow: 0 6px 18px rgba(29, 78, 216, .22);
}
.admin-body .appbar {
  background: linear-gradient(135deg, #0F172A 0%, #334155 100%);
  box-shadow: 0 6px 18px rgba(15, 23, 42, .3);
}
.appbar-brand { display: flex; align-items: center; gap: 10px; color: #fff; min-width: 0; }
.brand-mark {
  width: 36px; height: 36px; flex: 0 0 36px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .18);
  border-radius: 11px;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 1rem; line-height: 1.15; }
.brand-text small { font-size: .72rem; opacity: .82; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.icon-btn {
  position: relative;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 11px;
  color: #fff;
  background: rgba(255, 255, 255, .14);
  border: 0; cursor: pointer;
}
.icon-btn:hover { background: rgba(255, 255, 255, .26); }
.badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 17px; height: 17px; padding: 0 4px;
  display: grid; place-items: center;
  background: #EF4444; color: #fff;
  font-size: .62rem; font-weight: 700; border-radius: 9px;
  border: 2px solid var(--blue);
}
.admin-body .badge { border-color: #1E293B; }
.avatar-btn { width: 38px; height: 38px; border-radius: 50%; overflow: hidden; border: 2px solid rgba(255,255,255,.55); display: block; }
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; }
.avatar-init {
  display: grid; place-items: center; width: 100%; height: 100%;
  background: rgba(255, 255, 255, .22); color: #fff; font-weight: 700; font-size: .82rem;
}

/* ---------------- Structure ---------------- */
.page { max-width: 760px; margin: 0 auto; padding: 16px 14px calc(96px + env(safe-area-inset-bottom, 0px)); }
.page-narrow { max-width: 480px; }
.section { margin-bottom: 26px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.link-more { font-size: .85rem; font-weight: 600; white-space: nowrap; }
.muted { color: var(--muted); }
.center { text-align: center; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.row-between > .grow { min-width: 0; }
@media (max-width: 400px) { .tab-lbl { font-size: .64rem; } .stat .num { font-size: 1.4rem; } }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

/* ---------------- Cartes ---------------- */
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 12px; }
.card-flush { padding: 0; overflow: hidden; }
.card-link { display: block; color: inherit; transition: transform .16s ease, box-shadow .16s ease; }
.card-link:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

/* ---------------- Grilles ---------------- */
.grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
.grid-2 { display: grid; gap: 12px; grid-template-columns: 1fr; }
.grid-stats { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
.grid-annonces { display: grid; gap: 14px; grid-template-columns: 1fr; }
.grid-voisins { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-stats { grid-template-columns: repeat(4, 1fr); }
  .grid-annonces { grid-template-columns: repeat(2, 1fr); }
  .grid-voisins { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 980px) {
  .grid-annonces { grid-template-columns: repeat(3, 1fr); }
  .grid-voisins { grid-template-columns: repeat(4, 1fr); }
}

/* ---------------- Boutons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 16px; border-radius: 12px;
  border: 1px solid transparent; background: var(--blue-soft); color: var(--blue);
  font: inherit; font-weight: 600; cursor: pointer; text-align: center;
  transition: filter .15s ease, background .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { filter: brightness(.97); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-sky { background: var(--sky); color: #fff; }
.btn-light { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-success { background: var(--green-soft); color: var(--green); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: .86rem; border-radius: 10px; }
.btn-xs { padding: 6px 10px; font-size: .78rem; border-radius: 9px; gap: 5px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-admin { background: var(--admin); color: #fff; }

.fab {
  position: fixed; right: 16px;
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  width: 54px; height: 54px; border-radius: 50%;
  display: grid; place-items: center; border: 0;
  background: var(--blue); color: #fff;
  box-shadow: 0 10px 24px rgba(29, 78, 216, .38); cursor: pointer; z-index: 35;
}

/* ---------------- Formulaires ---------------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .84rem; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field .hint { font-size: .76rem; color: var(--muted); margin-top: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], input[type=search], select, textarea {
  width: 100%; padding: 12px 13px;
  border: 1px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--ink); font: inherit;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(29, 78, 216, .25); border-color: var(--blue); }
.form-error { background: var(--red-soft); color: var(--red); padding: 11px 13px; border-radius: 11px; font-size: .87rem; margin-bottom: 14px; }
.form-ok { background: var(--green-soft); color: var(--green); padding: 11px 13px; border-radius: 11px; font-size: .87rem; margin-bottom: 14px; }

/* ---------------- Recherche / filtres ---------------- */
.searchbar { display: flex; gap: 8px; margin-bottom: 14px; }
.searchbar input { flex: 1 1 auto; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 8px 14px; border-radius: 999px;
  background: #fff; border: 1px solid var(--line); color: var(--ink-2);
  font-size: .85rem; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.chip.active { background: var(--blue); border-color: var(--blue); color: #fff; }

/* ---------------- Listes ---------------- */
.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px; background: #fff; border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: #FBFCFE; }
.list-item .thumb { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; flex: 0 0 56px; }
.list-item .grow { min-width: 0; }
.list-item h3 { font-size: .96rem; margin: 0 0 4px; }
.list-item p { margin: 0; font-size: .84rem; color: var(--muted); }

.avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; flex: 0 0 42px; }
.avatar-sm { width: 32px; height: 32px; flex: 0 0 32px; }
.avatar-lg { width: 74px; height: 74px; flex: 0 0 74px; }
.avatar-fallback {
  display: grid; place-items: center; border-radius: 50%;
  background: var(--blue-soft); color: var(--blue); font-weight: 700; width: 42px; height: 42px;
}

/* ---------------- Photos ---------------- */
.media { position: relative; }
.media img { width: 100%; height: 100%; object-fit: cover; }
.card-photo { aspect-ratio: 4 / 3; overflow: hidden; border-radius: var(--radius) var(--radius) 0 0; background: #EDF1F7; }
.card-photo img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.card-link:hover .card-photo img { transform: scale(1.04); }
.hero-photo { height: 210px; overflow: hidden; position: relative; }
.hero-photo img { width: 100%; height: 100%; object-fit: cover; }
.hero-photo::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(15,23,42,.05) 0%, rgba(15,23,42,.62) 100%);
}
.hero-photo .hero-caption { position: absolute; left: 16px; right: 16px; bottom: 14px; color: #fff; z-index: 2; }
.hero-photo .hero-caption h2 { color: #fff; margin: 0 0 4px; }
.hero-photo .hero-caption p { margin: 0; font-size: .85rem; opacity: .92; }

/* ---------------- Etiquettes ---------------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 999px;
  font-size: .74rem; font-weight: 700; letter-spacing: .01em;
  background: var(--blue-soft); color: var(--blue);
}
.pill-green { background: var(--green-soft); color: var(--green); }
.pill-amber { background: var(--amber-soft); color: var(--amber); }
.pill-red { background: var(--red-soft); color: var(--red); }
.pill-grey { background: #EEF1F6; color: var(--muted); }
.pill-admin { background: #E2E8F0; color: var(--admin); }

/* ---------------- Statistiques ---------------- */
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat .num { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.stat .lbl { font-size: .78rem; color: var(--muted); margin-top: 3px; }
.admin-body .stat { background: var(--admin-2); border-color: #334155; color: #E2E8F0; }
.admin-body .stat .lbl { color: #94A3B8; }

/* ---------------- Messages ---------------- */
.chat-thread { display: flex; flex-direction: column; gap: 8px; padding: 14px; }
.bubble { max-width: 82%; padding: 10px 13px; border-radius: 15px; font-size: .9rem; background: #EEF1F6; color: var(--ink); }
.bubble.me { align-self: flex-end; background: var(--blue); color: #fff; }
.bubble time { display: block; font-size: .68rem; opacity: .7; margin-top: 4px; }
.chat-compose {
  position: sticky; bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  display: flex; gap: 8px; padding: 10px 14px;
  background: #fff; border-top: 1px solid var(--line);
}
.chat-compose input { flex: 1 1 auto; }

/* ---------------- Barre de navigation ---------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; align-items: stretch;
  background: rgba(255, 255, 255, .97);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
}
.tab {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 5px 2px; color: var(--muted); font-size: .68rem; font-weight: 600;
  border-radius: 12px;
}
.tab-ico { position: relative; display: grid; place-items: center; }
.tab.active { color: var(--blue); }
.tab.active .tab-ico { background: var(--blue-soft); border-radius: 11px; padding: 3px 10px; }
.tab-lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.admin-tabbar { background: rgba(15, 23, 42, .97); border-top-color: #1E293B; }
.admin-tabbar .tab { color: #94A3B8; }
.admin-tabbar .tab.active { color: #fff; }
.admin-tabbar .tab.active .tab-ico { background: rgba(255,255,255,.16); border-radius: 11px; padding: 3px 10px; }
.admin-tabbar .badge { border-color: #0F172A; }

/* ---------------- Bandeau installation ---------------- */
.install-strip {
  position: fixed; left: 14px; right: 14px;
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  z-index: 45; display: flex; justify-content: center;
}
.install-strip .btn { box-shadow: 0 10px 24px rgba(15, 23, 42, .18); }

/* ---------------- Pages publiques ---------------- */
.pub-hero {
  position: relative; color: #fff;
  min-height: 260px; display: flex; align-items: flex-end;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  overflow: hidden;
}
.pub-hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pub-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(160deg, rgba(29,78,216,.72), rgba(15,23,42,.82)); }
.pub-hero .inner { position: relative; z-index: 2; }
.pub-hero h1 { font-size: 1.72rem; color: #fff; margin-bottom: 6px; }
.pub-hero p { opacity: .94; margin: 0 0 14px; font-size: .95rem; }
.pub-hero .btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------------- Auth ---------------- */
.auth-wrap { max-width: 460px; margin: 0 auto; padding: 18px 14px calc(96px + env(safe-area-inset-bottom, 0px)); }
.auth-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.auth-visual { height: 170px; border-radius: var(--radius); overflow: hidden; margin-bottom: 14px; position: relative; }
.auth-visual img { width: 100%; height: 100%; object-fit: cover; }
.auth-visual .overlay { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(29,78,216,.25), rgba(15,23,42,.7)); display: flex; align-items: flex-end; padding: 14px; color: #fff; }

/* ---------------- Modale ---------------- */
.modal-back { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: grid; place-items: center; padding: 18px; z-index: 90; }
.modal { background: #fff; border-radius: var(--radius); padding: 20px; max-width: 420px; width: 100%; box-shadow: var(--shadow); }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  background: var(--ink); color: #fff; padding: 10px 16px;
  border-radius: 999px; font-size: .86rem; z-index: 120; max-width: 88vw; text-align: center;
}
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }

/* ---------------- Admin ---------------- */
.admin-body { background: #F1F5F9; }
.admin-body .page { max-width: 900px; }
.admin-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.chart-box { position: relative; height: 260px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.admin-table th, .admin-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.gate { max-width: 440px; margin: 8vh auto; padding: 20px; }
.gate-card { background: #fff; border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); text-align: center; }
.gate-card .brand-mark { margin: 0 auto 12px; background: var(--admin); }

/* ---------------- Divers ---------------- */
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty svg { opacity: .4; margin-bottom: 10px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.tag-legend { display: flex; flex-wrap: wrap; gap: 8px; }
.tabs-inline { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs-inline a { padding: 8px 13px; border-radius: 10px; background: #fff; border: 1px solid var(--line); font-size: .85rem; font-weight: 600; color: var(--ink-2); }
.tabs-inline a.active { background: var(--admin); border-color: var(--admin); color: #fff; }
.pwa-steps { list-style: none; padding: 0; margin: 12px 0 0; text-align: left; }
.pwa-steps li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; font-size: .88rem; }
.pwa-steps .n { flex: 0 0 24px; height: 24px; border-radius: 50%; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; font-weight: 700; font-size: .78rem; }
.os-badges { display: flex; gap: 14px; justify-content: center; margin-top: 14px; color: var(--ink-2); }
.os-badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 13px; border: 1px solid var(--line); border-radius: 999px;
  font-size: .82rem; font-weight: 600; background: #fff;
}

@media (prefers-reduced-motion: no-preference) {
  .reveal { opacity: 0; transform: translateY(14px); transition: opacity .5s ease, transform .5s ease; }
  .reveal.in { opacity: 1; transform: none; }
}
