/* Spotter TailwindCSS - Version Responsive Unifiée avec Variables Dynamiques */

/* === VARIABLES CSS GLOBALES === */
:root {
  /* Variables couleurs par défaut (surchargées par PHP) */
  --spotter-primary: #dc2626;
  --spotter-primary-dark: #b91c1c;
  --spotter-primary-light: #f87171;
  --spotter-accent: #991b1b;
  --spotter-success: #10b981;
  --spotter-error: #ef4444;
  --spotter-warning: #f59e0b;
  --spotter-text: #1f2937;
  --spotter-bg: #f3f4f6;
  
  /* Variables couleurs personnalisables (injectées par PHP) */
  --spotter-main: var(--spotter-primary);
  --spotter-accent-custom: var(--spotter-accent);
  --spotter-success-custom: var(--spotter-success);
  --spotter-error-custom: var(--spotter-error);
  --spotter-text-custom: var(--spotter-text);
  --spotter-bg-custom: var(--spotter-bg);
  
  /* Variables pour le responsive */
  --container-padding-mobile: 1rem;
  --container-padding-tablet: 1.5rem;
  --container-padding-desktop: 2rem;
  --horizontal-gap: 1rem;
  --vertical-gap: 1rem;
  --flex-direction: column;
}

/* === RESET ET BASE === */
* {
  box-sizing: border-box;
}

/* === CORRECTION DES FLEXBOX POUR RESPONSIVE === */
.et_flex_column, 
.et_flex_group, 
.et_flex_module, 
.et_flex_row, 
.et_flex_section {
  display: flex;
  gap: var(--horizontal-gap);
  flex-direction: var(--flex-direction);
  flex-wrap: wrap;
  width: 100%;
  min-height: fit-content;
  max-width: 100%;
}

/* Container principal responsive */
.spotter-container {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  max-width: none;
  overflow-x: hidden;
}

/* === INTEGRATION WORDPRESS === */
.spotter-app-container {
  font-family: inherit;
  color: inherit;
  line-height: 1.5;
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Intégration avec Divi */
.et_pb_section .spotter-app-container {
  padding: 0;
  margin: 0;
  width: 100% !important;
  max-width: none !important;
}

/* Corrections pour le thème Divi */
.et-db #et-boc .et-l .spotter-app-container button {
  cursor: pointer;
}

.et-db #et-boc .et-l .spotter-app-container input,
.et-db #et-boc .et-l .spotter-app-container button,
.et-db #et-boc .et-l .spotter-app-container select,
.et-db #et-boc .et-l .spotter-app-container textarea {
  font-family: inherit;
}

.et-db #et-boc .et-l .spotter-app-container .text-white {
  color: #fff !important;
}

/* === RESPONSIVE BREAKPOINTS === */

/* Mobile First - Base (0-639px) */
@media (max-width: 639px) {
  :root {
    --horizontal-gap: 0.75rem;
    --vertical-gap: 0.75rem;
    --flex-direction: column;
  }
  
  .spotter-container {
    padding: 0;
    margin: 0;
    width: 100vw;
    max-width: 100vw;
  }
  
  .spotter-header {
    padding: var(--container-padding-mobile);
    margin: 0;
    border-radius: 0;
    width: 100%;
  }
  
  .locations-grid {
    padding: var(--container-padding-mobile);
    gap: var(--horizontal-gap);
    grid-template-columns: 1fr;
    width: 100%;
  }
  
  .location-card {
    box-shadow: none !important;
    border-radius: 0.5rem;
    border-bottom: 1px solid #e5e7eb;
    margin: 0;
    min-height: 120px;
    width: 100%;
  }
  
  .location-card:hover {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
    transform: none;
  }
  
  .section-title {
    padding: var(--container-padding-mobile);
    margin: 0;
    font-size: 1.125rem;
  }
  
  .button-container {
    padding: var(--container-padding-mobile);
    margin: 0;
    border-radius: 0;
    width: 100%;
  }
  
  .btn-primary-responsive {
    border-radius: 0.5rem;
    min-height: 50px;
    font-size: 16px; /* Évite le zoom sur iOS */
    width: 100%;
  }
}

/* Tablet (640px-1023px) */
@media (min-width: 640px) and (max-width: 1023px) {
  :root {
    --horizontal-gap: 1.5rem;
    --vertical-gap: 1.5rem;
    --flex-direction: row;
  }
  
  .spotter-container {
    max-width: 48rem;
    margin: 0 auto;
    padding: var(--container-padding-tablet);
  }
  
  .locations-grid {
    gap: var(--horizontal-gap);
    grid-template-columns: repeat(2, 1fr);
    padding: var(--container-padding-tablet);
  }
  
  .location-card {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border-radius: 0.75rem;
    min-height: 220px;
  }
  
  .location-card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
  }
  
  .spotter-header {
    padding: var(--container-padding-tablet);
    border-radius: 0.75rem 0.75rem 0 0;
  }
  
  .button-container {
    padding: var(--container-padding-tablet);
    border-radius: 0 0 0.75rem 0.75rem;
  }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
  :root {
    --horizontal-gap: 2rem;
    --vertical-gap: 2rem;
    --flex-direction: row;
  }
  
  .spotter-container {
    max-width: 80rem;
    margin: 0 auto;
    padding: var(--container-padding-desktop);
  }
  
  .locations-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--horizontal-gap);
    padding: var(--container-padding-desktop);
  }
  
  .location-card {
    min-height: 240px;
    border-radius: 1rem;
  }
  
  .spotter-header {
    padding: var(--container-padding-desktop);
    border-radius: 1rem 1rem 0 0;
  }
  
  .button-container {
    padding: var(--container-padding-desktop);
    border-radius: 0 0 1rem 1rem;
  }
}

/* === CLASSES UTILITAIRES COULEURS (Variables Dynamiques) === */
.bg-spotter-primary {
  background-color: var(--spotter-main);
}

.bg-spotter-primary-dark {
  background-color: color-mix(in srgb, var(--spotter-main) 80%, black);
}

.text-spotter-primary {
  color: var(--spotter-main);
}

.border-spotter-primary {
  border-color: var(--spotter-main);
}

/* Classes couleurs personnalisables */
.bg-spotter-accent {
  background-color: var(--spotter-accent-custom);
}

.bg-spotter-success {
  background-color: var(--spotter-success-custom);
}

.bg-spotter-error {
  background-color: var(--spotter-error-custom);
}

.text-spotter-accent {
  color: var(--spotter-accent-custom);
}

.text-spotter-success {
  color: var(--spotter-success-custom);
}

.text-spotter-error {
  color: var(--spotter-error-custom);
}

.text-spotter-custom {
  color: var(--spotter-text-custom);
}

.bg-spotter-custom {
  background-color: var(--spotter-bg-custom);
}

/* Gradient avec couleur principale */
.bg-gradient-spotter {
  background: linear-gradient(135deg, var(--spotter-main), color-mix(in srgb, var(--spotter-main) 80%, black));
}

/* === HEADER RESPONSIVE === */
.spotter-header {
  background: linear-gradient(135deg, var(--spotter-main), color-mix(in srgb, var(--spotter-main) 80%, black));
  color: white;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* === GRILLE RESPONSIVE === */
.locations-grid {
  display: grid;
  width: 100%;
  place-items: stretch;
}

/* === CARTES RESPONSIVES === */
.location-card {
  background: white;
  overflow: hidden;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 100%;
  cursor: pointer;
}

/* === ELEMENTS RESPONSIVE === */

/* Badge responsive */
.location-badge {
  background-color: var(--spotter-main);
  color: white;
  font-weight: bold;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
}

@media (min-width: 640px) {
  .location-badge {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
  }
}

/* Titres responsifs */
.location-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--spotter-text-custom);
  margin-bottom: 0.5rem;
  line-height: 1.25;
}

@media (min-width: 640px) {
  .location-title {
    font-size: 1rem;
    margin-bottom: 0.75rem;
  }
}

@media (min-width: 768px) {
  .location-title {
    font-size: 1.125rem;
  }
}

/* Descriptions responsives */
.location-description {
  font-size: 0.75rem;
  color: color-mix(in srgb, var(--spotter-text-custom) 70%, transparent);
  line-height: 1.5;
  flex-grow: 1;
}

@media (min-width: 640px) {
  .location-description {
    font-size: 0.875rem;
  }
}

@media (min-width: 768px) {
  .location-description {
    font-size: 1rem;
  }
}

/* Section titre responsive */
.section-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--spotter-text-custom);
  margin-bottom: 1rem;
  text-align: center;
}

@media (min-width: 640px) {
  .section-title {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
  }
}

@media (min-width: 768px) {
  .section-title {
    font-size: 1.5rem;
    margin-bottom: 2rem;
  }
}

/* Bouton principal responsive avec couleur dynamique */
.btn-primary-responsive {
  width: 100%;
  background-color: var(--spotter-main);
  color: white;
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 0.5rem;
}

.btn-primary-responsive:hover {
  background-color: color-mix(in srgb, var(--spotter-main) 80%, black);
}

.btn-primary-responsive:focus {
  outline: 2px solid var(--spotter-main);
  outline-offset: 2px;
}

@media (min-width: 640px) {
  .btn-primary-responsive {
    padding: 1rem 1.5rem;
    font-size: 1rem;
    border-radius: 0.5rem;
  }
  
  .btn-primary-responsive:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--spotter-main) 30%, transparent);
  }
}

@media (min-width: 768px) {
  .btn-primary-responsive {
    padding: 1.25rem 2rem;
    font-size: 1.125rem;
  }
}

/* Bouton secondaire */
.btn-secondary-responsive {
  width: 100%;
  background-color: var(--spotter-accent-custom);
  color: white;
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  border: 2px solid var(--spotter-accent-custom);
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 0.5rem;
}

.btn-secondary-responsive:hover {
  background-color: transparent;
  color: var(--spotter-accent-custom);
}

/* Messages avec couleurs personnalisables */
.spotter-message-success {
  background-color: color-mix(in srgb, var(--spotter-success-custom) 10%, white);
  border: 1px solid var(--spotter-success-custom);
  color: color-mix(in srgb, var(--spotter-success-custom) 80%, black);
  padding: 1rem;
  border-radius: 0.5rem;
  margin: 1rem;
}

.spotter-message-error {
  background-color: color-mix(in srgb, var(--spotter-error-custom) 10%, white);
  border: 1px solid var(--spotter-error-custom);
  color: color-mix(in srgb, var(--spotter-error-custom) 80%, black);
  padding: 1rem;
  border-radius: 0.5rem;
  margin: 1rem;
}

/* Container bouton responsive */
.button-container {
  background: var(--spotter-bg-custom);
  width: 100%;
}

/* === ANIMATIONS (seulement sur tablette+) === */
@keyframes slideInScale {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (min-width: 640px) {
  .animate-slide-scale {
    animation: slideInScale 0.4s ease-out;
  }
}

/* === ELEMENTS UI RESPONSIVE === */

/* Header info responsive */
.header-info {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.9);
}

@media (min-width: 640px) {
  .header-info {
    font-size: 1rem;
  }
}

/* Timer responsive */
.timer-display {
  font-size: 0.875rem;
  font-weight: 600;
  color: white;
  background: rgba(255, 255, 255, 0.2);
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
}

@media (min-width: 640px) {
  .timer-display {
    font-size: 1rem;
  }
}

@media (min-width: 768px) {
  .timer-display {
    font-size: 1.125rem;
  }
}

/* Badge de progression responsive */
.progress-badge {
  background: rgba(255, 255, 255, 0.2);
  padding: 0.25rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  color: white;
}

@media (min-width: 640px) {
  .progress-badge {
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
  }
}

/* === OPTIMISATIONS TOUCH POUR MOBILE === */
@media (max-width: 639px) {
  .location-card {
    padding: 1rem;
    min-height: 120px;
  }
  
  .btn-primary-responsive {
    min-height: 50px;
    font-size: 16px; /* Évite le zoom sur iOS */
  }
  
  /* Améliorer la zone de toucher */
  .location-card,
  .btn-primary-responsive {
    touch-action: manipulation;
  }
}

/* === ACCESSIBILITÉ === */
/* Focus amélioré pour accessibilité */
.location-card:focus {
  outline: 2px solid var(--spotter-main);
  outline-offset: 2px;
}

@media (min-width: 640px) {
  .location-card:focus-within {
    outline: none;
    box-shadow: 0 0 0 2px var(--spotter-main), 0 0 0 4px color-mix(in srgb, var(--spotter-main) 20%, transparent);
  }
}

/* === IMPRESSION === */
@media print {
  .spotter-container {
    max-width: none;
    padding: 0;
  }
  
  .location-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }
  
  .bg-gradient-spotter {
    background: #333 !important;
    color: white !important;
  }
}

/* === ÉTAT DE CHARGEMENT === */
.spotter-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
  color: var(--spotter-main);
}

.spotter-loading::after {
  content: "";
  width: 2rem;
  height: 2rem;
  border: 2px solid transparent;
  border-top: 2px solid var(--spotter-main);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* === THÈMES ALTERNATIFS VIA CLASSES === */
/* Thème vert */
.theme-green {
  --spotter-main: #22c55e;
  --spotter-accent-custom: #16a34a;
}

/* Thème bleu */
.theme-blue {
  --spotter-main: #3b82f6;
  --spotter-accent-custom: #2563eb;
}

/* Thème violet */
.theme-purple {
  --spotter-main: #a855f7;
  --spotter-accent-custom: #9333ea;
}

/* Thème orange */
.theme-orange {
  --spotter-main: #f97316;
  --spotter-accent-custom: #ea580c;
}

/* Mode sombre */
.theme-dark {
  --spotter-bg-custom: #1f2937;
  --spotter-text-custom: #f9fafb;
}

.theme-dark .location-card {
  background: #374151;
  color: #f9fafb;
}

.theme-dark .spotter-header {
  background: linear-gradient(135deg, #111827, #1f2937);
}

/* === RESPONSIVE POUR ÉCRANS TRÈS LARGES === */
@media (min-width: 1440px) {
  .spotter-container {
    max-width: 90rem;
  }
  
  .locations-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* === CORRECTIONS SPÉCIFIQUES WORDPRESS/DIVI === */
/* Fix pour débordement dans Divi */
.et_pb_section .spotter-app-container,
.et_pb_column .spotter-app-container {
  overflow-x: hidden !important;
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Fix pour les conteneurs flex qui débordent */
.et_flex_column, 
.et_flex_group, 
.et_flex_module, 
.et_flex_row, 
.et_flex_section {
  max-width: 100%;
  overflow: hidden;
}

/* Fix pour les images qui débordent */
.location-card img {
  max-width: 100%;
  height: auto;
  object-fit: cover;
}

/* Fix pour le scroll horizontal indésirable */
body.spotter-active {
  overflow-x: hidden;
}

/* === OPTIMISATIONS DE PERFORMANCE === */
/* Optimiser les transitions sur les devices lents */
@media (prefers-reduced-motion: reduce) {
  .location-card,
  .btn-primary-responsive,
  .animate-slide-scale {
    transition: none;
    animation: none;
  }
}

/* Optimiser l'affichage sur des connexions lentes */
@media (prefers-reduced-data: reduce) {
  .bg-gradient-spotter {
    background: var(--spotter-main);
  }
  
  .location-card {
    box-shadow: none;
  }
}