/* L'attribut `hidden` DOIT gagner contre tout `display` posé par une classe.
   Sans cette règle, .login-view et .app-view (display: flex) restaient affichées
   même cachées — connexion réussie, écran inchangé, « il ne se passe rien ». */
[hidden] { display: none !important; }

/* Target in Paris — curation. Sombre, une couleur d'accent, cartes arrondies. */

:root {
  --bg: #121214;
  --bg-elevated: #19191c;
  --bg-card: #1e1f23;
  --bg-input: #232429;
  --border: #2c2d33;
  --border-soft: #26272c;
  --text: #f2f1ee;
  --text-dim: #a2a1ab;
  --text-faint: #6f6e78;

  --accent: #ff5d3b;
  --accent-dim: rgba(255, 93, 59, 0.16);
  --accent-strong: #ff7a5c;

  --success: #35c46c;
  --success-dim: rgba(53, 196, 108, 0.16);
  --warning: #f0a93b;
  --warning-dim: rgba(240, 169, 59, 0.16);
  --danger: #e5484d;
  --danger-dim: rgba(229, 72, 77, 0.16);
  --neutral-dim: rgba(160, 160, 170, 0.14);

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

h1, h2, h3, p { margin: 0; }

button {
  font-family: inherit;
}

/* ---------- Boutons ---------- */

.btn {
  appearance: none;
  border: none;
  border-radius: var(--radius-md);
  padding: 11px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.15s ease, background 0.15s ease;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }

.btn-primary {
  background: var(--accent);
  color: #1a0d08;
}
.btn-primary:active { background: var(--accent-strong); }

.btn-secondary {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--danger);
  color: #2a0a0b;
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-lg { padding: 15px 18px; font-size: 16px; }

/* ---------- Champs de formulaire ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 18px;
}

.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
}

.input, .textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  padding: 12px 14px;
  font-size: 16px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s ease;
}
.input:focus, .textarea:focus {
  border-color: var(--accent);
}
.textarea {
  resize: vertical;
  font-family: inherit;
  min-height: 72px;
}

.form-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 4px;
}

/* ---------- Écran de connexion ---------- */

.login-view {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
}

.login-sub {
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  margin-top: 4px;
  margin-bottom: 22px;
}

/* ---------- Structure app ---------- */

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.tabs {
  display: flex;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 57px;
  z-index: 5;
  overflow-x: auto;
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 13px 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-badge {
  background: var(--accent);
  color: #1a0d08;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  min-width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.content {
  flex: 1;
  padding: 16px;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.empty-state {
  color: var(--text-faint);
  text-align: center;
  padding: 40px 20px;
  font-size: 14px;
}

/* ---------- Cartes lieu ---------- */

.cards-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.card-name {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
}

.card-name.is-empty {
  color: var(--text-faint);
  font-style: italic;
  font-weight: 500;
}

.card-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.role-pill {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--neutral-dim);
  color: var(--text-dim);
  white-space: nowrap;
}

.notoriety-dots {
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--accent);
  white-space: nowrap;
}
.notoriety-dots .dim { color: var(--border); }

.card-what {
  color: var(--text);
  font-size: 14px;
  margin-bottom: 4px;
}

.card-why {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 10px;
}

.card-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.chip-tag {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.card-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.geo-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.geo-coherent { background: var(--success-dim); color: var(--success); }
.geo-eloigne { background: var(--warning-dim); color: var(--warning); }
.geo-neutral { background: var(--neutral-dim); color: var(--text-dim); }

.card-owner {
  font-size: 12px;
  color: var(--text-faint);
}

.card-actions {
  display: flex;
  gap: 10px;
}

.card-actions .btn { flex: 1; }

/* ---------- Formulaire d'ajout / champs composés ---------- */

.address-search-wrap {
  position: relative;
}

.address-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  z-index: 10;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.address-suggestion-item {
  padding: 12px 14px;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-soft);
}
.address-suggestion-item:last-child { border-bottom: none; }
.address-suggestion-item:active { background: var(--accent-dim); }

.address-selected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--accent-dim);
  border: 1px solid rgba(255, 93, 59, 0.35);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-top: 8px;
}

.address-selected-text {
  font-size: 14px;
  color: var(--text);
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  appearance: none;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.chip-selected {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent-strong);
  font-weight: 600;
}

.custom-tag-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.custom-tag-row .input { flex: 1; }

.notoriety-field {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.notoriety-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: transparent;
  cursor: pointer;
  position: relative;
}
.notoriety-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
}
.notoriety-dot.active {
  border-color: var(--accent);
}
.notoriety-dot.active::after {
  background: var(--accent);
}

.notoriety-label {
  font-size: 13px;
  color: var(--text-dim);
  margin-left: 6px;
}

.role-field {
  display: flex;
  gap: 8px;
}

.role-btn {
  flex: 1;
  padding: 11px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.role-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent-strong);
}

/* ---------- Champ "Adresse ou lien Google Maps" ---------- */

.field-help {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: -2px;
}

.link-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--success-dim);
  color: var(--success);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: var(--radius-md);
  margin-top: 8px;
  width: fit-content;
}

.tech-details {
  margin-top: 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 2px 12px;
  background: var(--bg-elevated);
}

.tech-details summary {
  cursor: pointer;
  padding: 10px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  list-style: revert;
}

.tech-details[open] summary {
  color: var(--text);
}

.lat-lon-row {
  display: flex;
  gap: 10px;
  padding-bottom: 12px;
}
.lat-lon-row .field { flex: 1; margin-bottom: 0; }

/* ---------- Thèmes / tags (formulaire) ---------- */

.tags-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tags-subtitle {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 6px;
}

.chip-tag.removable {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-right: 6px;
}

.chip-remove {
  appearance: none;
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 50%;
}
.chip-remove:active { background: var(--danger-dim); color: var(--danger); }

.tag-suggestions .chip {
  opacity: 0.85;
}

/* ---------- Notoriété : mention "estimé d'après N avis" ---------- */

.notoriety-dots-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.notoriety-hint {
  font-size: 12px;
  color: var(--text-faint);
  font-style: italic;
  margin-top: 6px;
}

/* ---------- Onglet Thèmes & tags ---------- */

.mgmt-section {
  margin-bottom: 28px;
}

.mgmt-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.mgmt-section h2 {
  font-size: 16px;
  font-weight: 700;
}

.mgmt-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.mgmt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.mgmt-row-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.mgmt-row-info strong {
  font-size: 14px;
}

.mgmt-row-meta {
  font-size: 12px;
  color: var(--text-faint);
  overflow-wrap: anywhere;
}

.mgmt-row-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.tags-mgmt-list {
  margin-top: 12px;
  margin-bottom: 12px;
}

/* ---------- Toasts ---------- */

.toasts {
  position: fixed;
  bottom: 20px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
  padding: 0 16px;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: 480px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success { border-color: rgba(53, 196, 108, 0.5); }
.toast-error { border-color: rgba(229, 72, 77, 0.5); }

/* ---------- Dialogues maison ---------- */

.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 500;
  padding: 0;
  animation: fade-in 0.15s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.dialog-box {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}

.dialog-box-lg {
  max-width: 560px;
}

.dialog-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 14px;
}

.dialog-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dialog-message {
  font-size: 15px;
  color: var(--text);
  margin-bottom: 12px;
  line-height: 1.4;
}

.dialog-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: -8px;
  margin-bottom: 8px;
}

.dialog-footer {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.dialog-footer .btn { flex: 1; }

@media (min-width: 560px) {
  .dialog-overlay {
    align-items: center;
  }
  .dialog-box {
    border-radius: var(--radius-lg);
  }
}
