:root {
  --card-size: 200px;
  --bg: #fff;
  --text: #000;
  --card-front: #f9f9f9;
  --card-back: #e9e9e9;
  --card-shadow: rgba(0, 0, 0, 0.15);
  --font-base: 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
  --font-size-base: clamp(0.9rem, 1vw, 1rem);
  --font-size-small: clamp(0.75rem, 0.9vw, 0.875rem);
  --font-size-large: clamp(1.1rem, 1.5vw, 1.25rem);
}

/* === BASE === */
body {
  font-family: var(--font-base);
  font-size: var(--font-size-base);
  background-color: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 2rem;
}

h1 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: var(--font-size-large);
  margin-bottom: 1rem;
}

/* === THÈME === */
#theme-toggle-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
}

#toggle-theme {
  background: none;
  color: inherit;
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.3s ease;
}

#toggle-theme:hover {
  transform: scale(1.1) rotate(15deg);
}

.theme-icon {
  width: 28px;
  height: 28px;
  stroke: currentColor;
  color: var(--text);
  transition: transform 0.3s ease;
}

.theme-button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--card-front);
  color: var(--text);
  border: 1px solid #ccc;
  border-radius: 10px;
  padding: 0.4rem 0.8rem;
  font-weight: 500;
  transition: all 0.3s ease;
}

.theme-button:hover {
  background-color: rgba(0, 123, 255, 0.1);
}

/* === GRILLE === */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(var(--card-size), 1fr));
  gap: 1rem;
  max-width: 1200px;
  margin: 0 auto;
}

/* === CARTE === */
.card {
  min-height: 360px;
  position: relative;
  perspective: 1000px;
  border-radius: 12px;
  box-shadow: 0 8px 20px var(--card-shadow);
  overflow: hidden;
  background: var(--card-front);
  display: flex;
  flex-direction: column;
  height: auto;
  transform-style: preserve-3d;
}

.card-inner {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.8s ease;
  display: flex;
  flex-direction: column;
}

.card.flipped .card-inner {
  transform: rotateY(180deg);
}

/* Hover uniquement si supporté (pas mobile) */
@media (hover: hover) {
  .card:hover .card-inner {
    transform: rotateY(180deg);
  }
}

/* Faces de la carte */
.card-front,
.card-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  will-change: transform, opacity;
  transform-style: preserve-3d;
  padding: 1rem;
  border-radius: 12px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: stretch;
  width: 100%;
  height: 100%;
  font-size: clamp(0.6rem, 0.9vw, 1rem); /* plus responsive */
}

.card-front {
  background: var(--card-front);
  z-index: 2;
}

.card-back {
  background: var(--card-back);
  transform: rotateY(180deg);
  padding-bottom: 1.5rem;
  font-size: clamp(0.6rem, 1vw, 0.85rem);
}

/* Contenu de carte */
.card img {
  width: 100%;
  height: auto;
  max-height: 140px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.card h2,
.card p,
.card-back h3,
.card-back p,
.card-back small {
  font-size: inherit;
  margin: 0.25rem 0;
  text-align: center;
  word-break: break-word;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
}

.card h2 {
  font-weight: 600;
  min-height: 2.5em;
}

.card-content {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex-grow: 1;
  width: 100%;
  height: 100%;
}

.card-back .card-content {
  gap: 0.3rem;
}

/* === OPTIONS & CONTROLS === */
.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.grid-buttons {
  margin-top: -1.2rem; /* remonte un peu la grille si besoin */
}

.grid-options {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.grid-options button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 6px;
  transition: background 0.3s;
}

.grid-options button:hover {
  background-color: rgba(0, 123, 255, 0.1);
}

.grid-options button.active {
  background-color: #007bff;
  color: white;
}

.grid-options button.active .grid-icon {
  color: white;
}

.grid-icon {
  width: 24px;
  height: 24px;
  fill: currentColor;
  color: var(--text);
}

/* === FORMULAIRES === */
#search-input,
#city-filter {
  padding: 0.5rem 1rem;
  font-size: 1rem;
  border-radius: 8px;
  border: 1px solid #ccc;
  background-color: var(--card-front);
  color: var(--text);
  transition: background-color 0.3s, color 0.3s;
}

#search-input {
  width: 300px;
  max-width: 90%;
}

#city-filter {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* === ICÔNES === */
.icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.globe-icon {
  font-size: 36px;
  color: var(--text);
  transition: color 0.3s;
}

/* === COMPTEUR === */
#card-counter {
  font-size: 0.9rem;
  font-weight: 400;
  margin: 0;
  color: var(--text);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .card h2 {
    font-size: inherit;
  }

  .card-back {
    font-size: inherit;
  }
}

@media (max-width: 600px) {
  .card img {
    height: min(100px, 25vw);
  }

  .card-front,
  .card-back {
    padding: 0.75rem;
  }

  .card h2,
  .card p,
  .card-back p,
  .card-back small {
    font-size: clamp(0.65rem, 1.2vw, 0.85rem);
  }
}

@media (max-width: 480px) {
  .card {
    min-height: 360px;
  }
}

/* === DARK MODE === */
[data-theme="dark"] {
  --bg: #121212;
  --text: #e0e0e0;
  --card-front: #1e1e1e;
  --card-back: #2a2a2a;
  --card-shadow: rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .theme-icon {
  color: hsl(0, 0%, 98%);
}

[data-theme="dark"] .theme-button {
  border-color: #555;
  background-color: var(--card-back);
}

[data-theme="dark"] .grid-options button.active {
  background-color: #0056b3;
}

[data-theme="dark"] #city-filter {
  border: 1px solid #444;
}

/* === ALIGNEMENT === */
.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  align-items: center;
  margin-top: -0.5rem;
}

.sort-btn .icon {
  vertical-align: middle;
}

/* === CONTENU ÉTIRÉ === */
.card-front::after,
.card-back::after {
  content: '';
  flex-grow: 1;
  display: block;
  min-height: 1rem;
}

.search-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 1rem;
}

.tag-overlay {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  z-index: 10;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.tag-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  font-weight: bold;
  border-radius: 1rem;
  background-color: rgba(255, 255, 255, 0.85);
  color: #333;
  backdrop-filter: blur(3px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  white-space: nowrap;
  transition: background-color 0.3s ease;
}

.tag-icon-svg {
  width: 1rem;
  height: 1rem;
  fill: currentColor;
}

/* Couleurs spécifiques */
.tag-icon.favorite {
  color: #c92a2a;
  background-color: rgba(255, 230, 230, 0.85);
}

.tag-icon.superhost {
  color: #000000;
  background-color: rgba(255, 243, 205, 0.85);
}

/* Dark mode support (si tu gères un theme dark via body class ou data-theme) */
body.dark .tag-icon {
  background-color: rgba(30, 30, 30, 0.85);
  color: white;
}

body.dark .tag-icon.favorite {
  color: #ff6b6b;
  background-color: rgba(70, 0, 0, 0.7);
}

body.dark .tag-icon.superhost {
  color: #ffc107;
  background-color: rgba(209, 173, 10, 0.6);
}


.tag-filter-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  margin-bottom: 1rem;
}

.tag-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  border-radius: 1rem;
  background-color: var(--button-bg, #eee);
  border: none;
  cursor: pointer;
  font-weight: bold;
  font-size: 0.9rem;
  transition: background-color 0.3s ease;
}

.theme-button {
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

/* Hover en mode clair */
body.light .tag-filter-btn:hover {
  background-color: #e0e0e0;
  color: #000;
}

/* Hover en mode sombre */
body.dark .tag-filter-btn:hover {
  background-color: #444;
  color: #fff;
}

.tag-icon-svg {
  width: 1rem;
  height: 1rem;
  fill: currentColor;
}

body.light .theme-button {
  background-color: #f0f0f0;
  color: #111;
  border-color: #ccc;
}

body.light .theme-button:hover {
  background-color: #ddd;
}

body.dark .theme-button {
  background-color: #2c2c2c;
  color: #f8f8f8;
  border-color: #555;
}
/* Hover en dark mode – changer SEULEMENT le fond */
body.dark .theme-button:hover {
  background-color: #444;
  color: #f8f8f8; /* ou rien, hérite de .theme-button */
}

body.dark .tag-filter-btn {
  background-color: #222 !important;
  color: #f8f8f8 !important;
  border: 1px solid #444 !important;
}

/* Active tag button */
.tag-filter-btn.active {
  font-weight: bold;
  box-shadow: 0 0 0 2px var(--accent-color, #0056b3 );
}