/* ==========================================================
   Plaisanciers Connect — feuille de style principale
   Palette : marine profond / sable / corail / lagon
   ========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&display=swap');

:root {
  --marine-950: #081E2B;
  --marine-900: #0B2B3C;
  --marine-700: #164659;
  --marine-500: #2C6E82;
  --sable: #F5EFE3;
  --sable-dark: #E7DCC6;
  --corail: #FF6B4A;
  --corail-dark: #E5522F;
  --lagon: #2CA6A4;
  --lagon-dark: #0E7C7B;
  --blanc: #FFFFFF;
  --gris-texte: #4A5A62;
  --danger: #D64545;

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;

  --radius-s: 6px;
  --radius-m: 12px;
  --radius-l: 20px;

  --shadow-card: 0 2px 16px rgba(8, 30, 43, 0.10);
  --shadow-float: 0 8px 32px rgba(8, 30, 43, 0.22);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--marine-900);
  background: var(--sable);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .font-display {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  margin: 0;
  color: var(--marine-950);
}

p { line-height: 1.6; }

a { color: inherit; text-decoration: none; }

button, input, select, textarea { font-family: inherit; font-size: 1rem; }

:focus-visible {
  outline: 3px solid var(--lagon);
  outline-offset: 2px;
}

/* ---------- Layout général ---------- */

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.5rem;
  background: var(--marine-900);
  color: var(--sable);
  z-index: 40;
  position: relative;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--blanc);
}

.brand .flag-mark {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  font-size: 0.94rem;
}

.topbar nav a {
  color: var(--sable);
  opacity: 0.88;
  transition: opacity .15s ease;
}
.topbar nav a:hover { opacity: 1; }

.topbar .cta-btn {
  background: var(--corail);
  color: var(--blanc);
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius-s);
  font-weight: 600;
  opacity: 1 !important;
}
.topbar .cta-btn:hover { background: var(--corail-dark); }

.avatar-chip {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--lagon);
  color: var(--blanc);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-family: var(--font-display);
  font-size: 0.85rem;
}

/* ---------- Boutons génériques ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.4rem;
  border-radius: var(--radius-s);
  border: none;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform .1s ease, background .15s ease, box-shadow .15s ease;
}
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--corail); color: var(--blanc); }
.btn-primary:hover { background: var(--corail-dark); }

.btn-secondary { background: var(--marine-900); color: var(--sable); }
.btn-secondary:hover { background: var(--marine-700); }

.btn-outline {
  background: transparent;
  color: var(--marine-900);
  border: 1.5px solid var(--marine-700);
}
.btn-outline:hover { background: var(--marine-900); color: var(--sable); }

.btn-ghost {
  background: transparent;
  color: var(--marine-700);
}
.btn-ghost:hover { background: rgba(11,43,60,0.06); }

.btn-danger { background: var(--danger); color: var(--blanc); }

.btn-block { width: 100%; }
.btn-sm { padding: 0.45rem 0.9rem; font-size: 0.85rem; }

/* ---------- Carte plein écran (accueil) ---------- */

.map-page {
  position: relative;
  flex: 1;
  min-height: 0;
}

#map {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.map-panel {
  position: absolute;
  top: 1.25rem;
  left: 1.25rem;
  width: 320px;
  max-width: calc(100vw - 2.5rem);
  background: var(--blanc);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-float);
  z-index: 20;
  padding: 1.25rem;
  max-height: calc(100vh - 8rem);
  overflow-y: auto;
}

.map-panel h2 {
  font-size: 1.05rem;
  margin-bottom: 0.9rem;
}

.search-field {
  position: relative;
  margin-bottom: 1rem;
}

.search-field input {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1.5px solid var(--sable-dark);
  border-radius: var(--radius-s);
  background: var(--sable);
}

.search-field .locate-btn {
  position: absolute;
  right: 6px;
  top: 6px;
  bottom: 6px;
  width: 34px;
  border-radius: var(--radius-s);
  background: var(--marine-900);
  color: var(--sable);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.category-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.category-chip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-s);
  cursor: pointer;
  font-size: 0.9rem;
  border: 1.5px solid transparent;
  transition: background .12s ease, border-color .12s ease;
}
.category-chip:hover { background: var(--sable); }
.category-chip.active {
  background: rgba(44, 166, 164, 0.12);
  border-color: var(--lagon);
  font-weight: 600;
}
.category-chip .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--lagon);
  flex-shrink: 0;
}

.map-legend {
  position: absolute;
  bottom: 1.25rem;
  left: 1.25rem;
  z-index: 20;
  background: rgba(11,43,60,0.9);
  color: var(--sable);
  padding: 0.55rem 0.9rem;
  border-radius: var(--radius-s);
  font-size: 0.8rem;
  display: flex;
  gap: 0.7rem;
  align-items: center;
}

/* Fenêtre popup Leaflet personnalisée */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-float);
}
.popup-offreur { min-width: 200px; }
.popup-offreur h3 { font-size: 1rem; margin-bottom: 0.2rem; }
.popup-offreur .cats { font-size: 0.78rem; color: var(--gris-texte); margin-bottom: 0.5rem; }
.popup-offreur .rating { color: var(--corail); font-size: 0.85rem; margin-bottom: 0.6rem; }

/* Marqueur pavillon custom */
.flag-marker {
  width: 30px;
  height: 38px;
  position: relative;
}

/* ---------- Pages classiques (auth, profil, listes) ---------- */

.page-container {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.page-container.narrow { max-width: 480px; }

.card {
  background: var(--blanc);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-card);
  padding: 2rem;
}

.page-title {
  font-size: 1.8rem;
  margin-bottom: 0.4rem;
}
.page-subtitle {
  color: var(--gris-texte);
  margin-bottom: 1.75rem;
}

.form-group { margin-bottom: 1.15rem; }
.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 0.4rem;
  color: var(--marine-700);
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1.5px solid var(--sable-dark);
  border-radius: var(--radius-s);
  background: var(--blanc);
}
.form-group textarea { resize: vertical; min-height: 100px; }
.form-hint { font-size: 0.8rem; color: var(--gris-texte); margin-top: 0.3rem; }

.role-choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.role-choice label {
  border: 1.5px solid var(--sable-dark);
  border-radius: var(--radius-s);
  padding: 0.7rem;
  text-align: center;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
}
.role-choice input { display: none; }
.role-choice input:checked + span,
.role-choice label:has(input:checked) {
  border-color: var(--lagon);
  background: rgba(44,166,164,0.1);
  font-weight: 600;
}

.alert {
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius-s);
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}
.alert-error { background: #FDECEA; color: #A32F1E; }
.alert-success { background: #E4F5EE; color: #14603F; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-offreur { background: rgba(44,166,164,0.15); color: var(--lagon-dark); }
.badge-demandeur { background: rgba(255,107,74,0.15); color: var(--corail-dark); }
.badge-admin { background: var(--marine-900); color: var(--sable); }

/* ---------- Liste des conversations / messagerie ---------- */

.messages-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.25rem;
  height: calc(100vh - 200px);
  min-height: 480px;
}

.conv-list {
  background: var(--blanc);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-card);
  overflow-y: auto;
}

.conv-item {
  display: block;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--sable);
}
.conv-item:hover { background: var(--sable); }
.conv-item.active { background: rgba(44,166,164,0.1); }
.conv-item .conv-top {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}
.conv-item .conv-name { font-weight: 600; }
.conv-item .conv-preview {
  font-size: 0.82rem;
  color: var(--gris-texte);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-panel {
  background: var(--blanc);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.thread-header {
  padding: 1rem 1.4rem;
  border-bottom: 1px solid var(--sable);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.status-select {
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-s);
  border: 1.5px solid var(--sable-dark);
  font-size: 0.85rem;
  font-weight: 600;
}

.thread-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.msg-bubble {
  max-width: 68%;
  padding: 0.65rem 0.95rem;
  border-radius: var(--radius-m);
  font-size: 0.92rem;
  line-height: 1.45;
}
.msg-bubble.mine {
  align-self: flex-end;
  background: var(--lagon);
  color: var(--blanc);
  border-bottom-right-radius: 4px;
}
.msg-bubble.theirs {
  align-self: flex-start;
  background: var(--sable);
  border-bottom-left-radius: 4px;
}
.msg-time {
  font-size: 0.7rem;
  opacity: 0.7;
  margin-top: 0.25rem;
  display: block;
}

.thread-composer {
  display: flex;
  gap: 0.6rem;
  padding: 1rem;
  border-top: 1px solid var(--sable);
}
.thread-composer textarea {
  flex: 1;
  border: 1.5px solid var(--sable-dark);
  border-radius: var(--radius-s);
  padding: 0.6rem 0.8rem;
  resize: none;
  max-height: 100px;
}

/* ---------- Profil offreur public ---------- */

.profile-header {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  margin-bottom: 1.75rem;
}
.profile-avatar {
  width: 84px; height: 84px;
  border-radius: 50%;
  background: var(--marine-900);
  color: var(--sable);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 1.8rem;
  flex-shrink: 0;
}
.stars { color: var(--corail); font-size: 0.95rem; }

.cat-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--sable);
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  font-size: 0.85rem;
  margin: 0 0.4rem 0.4rem 0;
}

.review-item {
  padding: 1rem 0;
  border-bottom: 1px solid var(--sable);
}
.review-item:last-child { border-bottom: none; }

/* ---------- Table admin ---------- */

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--blanc);
  border-radius: var(--radius-m);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.data-table th, .data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--sable);
}
.data-table th {
  background: var(--marine-900);
  color: var(--sable);
  font-weight: 600;
  font-family: var(--font-display);
}
.data-table tr:last-child td { border-bottom: none; }

.admin-nav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.admin-nav a {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-s);
  font-size: 0.88rem;
  font-weight: 600;
  background: var(--sable);
}
.admin-nav a.active { background: var(--marine-900); color: var(--sable); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--blanc);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-card);
  padding: 1.25rem;
}
.stat-card .num {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--marine-900);
}
.stat-card .label { font-size: 0.85rem; color: var(--gris-texte); }

/* ---------- Footer ---------- */

.site-footer {
  background: var(--marine-950);
  color: rgba(245,239,227,0.7);
  padding: 1.25rem 1.5rem;
  font-size: 0.8rem;
  text-align: center;
}

/* ---------- Responsive ---------- */

/* ---------- Barre de navigation basse (mobile uniquement) ---------- */

.bottom-nav {
  display: none;
}

@media (max-width: 760px) {
  .topbar nav { display: none; }
  .map-panel { width: calc(100vw - 2.5rem); }
  .messages-layout { grid-template-columns: 1fr; height: auto; }
  .conv-list { max-height: 240px; }
  .role-choice { grid-template-columns: 1fr; }
  .profile-header { flex-direction: column; text-align: center; }

  /* Espace réservé en bas de l'écran pour ne rien masquer sous la barre */
  .app-shell { padding-bottom: calc(58px + env(safe-area-inset-bottom)); }

  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 50;
    background: var(--marine-900);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 12px rgba(8,30,43,0.25);
  }
  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    padding: 0.55rem 0.2rem;
    color: var(--sable);
    font-size: 0.72rem;
    opacity: 0.85;
    min-height: 44px; /* zone tactile confortable */
  }
  .bottom-nav-item:active { opacity: 1; }
  .bn-icon { font-size: 1.25rem; line-height: 1; }

  /* Sur mobile, la carte doit remplir l'espace disponible au-dessus de la barre basse */
  .map-page { min-height: calc(100vh - 58px - env(safe-area-inset-bottom)); }

  /* Zones tactiles confortables partout */
  .btn { min-height: 44px; }
  .category-chip { min-height: 40px; }
}

@supports (padding: max(0px)) {
  .topbar {
    padding-left: max(1.5rem, env(safe-area-inset-left));
    padding-right: max(1.5rem, env(safe-area-inset-right));
  }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
