/* =============================================================
   Carnet de voyage — app.css (composants)
   Aucune couleur en dur : tout référence css/tokens.css.
   ============================================================= */

* { box-sizing: border-box; }

/* Priorité explicite sur les classes display:flex ci-dessous, sinon l'attribut
   [hidden] (spécificité UA) est écrasé par les règles auteur de même poids. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page-bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -.01em;
  margin: 0 0 .35rem;
}

a { color: inherit; }

/* ── Eyebrow (label au-dessus des titres) ─────────────────────────────── */
.eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--sunset);
  margin-bottom: .5rem;
}

/* ── App shell ─────────────────────────────────────────────────────────── */
.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app-main {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 6rem;
}

.app-view { display: none; }
.app-view.is-active { display: block; }

/* ── En-tête avec forme organique décorative ─────────────────────────────── */
.hero {
  position: relative;
  overflow: hidden;
  padding: 1.5rem 0 2rem;
  isolation: isolate;
}
.hero::before {
  content: '';
  position: absolute;
  z-index: -1;
  top: -90px;
  right: -70px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: var(--sand);
}

/* ── Cartes ───────────────────────────────────────────────────────────── */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.25rem;
}
.card--sand  { background: var(--sand);  border-color: transparent; }
.card--sky   { background: var(--sky);   border-color: transparent; }
.card--terra { background: var(--terra); border-color: transparent; }

/* ── Boutons ──────────────────────────────────────────────────────────── */
.btn-primary, .btn-secondary, .btn-danger, .btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  border: none;
  border-radius: 100px;
  padding: .75rem 1.5rem;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: .92rem;
  cursor: pointer;
  min-height: 44px;
}
.btn-primary {
  background: var(--ink);
  color: #fff;
  box-shadow: 0 6px 16px rgba(43, 38, 32, .18), 0 2px 4px rgba(43, 38, 32, .1);
}
.btn-secondary {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-icon {
  min-height: 44px;
  min-width: 44px;
  padding: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 1.05rem;
}
.btn-primary:active, .btn-secondary:active, .btn-danger:active, .btn-icon:active { transform: translateY(1px); }
.btn-primary:disabled, .btn-secondary:disabled, .btn-danger:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}
.btn-block { width: 100%; }

/* ── Formulaires ──────────────────────────────────────────────────────── */
.form-field {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin-bottom: 1rem;
}
.form-field label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}
.form-field input,
.form-field select,
.form-field textarea {
  font-family: var(--font-body);
  font-size: .95rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .65rem .8rem;
  min-height: 44px;
}
.form-field textarea { min-height: 88px; resize: vertical; }
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--sunset);
  box-shadow: 0 0 0 4px var(--focus-ring);
}
.form-field .field-hint { color: var(--muted); font-size: .78rem; }
.form-error {
  color: var(--danger);
  background: var(--danger-bg);
  border-radius: 10px;
  padding: .6rem .8rem;
  font-size: .85rem;
  margin-bottom: 1rem;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: .6rem;
  margin-top: 1.25rem;
}

/* ── Styles visuels (sélection de 4 vignettes) ───────────────────────────── */
.style-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .6rem;
}
.style-swatch {
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: .6rem .4rem;
  background: var(--paper);
  text-align: center;
  font-size: .7rem;
  color: var(--muted);
  cursor: pointer;
}
.style-swatch .swatch-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  margin: 0 auto .35rem;
}
.style-swatch.is-selected { border-color: var(--sunset); color: var(--ink); background: var(--accent-soft); }
.style-swatch[data-style="classique"] .swatch-dot { background: var(--sunset); }
.style-swatch[data-style="carte-postale"] .swatch-dot { background: var(--sky); }
.style-swatch[data-style="minimal"] .swatch-dot { background: var(--ink); }
.style-swatch[data-style="aventure"] .swatch-dot { background: var(--terra); }

/* ── Modale ───────────────────────────────────────────────────────────── */
body.modal-open { overflow: hidden; }
#modal-root { position: relative; z-index: 100; }
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(43, 38, 32, .42);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 0;
}
.modal-card {
  background: var(--paper);
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 30px rgba(43, 38, 32, .22);
}
.modal-card--wide { max-width: 760px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--paper);
}
.modal-header h2 {
  font-size: 1.15rem;
  margin: 0;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  color: var(--muted);
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
}
.modal-body { padding: 1.25rem; }

@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
  .modal-card { border-radius: 20px; }
}

/* ── Confirmation ─────────────────────────────────────────────────────── */
.confirm-dialog p { color: var(--ink); margin: 0 0 1.25rem; }
.confirm-actions { display: flex; justify-content: flex-end; gap: .6rem; }

/* ── Notices (toasts) ─────────────────────────────────────────────────── */
.toast-stack {
  position: fixed;
  left: 50%;
  bottom: calc(5.5rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: .5rem;
  z-index: 200;
  width: min(92vw, 420px);
}
.toast {
  background: var(--ink);
  color: #fff;
  border-radius: 12px;
  padding: .75rem 1rem;
  font-size: .85rem;
  box-shadow: 0 8px 24px rgba(43, 38, 32, .25);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
  border-left: 4px solid var(--sunset);
}
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast--error { border-left-color: var(--danger); }
.toast--success { border-left-color: var(--sunset); }

@media (min-width: 1024px) {
  .toast-stack { bottom: 1.5rem; }
}

/* ── Squelettes de chargement ─────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(100deg, var(--line) 30%, var(--paper) 50%, var(--line) 70%);
  background-size: 220% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
  border-radius: 12px;
}
@keyframes skeleton-shimmer {
  0% { background-position: 140% 0; }
  100% { background-position: -40% 0; }
}

/* ── Cartes voyage (onglet Voyages) ───────────────────────────────────── */
.view-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
}
.trip-list {
  display: grid;
  gap: 1rem;
}
.trip-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  cursor: pointer;
}
.trip-card__cover {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--sand);
  display: block;
}
.trip-card__cover-fallback {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--sand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}
.trip-card__body { padding: 1rem 1.1rem 1.1rem; }
.trip-card__title { font-size: 1.1rem; margin: 0 0 .15rem; }
.trip-card__meta {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 .75rem;
}
.trip-card__stats {
  display: flex;
  flex-wrap: wrap;
  gap: .9rem;
  font-size: .8rem;
  color: var(--ink);
}
.trip-card__stat { display: inline-flex; align-items: center; gap: .3rem; }
.trip-card__modes { display: flex; gap: .3rem; margin-top: .6rem; font-size: 1rem; }
.trip-card__actions {
  display: flex;
  gap: .5rem;
  padding: 0 1.1rem 1.1rem;
}

.cover-picker { display: flex; align-items: center; gap: .9rem; }
.cover-picker__preview {
  width: 84px;
  height: 84px;
  border-radius: 14px;
  object-fit: cover;
  background: var(--sand);
  flex-shrink: 0;
}

/* ── Onglet Carte ─────────────────────────────────────────────────────── */
.map-view-body { display: flex; flex-direction: column; gap: 1rem; }
.trip-picker { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.trip-picker select { flex: 1; min-width: 160px; }

#map-container {
  position: relative;
  width: 100%;
  height: min(58dvh, 520px);
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--sky);
}
#map-canvas { position: absolute; inset: 0; }

.map-toolbar {
  position: absolute;
  top: .75rem;
  right: .75rem;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  align-items: flex-end;
}
.map-hint {
  position: absolute;
  bottom: .75rem;
  left: .75rem;
  right: .75rem;
  z-index: 5;
  background: rgba(255, 252, 247, .88);
  backdrop-filter: blur(6px);
  border-radius: 12px;
  padding: .5rem .75rem;
  font-size: .75rem;
  color: var(--muted);
  text-align: center;
}

.map-search { position: relative; width: min(70vw, 260px); }
.map-search input {
  width: 100%;
  font-family: var(--font-body);
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: .6rem 1rem;
  min-height: 44px;
  background: var(--paper);
}
.map-search-results {
  position: absolute;
  top: calc(100% + .35rem);
  left: 0;
  right: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(43, 38, 32, .16);
  max-height: 260px;
  overflow-y: auto;
}
.map-search-results button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: .65rem .85rem;
  font-size: .82rem;
  color: var(--ink);
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.map-search-results button:last-child { border-bottom: none; }
.map-search-results button:hover { background: var(--accent-soft); }

.marker-pin {
  width: 30px;
  height: 30px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--sunset);
  box-shadow: 0 3px 8px rgba(43, 38, 32, .3);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--paper);
  cursor: pointer;
}
.marker-pin span {
  transform: rotate(45deg);
  color: #fff;
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 600;
}
.marker-pin--geoloc {
  background: var(--sky);
  border-color: var(--ink);
}

.mode-legend { display: flex; flex-wrap: wrap; gap: .5rem; }
.mode-chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  background: var(--sand);
  border-radius: 100px;
  padding: .3rem .7rem;
  font-size: .75rem;
  color: var(--ink);
}

.stops-panel { display: flex; flex-direction: column; gap: .6rem; }
.stop-row {
  display: flex;
  align-items: center;
  gap: .65rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: .65rem .8rem;
}
.stop-row__num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--sunset);
  color: #fff;
  font-family: var(--font-mono);
  font-size: .72rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stop-row__body { flex: 1; min-width: 0; }
.stop-row__name { font-weight: 600; }
.stop-row__meta { color: var(--muted); font-size: .75rem; }
.stop-row__actions { display: flex; gap: .25rem; }
.stop-row__actions button {
  min-height: 34px;
  min-width: 34px;
  padding: 0;
}

/* ── Fiche étape (dans la modale) ─────────────────────────────────────── */
.tag-chip-list { display: flex; flex-wrap: wrap; gap: .5rem; }
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  background: var(--sand);
  border: 1px solid transparent;
  border-radius: 100px;
  padding: .4rem .85rem;
  font-size: .8rem;
  color: var(--ink);
  cursor: pointer;
}
.tag-chip.is-selected { background: var(--accent-soft); border-color: var(--accent-line); color: var(--sunset); font-weight: 600; }

.stop-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: .5rem;
}
.stop-photos img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  background: var(--sand);
}

.section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  display: block;
  margin: 1.1rem 0 .5rem;
}
.section-label:first-child { margin-top: 0; }

/* ── Onglet Journal ───────────────────────────────────────────────────── */
.journal-toolbar {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.journal-toolbar select { flex: 1; min-width: 160px; }

.sync-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
  background: var(--sand);
  border-radius: 14px;
  padding: .75rem 1rem;
  margin-bottom: 1.25rem;
  font-size: .85rem;
  color: var(--ink);
}

.journal-day { margin-bottom: 1.5rem; }
.journal-day__items {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  margin-bottom: .75rem;
}

.journal-stop {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: .85rem 1rem;
}
.journal-stop__head {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  margin-bottom: .35rem;
}
.journal-stop__name { font-size: 1rem; margin: 0; flex: 1; }
.journal-stop__time {
  font-family: var(--font-mono);
  font-size: .72rem;
  color: var(--muted);
}
.journal-stop__desc { color: var(--ink); font-size: .88rem; margin: 0 0 .6rem; }
.journal-stop .tag-chip-list { margin-bottom: .6rem; }

.journal-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: .85rem;
}
.journal-photo {
  margin: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.journal-photo img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--sand);
  display: block;
}
.journal-photo__caption {
  border: none;
  border-top: 1px solid var(--line);
  border-radius: 0;
  font-size: .8rem;
  padding: .5rem .65rem;
  min-height: 38px;
  background: var(--paper);
  color: var(--ink);
}
.journal-photo__stop {
  border: none;
  border-top: 1px solid var(--line);
  border-radius: 0;
  font-size: .75rem;
  padding: .4rem .65rem;
  min-height: 36px;
  background: var(--paper);
  color: var(--muted);
}
.journal-photo [data-action="delete-photo"] {
  align-self: flex-end;
  margin: .4rem .5rem .5rem 0;
}

/* ── États vides ──────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: .85rem;
  padding: 3rem 1.5rem;
}
.empty-state .empty-icon {
  font-size: 2.4rem;
  line-height: 1;
}
.empty-state p {
  color: var(--muted);
  max-width: 32ch;
  margin: 0;
}

/* ── Écran de connexion ───────────────────────────────────────────────── */
.login-gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--page-bg);
}
.login-card {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  width: 100%;
  max-width: 380px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 2rem 1.75rem;
}
.login-card::before {
  content: '';
  position: absolute;
  z-index: -1;
  top: -80px;
  right: -60px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: var(--sand);
}
.login-card h1 { margin-bottom: 1.25rem; }

/* ── Navigation basse (mobile) ────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: .5rem .25rem calc(.5rem + env(safe-area-inset-bottom));
  background: rgba(255, 252, 247, .78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  z-index: 10;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2rem;
  background: none;
  border: none;
  font-family: var(--font-body);
  font-size: .68rem;
  color: var(--muted);
  padding: .25rem .5rem;
  cursor: pointer;
}
.nav-item .nav-icon { font-size: 1.15rem; }
.nav-item.is-active { color: var(--sunset); }

/* ── Barre latérale (desktop ≥ 1024px) ───────────────────────────────── */
.sidebar { display: none; }

@media (min-width: 1024px) {
  .app-shell { flex-direction: row; }

  .sidebar {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    width: 220px;
    flex-shrink: 0;
    padding: 1.5rem 1rem;
    background: var(--paper);
    border-right: 1px solid var(--line);
    min-height: 100dvh;
  }
  .sidebar .brand {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.1rem;
    margin: .5rem .5rem 1.5rem;
  }
  .sidebar .nav-item {
    flex-direction: row;
    justify-content: flex-start;
    font-size: .85rem;
    padding: .6rem .75rem;
    border-radius: 10px;
    width: 100%;
  }
  .sidebar .nav-item .nav-icon { font-size: 1.05rem; }
  .sidebar .nav-item.is-active { background: var(--accent-soft); color: var(--sunset); }

  .bottom-nav { display: none; }

  .app-main {
    max-width: 760px;
    padding: 2.5rem 3rem;
    margin: 0;
  }
}
