/* ZilHa42 — Design system (mobile-first, ambiance plage/turquoise) */
:root {
  --teal: #127475;
  --teal-dark: #0c5253;
  --teal-light: #14919b;
  --sand: #f4ecd9;
  --sand-dark: #e7d9bd;
  --coral: #ef7a5a;
  --ink: #1c2a2a;
  --muted: #5c6b6b;
  --bg: #f7f4ee;
  --white: #ffffff;
  --ok: #2e9e5b;
  --warn: #e0a800;
  --danger: #d0454c;
  --radius: 16px;
  --shadow: 0 6px 20px rgba(18, 116, 117, 0.14);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  /* Fond « coucher de soleil sur la plage » : illustration en couche fixe,
     avec un degrade de secours si l'image ne charge pas. */
  background:
    url('/img/scene.svg') center bottom / cover no-repeat fixed,
    linear-gradient(180deg, #FFF3DA 0%, #FFE1B0 45%, #FFC79B 100%) fixed;
}
/* Voile clair pour garder les textes/cartes bien lisibles par-dessus la scene */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.30), rgba(255,255,255,0.08) 38%, rgba(255,255,255,0) 68%);
}

.wrap { max-width: 720px; margin: 0 auto; padding: 20px; position: relative; z-index: 1; }

/* En-tete */
.brand {
  display: flex; align-items: center; gap: 10px;
  justify-content: center; margin: 24px 0 8px;
}
.brand h1 { font-size: 1.9rem; margin: 0; letter-spacing: -0.5px; }
.brand .dot { color: var(--coral); }
.tagline { text-align: center; color: var(--muted); margin: 0 0 28px; }

/* Gros boutons de choix (accueil) */
.choices { display: grid; gap: 16px; }
.big-btn {
  display: flex; align-items: center; gap: 16px;
  width: 100%; padding: 22px 24px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px) saturate(1.1);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius); box-shadow: var(--shadow);
  font-size: 1.25rem; font-weight: 600; color: var(--ink);
  cursor: pointer; transition: transform .12s, border-color .12s;
  text-align: left;
}
.big-btn:hover { transform: translateY(-2px); border-color: var(--teal-light); }
.big-btn .emoji { font-size: 2rem; line-height: 1; }
.big-btn .sub { display: block; font-size: .9rem; font-weight: 400; color: var(--muted); }

.step-title { text-align: center; font-size: 1.1rem; color: var(--teal-dark); margin: 8px 0 20px; font-weight: 600; }
.back { background: none; border: none; color: var(--teal); cursor: pointer; font-size: .95rem; padding: 8px 0; }
.hidden { display: none !important; }

/* Boutons generiques */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 18px; border-radius: 12px; border: none;
  font-size: 1rem; font-weight: 600; cursor: pointer;
  background: var(--teal); color: #fff;
}
.btn:hover { background: var(--teal-dark); }
.btn.secondary { background: var(--sand-dark); color: var(--ink); }
.btn.coral { background: var(--coral); }
.btn.ghost { background: transparent; color: var(--teal); border: 1px solid var(--teal-light); }
.btn.sm { padding: 6px 12px; font-size: .85rem; }

/* Cartes / sections */
.card {
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(10px) saturate(1.1);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
}
.card h3 { margin: 0 0 12px; }

/* Grille de sections (locataire) */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tile {
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(10px) saturate(1.1);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 26px 16px; text-align: center; cursor: pointer; border: 1px solid rgba(255, 255, 255, 0.65);
  transition: border-color .12s, transform .12s;
}
.tile:hover { border-color: var(--teal-light); transform: translateY(-2px); }
.tile .emoji { font-size: 2.4rem; display: block; margin-bottom: 8px; }
.tile .label { font-weight: 600; }

/* Formulaires */
label { display: block; font-size: .9rem; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid #d5ddd9; border-radius: 10px;
  font-size: 1rem; font-family: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--teal-light); border-color: var(--teal-light); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 120px; }

/* Onglets — ils PASSENT A LA LIGNE plutot que de deborder hors de l'ecran
   (avec 7 onglets, un defilement horizontal les rendait invisibles sur telephone). */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; padding-bottom: 4px; }
.tab {
  padding: 10px 14px; border-radius: 10px; background: var(--sand); border: none;
  cursor: pointer; white-space: nowrap; font-weight: 600; color: var(--muted); font-size: .95rem;
}
.tab.active { background: var(--teal); color: #fff; }
@media (max-width: 480px) {
  .tabs { gap: 5px; }
  .tab { padding: 9px 11px; font-size: .85rem; flex: 1 1 auto; text-align: center; }
}

/* Listes / taches / depenses */
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px; border-bottom: 1px solid #eee; }
.list-item:last-child { border-bottom: none; }
.list-item .grow { flex: 1; }
.list-item.done .grow { text-decoration: line-through; color: var(--muted); }
.check { width: 22px; height: 22px; cursor: pointer; }

/* Badges / legende calendrier */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.badge.loue { background: #fde2e1; color: var(--danger); }
.badge.menage { background: #fff1cf; color: #8a6d00; }
.badge.perso { background: #e3e7e7; color: var(--muted); }
.badge.libre { background: #dcf3e6; color: var(--ok); }
.badge.pending { background: #fff1cf; color: #8a6d00; }

.legend { display: flex; gap: 12px; flex-wrap: wrap; margin: 8px 0 16px; font-size: .85rem; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; }
.sw-libre { background: #dcf3e6; border: 1px solid var(--ok); }
.sw-loue { background: #f7b4b0; }
.sw-menage { background: #ffd66b; }
.sw-perso { background: #cfd6d6; }

/* Calendrier mensuel */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-grid .dow { text-align: center; font-size: .75rem; color: var(--muted); font-weight: 600; padding: 4px 0; }
.cal-cell { aspect-ratio: 1; border-radius: 8px; background: #eef2f1; display: flex; align-items: flex-start; justify-content: flex-end; padding: 4px; font-size: .8rem; color: var(--muted); }
.cal-cell.loue { background: #f7b4b0; color: #5a1a1a; }
.cal-cell.menage { background: #ffd66b; color: #5a4600; }
.cal-cell.perso { background: #cfd6d6; }
.cal-cell.empty { background: transparent; }

.msg { padding: 10px 14px; border-radius: 10px; margin: 10px 0; font-size: .92rem; }
.msg.ok { background: #dcf3e6; color: #14622f; }
.msg.err { background: #fbe0e1; color: #8a2a2e; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.muted { color: var(--muted); font-size: .9rem; }
.media { max-width: 100%; border-radius: 12px; margin-top: 8px; }

/* ===== Galerie photo plein ecran ===== */
.gallery {
  position: fixed; inset: 0; z-index: 1000; background: #000;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  touch-action: none; overscroll-behavior: contain;
}
.gallery-stage {
  position: absolute; inset: 0;
  background-position: center; background-repeat: no-repeat; background-size: contain;
  transition: filter .25s ease, opacity .2s ease;
  -webkit-user-drag: none;
}
/* Floutage quand l'app passe en arriere-plan (deter capture) */
.gallery.blurred .gallery-stage { filter: blur(34px) brightness(.7); }
/* Couche transparente au-dessus de l'image : capte l'appui long / clic droit */
.gallery-guard { position: absolute; inset: 0; -webkit-touch-callout: none; }
.gallery-close, .gallery-nav {
  position: absolute; z-index: 2; border: none; cursor: pointer; color: #fff;
  background: rgba(0, 0, 0, .42); backdrop-filter: blur(4px);
  border-radius: 999px; display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.gallery-close { top: 16px; right: 16px; width: 44px; height: 44px; font-size: 1.2rem; }
.gallery-nav { top: 50%; transform: translateY(-50%); width: 52px; height: 52px; font-size: 2rem; }
.gallery-nav.prev { left: 12px; }
.gallery-nav.next { right: 12px; }
.gallery-counter {
  position: absolute; z-index: 2; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: rgba(0, 0, 0, .5); color: #fff; padding: 6px 16px; border-radius: 999px; font-size: .9rem;
}
@media (hover: none) { .gallery-nav { opacity: .55; } }

/* ===== Bouton « Installer l'app » (PWA) ===== */
.pwa-install-btn {
  position: fixed; z-index: 900; left: 50%; transform: translateX(-50%); bottom: 18px;
  padding: 12px 22px; border: none; border-radius: 999px; cursor: pointer;
  background: var(--teal); color: #fff; font-size: 1rem; font-weight: 600;
  font-family: inherit; box-shadow: 0 8px 24px rgba(18, 116, 117, .38);
}
.pwa-install-btn:hover { background: var(--teal-dark); }

/* ===== Fenetre de revelation d'un code / Wi-Fi ===== */
.reveal {
  position: fixed; inset: 0; z-index: 1100; background: rgba(0, 0, 0, .55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.reveal-card {
  position: relative; background: #fff; border-radius: 18px; width: 100%; max-width: 460px;
  padding: 24px 22px; max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .4);
}
.reveal-close {
  position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border: none;
  border-radius: 999px; background: var(--sand-dark); cursor: pointer; font-size: 1rem;
}
.reveal-photo { width: 100%; aspect-ratio: 16 / 10; border-radius: 12px; margin-bottom: 14px;
  background: #e6ddca center center / cover no-repeat; }
.reveal-card h3 { margin: 0 0 14px; padding-right: 34px; }
.reveal-secret { text-align: center; margin: 6px 0 4px; }
.reveal-code {
  font-size: 2.6rem; font-weight: 800; letter-spacing: 4px; color: var(--teal-dark);
  background: var(--sand); border-radius: 12px; padding: 18px 12px; word-break: break-all;
}
.reveal-code.muted { font-size: 1.05rem; font-weight: 600; letter-spacing: normal; }
.reveal-row { font-size: 1.2rem; margin: 8px 0; }
.reveal-row strong { font-size: 1.35rem; letter-spacing: 1px; color: var(--teal-dark); word-break: break-all; }
.reveal-countdown { margin-top: 12px; color: var(--muted); font-size: .85rem; }
.reveal-note {
  background: #fff6e5; border-left: 4px solid var(--warn); border-radius: 8px;
  padding: 12px 14px; font-size: .92rem; margin-top: 14px; line-height: 1.5;
}
.reveal-note.extra { background: #e9f5f5; border-left-color: var(--teal-light); }

/* ===== Grille de vignettes (gestion des photos, cote proprio) ===== */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.photo-thumb {
  position: relative; aspect-ratio: 1; border-radius: 10px; cursor: pointer; overflow: hidden;
  background: #e6ddca center center / cover no-repeat; box-shadow: 0 2px 8px rgba(0, 0, 0, .14);
}
.thumb-del {
  position: absolute; top: 4px; right: 4px; z-index: 2; width: 24px; height: 24px; border: none;
  border-radius: 999px; background: rgba(208, 69, 76, .92); color: #fff; cursor: pointer; font-size: .75rem; line-height: 1;
}
.thumb-num {
  position: absolute; bottom: 3px; left: 6px; color: #fff; font-size: .72rem; font-weight: 600;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
}
