/* Terra Nostra — Design System */
:root {
  --green-dark:  #1B5E20;
  --green-mid:   #2E7D32;
  --green-lite:  #4CAF50;
  --gold:        #F9A825;
  --gold-dark:   #F57F17;
  --white:       #FFFFFF;
  --bg:          #F4F6F0;
  --card-bg:     #FFFFFF;
  --text:        #1C1C1C;
  --muted:       #607D8B;
  --border:      #DDE3D8;
  --danger:      #C62828;
  --radius:      12px;
  --shadow:      0 2px 12px rgba(0,0,0,0.10);
}

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

html, body { height: 100%; font-family: 'Segoe UI', Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 16px; }

/* ── Layout ── */
#app { display: flex; flex-direction: column; height: 100vh; }

.header {
  background: var(--green-dark);
  color: var(--white);
  padding: 0.9rem 1rem;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.header__logo { font-size: 1.25rem; font-weight: 700; letter-spacing: 0.02em; }
.header__logo span { color: var(--gold); }
.header__sub { font-size: 0.7rem; opacity: 0.75; margin-top: 1px; }
.header__user { font-size: 0.8rem; opacity: 0.85; text-align: right; }

.main { flex: 1; overflow-y: auto; }

/* ── Bottom nav ── */
.bottom-nav {
  background: var(--green-dark);
  display: flex; justify-content: space-around;
  padding: 0.5rem 0 calc(0.5rem + env(safe-area-inset-bottom));
  position: sticky; bottom: 0; z-index: 100;
}
.nav-btn {
  display: flex; flex-direction: column; align-items: center;
  color: rgba(255,255,255,0.65); font-size: 0.65rem; padding: 0.3rem 0.5rem;
  border: none; background: none; cursor: pointer; transition: color 0.2s;
  gap: 3px;
}
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn.active, .nav-btn:hover { color: var(--gold); }

/* ── Pages ── */
.page { display: none; padding: 1rem; animation: fadeIn 0.2s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── Cartes ── */
.card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 1.1rem 1rem; margin-bottom: 1rem;
  box-shadow: var(--shadow); border: 1px solid var(--border);
}
.card__title { font-size: 1rem; font-weight: 700; color: var(--green-dark); margin-bottom: 0.6rem; }
.card__meta { font-size: 0.8rem; color: var(--muted); margin-top: 0.3rem; }

/* ── Champs ── */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--green-dark); margin-bottom: 0.35rem; }
.field input, .field select, .field textarea {
  width: 100%; padding: 0.7rem 0.9rem;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 0.95rem; background: #FAFAFA; transition: border-color 0.2s;
  font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--green-mid); background: var(--white);
}

/* ── Boutons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.75rem 1.2rem; border-radius: 8px; font-size: 0.95rem; font-weight: 600;
  cursor: pointer; border: none; transition: all 0.2s; width: 100%; text-align: center;
}
.btn--primary { background: var(--green-dark); color: var(--white); }
.btn--primary:hover { background: var(--green-mid); }
.btn--gold { background: var(--gold); color: #1A1A00; }
.btn--gold:hover { background: var(--gold-dark); }
.btn--outline { background: transparent; color: var(--green-dark); border: 2px solid var(--green-dark); }
.btn--danger { background: var(--danger); color: var(--white); }
.btn--sm { padding: 0.45rem 0.9rem; font-size: 0.82rem; width: auto; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Badge statut ── */
.badge {
  display: inline-block; padding: 0.2rem 0.6rem; border-radius: 20px;
  font-size: 0.72rem; font-weight: 600;
}
.badge--en_cours  { background: #FFF8E1; color: #F57F17; }
.badge--valide    { background: #E8F5E9; color: #2E7D32; }
.badge--soumis    { background: #E3F2FD; color: #1565C0; }
.badge--gratuit   { background: #F3E5F5; color: #6A1B9A; }
.badge--en_attente{ background: #FFF8E1; color: #F57F17; }
.badge--paye      { background: #E8F5E9; color: #2E7D32; }

/* ── GPS tracker ── */
.gps-panel {
  background: var(--green-dark); color: var(--white);
  border-radius: var(--radius); padding: 1.2rem; margin-bottom: 1rem; text-align: center;
  width: 100%; box-sizing: border-box;
}
.gps-panel__count { font-size: 3rem; font-weight: 700; color: var(--gold); line-height: 1; }
.gps-panel__label { font-size: 0.8rem; opacity: 0.8; margin-top: 0.3rem; }
.gps-panel__surface { font-size: 1.1rem; font-weight: 600; margin-top: 0.5rem; }
.gps-panel__precision { font-size: 0.75rem; opacity: 0.7; margin-top: 0.2rem; }
.pulse { animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ── Carte Leaflet ── */
#map { height: 320px; width: 100%; border-radius: var(--radius); border: 2px solid var(--border); margin-bottom: 1rem; }
#map-detail { height: 250px; border-radius: var(--radius); border: 2px solid var(--border); margin-bottom: 1rem; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(20px);
  padding: 0.75rem 1.4rem; border-radius: 8px; font-size: 0.9rem; font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2); opacity: 0; transition: all 0.3s; z-index: 9999;
  max-width: calc(100vw - 2rem); text-align: center; pointer-events: none;
}
.toast--visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast--info    { background: #1B5E20; color: #fff; }
.toast--succes  { background: #2E7D32; color: #fff; }
.toast--erreur  { background: #C62828; color: #fff; }
.toast--warning { background: #F57F17; color: #fff; }

/* ── Loader ── */
.loader {
  display: flex; align-items: center; justify-content: center;
  padding: 2rem; color: var(--muted); font-size: 0.9rem; gap: 0.6rem;
}
.loader::before {
  content: ''; width: 18px; height: 18px;
  border: 2.5px solid var(--border); border-top-color: var(--green-dark);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Stat cards ── */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 1rem; }
.stat-card { background: var(--card-bg); border-radius: var(--radius); padding: 0.9rem; text-align: center; box-shadow: var(--shadow); border: 1px solid var(--border); }
.stat-card__val { font-size: 2rem; font-weight: 700; color: var(--green-dark); }
.stat-card__lbl { font-size: 0.72rem; color: var(--muted); margin-top: 0.2rem; }

/* ── Page connexion ── */
.auth-screen { min-height: 100vh; background: var(--green-dark); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-screen__logo { color: var(--white); font-size: 2rem; font-weight: 700; margin-bottom: 0.3rem; }
.auth-screen__logo span { color: var(--gold); }
.auth-screen__tagline { color: rgba(255,255,255,0.7); font-size: 0.85rem; margin-bottom: 2rem; text-align: center; }
.auth-box { background: var(--white); border-radius: 16px; padding: 1.5rem; width: 100%; max-width: 380px; box-shadow: 0 8px 32px rgba(0,0,0,0.25); }
.auth-box__title { font-size: 1.1rem; font-weight: 700; color: var(--green-dark); margin-bottom: 1.2rem; text-align: center; }
.auth-toggle { text-align: center; margin-top: 1rem; font-size: 0.85rem; color: var(--muted); }
.auth-toggle a { color: var(--green-dark); font-weight: 600; cursor: pointer; text-decoration: underline; }

/* ── Divider ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ── Paiement ── */
.operateurs { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.operateur-btn {
  flex: 1; padding: 0.6rem 0.4rem; border: 2px solid var(--border);
  border-radius: 8px; font-size: 0.8rem; font-weight: 600; cursor: pointer;
  background: var(--white); transition: all 0.2s; text-align: center;
}
.operateur-btn.selected { border-color: var(--green-dark); background: var(--green-dark); color: var(--white); }

/* ── Page titre ── */
.page-title { font-size: 1.1rem; font-weight: 700; color: var(--green-dark); margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem; }

/* ── Liste parcelles ── */
.parcelle-item { display: flex; justify-content: space-between; align-items: flex-start; padding: 0.8rem 0; border-bottom: 1px solid var(--border); }
.parcelle-item:last-child { border-bottom: none; }
.parcelle-item__code { font-size: 0.9rem; font-weight: 700; color: var(--green-dark); font-family: monospace; }
.parcelle-item__detail { font-size: 0.78rem; color: var(--muted); margin-top: 0.2rem; }

/* ── Responsive ── */
@media (min-width: 500px) {
  .main { max-width: 480px; margin: 0 auto; }
  .bottom-nav { max-width: 480px; margin: 0 auto; }
  .header { max-width: 100%; }
}

/* Animation point de position GPS temps réel */
@keyframes positionPulse {
  0%   { box-shadow: 0 0 0 0 rgba(21, 101, 192, 0.5); }
  70%  { box-shadow: 0 0 0 10px rgba(21, 101, 192, 0); }
  100% { box-shadow: 0 0 0 0 rgba(21, 101, 192, 0); }
}

/* ── Page nouvelle parcelle — pleine largeur ── */
#page-nouvelle { padding: 0.75rem 0.5rem; }
#page-nouvelle #map { border-radius: 8px; }
#page-nouvelle .gps-panel { margin-left: 0; margin-right: 0; }
#page-nouvelle > div[style*="display:flex"] { padding: 0 0.25rem; }
#form-parcelle .card { margin-top: 0.5rem; }