/* LogeRadar — interface conviviale (thème clair Côte d’Azur) */

@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,600;9..144,700&family=Figtree:wght@400;500;600;700&display=swap");

:root {
  --bg: #e8f1f5;
  --bg-elevated: #ffffff;
  --bg-soft: #f3f8fa;
  --bg-tint: #d4e8ef;
  --ink: #1a2b33;
  --muted: #5a6f7a;
  --line: #c5d6df;
  --line-soft: #dce8ee;
  --sea: #0b6e7a;
  --sea-deep: #085560;
  --sea-soft: #e0f3f5;
  --sand: #f6a15c;
  --sand-soft: #fff1e3;
  --danger: #c23b3b;
  --danger-soft: #fdeaea;
  --warn: #b86a12;
  --warn-soft: #fff6e8;
  --ok: #0b6e7a;
  --ok-soft: #e0f3f5;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 28px rgba(26, 43, 51, 0.08);
  --shadow-hover: 0 14px 36px rgba(26, 43, 51, 0.12);
  --font: "Figtree", sans-serif;
  --font-display: "Fraunces", Georgia, serif;
  --pad: 1rem;
  --gap: 0.9rem;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 0% 0%, #b8dde8 0%, transparent 55%),
    radial-gradient(800px 380px at 100% 10%, #ffe2c4 0%, transparent 50%),
    linear-gradient(180deg, #eef6f9 0%, var(--bg) 40%, #e3eef3 100%);
  background-attachment: fixed;
}

/* léger motif « vague » */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    repeating-linear-gradient(
      -12deg,
      transparent 0 14px,
      rgba(11, 110, 122, 0.03) 14px 15px
    );
  z-index: 0;
}

a { color: var(--sea); }

.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: none; /* pleine largeur de l’écran */
  margin: 0;
  padding: 1rem var(--pad) 2.5rem;
  padding-left: max(var(--pad), env(safe-area-inset-left));
  padding-right: max(var(--pad), env(safe-area-inset-right));
  padding-bottom: max(2.5rem, env(safe-area-inset-bottom));
}

@media (min-width: 768px) {
  :root { --pad: 1.5rem; }
  .app { padding-top: 1.25rem; }
}

@media (min-width: 1200px) {
  :root { --pad: 2rem; }
}

@media (min-width: 1600px) {
  :root { --pad: 2.5rem; }
}

/* ----- En-tête ----- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.4rem;
  flex-wrap: wrap;
  animation: rise-in 0.55s var(--ease) both;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.user-chip {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--sea-deep);
  background: var(--sea-soft);
  border: 1px solid color-mix(in srgb, var(--sea) 20%, var(--line-soft));
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
}

.brand {
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 3.2vw, 2.45rem);
  font-weight: 700;
  color: var(--sea-deep);
  margin: 0;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.tagline {
  color: var(--muted);
  margin: 0.35rem 0 0;
  font-size: 0.98rem;
  font-weight: 500;
}

/* ----- Vues ----- */

.view { display: none; }
.view.active {
  display: block;
  animation: rise-in 0.45s var(--ease) both;
}

.panel {
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  border: 1px solid var(--line-soft);
  border-radius: calc(var(--radius) + 4px);
  padding: 1.15rem 1.2rem 1.35rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.panel h2 {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 650;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.row {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  align-items: center;
}

.muted { color: var(--muted); }
.small { font-size: 0.9rem; }

/* ----- Boutons ----- */

button, .btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.6rem 1.05rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s ease, border-color 0.2s ease;
}

button:hover, .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(26, 43, 51, 0.1);
}

button:active, .btn:active {
  transform: translateY(0);
}

button.primary, .btn.primary {
  background: var(--sea);
  border-color: var(--sea);
  color: #fff;
}

button.primary:hover, .btn.primary:hover {
  background: var(--sea-deep);
  border-color: var(--sea-deep);
}

button.danger {
  border-color: transparent;
  background: var(--danger-soft);
  color: var(--danger);
}

button.danger:hover {
  background: #f8d4d4;
}

button.ghost {
  background: var(--bg-elevated);
  border-color: var(--line);
  color: var(--ink);
  padding: 0.55rem 0.95rem;
}

button.ghost:hover {
  color: var(--sea-deep);
  border-color: color-mix(in srgb, var(--sea) 40%, var(--line));
  background: var(--sea-soft);
}

/* ----- Formulaires ----- */

label.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--muted);
  min-width: 0;
}

input, select {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.75rem;
  font: inherit;
  font-weight: 500;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--sea);
  box-shadow: 0 0 0 3px rgba(11, 110, 122, 0.15);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
  margin-bottom: 1.1rem;
}

@media (min-width: 560px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 900px) {
  .form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1200px) {
  .form-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ----- Recherches ----- */

#search-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
}

@media (min-width: 640px) {
  #search-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1100px) {
  #search-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1500px) {
  #search-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.search-item {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 1.2rem;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  min-height: 100%;
  box-shadow: 0 4px 14px rgba(26, 43, 51, 0.04);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.2s ease;
  animation: card-in 0.45s var(--ease) both;
}

.search-item:nth-child(2) { animation-delay: 0.05s; }
.search-item:nth-child(3) { animation-delay: 0.1s; }
.search-item:nth-child(4) { animation-delay: 0.15s; }

.search-item:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: color-mix(in srgb, var(--sea) 35%, var(--line-soft));
}

.search-item h3 {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.search-item .search-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 500;
}

.search-item .search-foot {
  margin: 0.45rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.search-item .row {
  margin-top: auto;
  padding-top: 0.15rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--muted);
  border: 1px solid var(--line-soft);
}

.badge.on {
  background: var(--sea-soft);
  color: var(--sea-deep);
  border-color: color-mix(in srgb, var(--sea) 25%, var(--line-soft));
}

.badge.source {
  text-transform: none;
  font-weight: 600;
  background: var(--sand-soft);
  color: #9a5a1a;
  border-color: #f0d4b0;
}

/* ----- Annonces ----- */

#listing-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 700px) {
  #listing-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1100px) {
  #listing-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1500px) {
  #listing-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.listing {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 0;
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(26, 43, 51, 0.05);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
  animation: card-in 0.5s var(--ease) both;
}

.listing:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

.listing-photo {
  display: block;
  aspect-ratio: 16 / 10;
  background: var(--bg-tint);
  overflow: hidden;
  position: relative;
}

.listing-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.45s var(--ease);
}

.listing:hover .listing-photo img {
  transform: scale(1.04);
}

.listing-photo--empty {
  background:
    linear-gradient(145deg, #cfe4ec 0%, #e8f1f5 55%, #f7efe6 100%);
}

.listing-photo--empty::after {
  content: "Pas de photo";
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.listing-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 0.95rem 1.05rem 1.1rem;
  min-height: 0;
  gap: 0.15rem;
}

.listing h3 {
  margin: 0 0 0.5rem;
  font-size: 1.02rem;
  line-height: 1.35;
  font-weight: 650;
}

.listing h3 a {
  text-decoration: none;
  color: var(--ink);
}

.listing h3 a:hover {
  color: var(--sea);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.7rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.85rem;
}

.price {
  color: var(--sea-deep);
  font-weight: 750;
  font-size: 1.12rem;
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}

.listing-body .row {
  margin-top: auto;
}

.listing .field {
  flex: 1 1 auto;
}

.listing .field select {
  border-radius: 999px;
  padding: 0.5rem 0.85rem;
  background: var(--bg-soft);
}

/* ----- Flash / empty / toolbar ----- */

.flash {
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  font-weight: 550;
  animation: rise-in 0.35s var(--ease) both;
}

.flash.warn {
  border-color: #efd2a8;
  background: var(--warn-soft);
  color: var(--warn);
}

.flash.err {
  border-color: #f0c4c4;
  background: var(--danger-soft);
  color: var(--danger);
}

.flash.ok {
  border-color: #b7dde2;
  background: var(--ok-soft);
  color: var(--ok);
}

.empty {
  color: var(--muted);
  padding: 1.6rem 1rem;
  grid-column: 1 / -1;
  text-align: center;
  background: var(--bg-soft);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  font-weight: 500;
}

.empty strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--ink);
  margin-bottom: 0.35rem;
}

.toolbar {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.15rem;
  align-items: center;
  padding: 0.75rem 0.9rem;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
}

.toolbar label.row {
  gap: 0.45rem;
  cursor: pointer;
}

.back {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding-left: 0;
  margin-bottom: 0.65rem;
  font-weight: 600;
  border-radius: 0;
  box-shadow: none;
}

.back:hover {
  color: var(--sea);
  transform: none;
  box-shadow: none;
}

.detail-head {
  margin-bottom: 0.35rem;
}

#detail-meta {
  margin: -0.35rem 0 1rem;
}

/* ----- Animations ----- */

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ----- Mobile / tablette ----- */

@media (max-width: 767px) {
  body {
    background-attachment: scroll; /* plus fluide sur téléphone */
  }

  :root {
    --pad: 0.85rem;
    --radius: 14px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 0.85rem;
    margin-bottom: 1rem;
  }

  .topbar > div {
    min-width: 0;
  }

  .brand {
    font-size: 1.7rem;
  }

  .tagline {
    font-size: 0.9rem;
    line-height: 1.4;
  }

  .topbar > button.primary {
    width: 100%;
    min-height: 48px; /* zone tactile confortable */
    justify-content: center;
  }

  .panel {
    padding: 0.95rem;
    border-radius: var(--radius);
  }

  .panel h2 {
    font-size: 1.2rem;
    margin-bottom: 0.85rem;
  }

  /* Boutons plus gros au toucher */
  button, .btn {
    min-height: 44px;
    padding: 0.65rem 1rem;
  }

  input, select {
    min-height: 44px;
    font-size: 16px; /* évite le zoom auto iOS */
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  #search-list,
  #listing-list {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .search-item {
    padding: 1rem;
  }

  .search-item .row {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .search-item .row button {
    width: 100%;
  }

  .toolbar {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    padding: 0.85rem;
  }

  .toolbar > button {
    width: 100%;
  }

  .toolbar label.row {
    width: 100%;
    justify-content: flex-start;
  }

  #listing-count {
    display: block;
    text-align: center;
  }

  .listing:hover,
  .search-item:hover {
    transform: none; /* pas de hover « fantôme » au doigt */
  }

  .listing:hover .listing-photo img {
    transform: none;
  }

  .listing-body {
    padding: 0.85rem 0.9rem 1rem;
  }

  .price {
    font-size: 1.2rem;
  }

  .back {
    min-height: auto;
    padding: 0.35rem 0;
    margin-bottom: 0.5rem;
  }

  .empty {
    padding: 1.25rem 0.85rem;
  }
}

/* Très petits écrans */
@media (max-width: 379px) {
  .brand {
    font-size: 1.5rem;
  }

  .badge {
    font-size: 0.68rem;
  }
}

/* ----- Login ----- */

.login-wrap {
  min-height: calc(100vh - 4rem);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 0;
}

.login-panel {
  width: 100%;
  max-width: 420px;
  margin: 0;
}

.login-brand {
  font-size: clamp(2rem, 5vw, 2.4rem);
  margin: 0;
}

/* ----- Modale ----- */

body.modal-open {
  overflow: hidden;
}

.modal[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: rise-in 0.25s var(--ease) both;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 43, 51, 0.45);
  backdrop-filter: blur(3px);
}

.modal-dialog {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  max-height: min(90vh, 720px);
  overflow: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: 0 20px 50px rgba(26, 43, 51, 0.22);
  padding: 1.15rem 1.25rem 1.35rem;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.modal-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.3rem;
  letter-spacing: -0.02em;
}

.modal-close {
  border: 0;
  background: var(--bg-soft);
  color: var(--muted);
  width: 2.25rem;
  height: 2.25rem;
  min-height: 2.25rem;
  border-radius: 999px;
  padding: 0;
  font-size: 1.4rem;
  line-height: 1;
  flex-shrink: 0;
}

.modal-close:hover {
  color: var(--ink);
  background: var(--bg-tint);
  box-shadow: none;
  transform: none;
}

.modal-grid {
  margin-bottom: 0.65rem;
}

.modal-actions {
  margin-top: 1rem;
  justify-content: flex-end;
}

@media (max-width: 559px) {
  .modal {
    align-items: flex-end;
    padding: 0;
  }

  .modal-dialog {
    width: 100%;
    max-height: 92vh;
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 1rem 1rem 1.25rem;
  }

  .modal-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .modal-actions button {
    width: 100%;
  }

  .modal-grid {
    grid-template-columns: 1fr;
  }
}

/* ----- Admin utilisateurs ----- */

.users-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.users-head h2 {
  margin: 0;
}

.users-table {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.user-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--bg-elevated);
}

@media (min-width: 800px) {
  .user-row {
    grid-template-columns: 1.4fr auto auto;
    align-items: center;
  }
}

.user-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.source-row code {
  font-size: 0.85em;
  background: var(--bg-soft);
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
}

#source-key[readonly] {
  background: var(--bg-soft);
  color: var(--muted);
}

@media (max-width: 767px) {
  .topbar-actions {
    width: 100%;
  }

  .topbar-actions > button,
  .topbar-actions > .user-chip {
    flex: 1 1 auto;
    text-align: center;
    justify-content: center;
  }

  .user-row .row {
    flex-direction: column;
    align-items: stretch;
  }

  .user-row .row button {
    width: 100%;
  }
}
