/* Tailwind CSS v4 */
@import "tailwindcss";

/* Configuration des couleurs de marque */
@theme {
  --color-brand-primary: #FFC629;
  --color-brand-secondary: #000000;
  --color-brand-dark: #1F1F1F;
  --color-brand-light: #FFFFFF;
  --color-brand-gray: #F3F4F6;
  
  --font-family-sans: 'Inter', system-ui, -apple-system, sans-serif;
  
  --shadow-float: 0 10px 40px -10px rgba(0,0,0,0.2);
}

/* Désactiver la sélection de texte sur tout le site */
*, *::before, *::after {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Autoriser la sélection dans les champs de saisie */
input, textarea, [contenteditable="true"] {
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

/* CSS pour améliorer l'expérience mobile */

/* Fix pour la hauteur viewport sur mobile (évite les problèmes avec les barres d'adresse) */
:root {
  --vh: 1vh;
}

/* Masquer la scrollbar pour les sliders */
.scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.scrollbar-hide::-webkit-scrollbar {
  display: none;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
  background-color: #f5f5f5;
  /* Permettre le scroll vertical uniquement */
  overflow-x: hidden !important;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100vw;
}

html {
  overflow-x: hidden !important;
  overflow-y: auto;
  max-width: 100vw;
}

#root {
  min-height: 100vh;
  overflow-x: hidden !important;
  max-width: 100vw;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}

/* Hide scrollbar for IE, Edge and Firefox */
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Leaflet custom styles */
.leaflet-control-attribution {
  display: none;
}

.custom-pin {
  transition: all 0.3s ease;
}

/* Conteneur de la carte - gérer overflow correctement */
#map-container {
  position: relative;
  width: 100%;
  height: 100%;
}

.leaflet-container {
  width: 100% !important;
  height: 100% !important;
  position: absolute !important;
  top: 0;
  left: 0;
}

/* Sur desktop, s'assurer que le conteneur principal limite la carte */
@media (min-width: 1024px) {
  #map-container {
    overflow: hidden;
  }
}

/* Fix pour les inputs sur mobile - empêcher le zoom automatique sur iOS */
input[type="text"],
input[type="datetime-local"],
textarea {
  font-size: 16px !important; /* iOS ne zoom pas si font-size >= 16px */
}

/* Améliorer le comportement du clavier sur mobile */
@supports (-webkit-touch-callout: none) {
  /* iOS only */
  .mobile-safe-height {
    height: -webkit-fill-available;
    min-height: -webkit-fill-available;
  }
}

/* Animation pour le clavier mobile */
@media (max-width: 768px) {
  /* Transition douce quand le clavier apparaît */
  .keyboard-aware {
    transition: transform 0.3s ease, padding 0.3s ease;
  }
  
  /* S'assurer que les éléments en position fixed restent visibles */
  .mobile-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 85vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

/* Animation de slide-in améliorée */
@keyframes slideInFromBottom {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.animate-in {
  animation: slideInFromBottom 0.3s ease-out;
}

/* Améliorer les zones tactiles pour mobile (minimum 44x44px recommandé par Apple) */
@media (max-width: 768px) {
  button, 
  input[type="button"],
  .clickable {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Quand le clavier est ouvert, réduire les marges et ajuster la hauteur */
  body.keyboard-open .mobile-drawer {
    max-height: 50vh;
  }
  
  /* Assurer que les inputs soient visibles même avec le clavier */
  body.keyboard-open input:focus,
  body.keyboard-open textarea:focus {
    transform: translateY(-20px);
  }
}

/* Améliorer le comportement des drawers sur mobile */
.mobile-drawer {
  touch-action: pan-y;
}

/* Safe area insets pour les mobiles avec encoche */
.pb-safe {
  padding-bottom: 4rem !important;
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .pb-safe {
    padding-bottom: calc(4rem + env(safe-area-inset-bottom)) !important;
  }
  
  .mobile-drawer {
    padding-bottom: calc(env(safe-area-inset-bottom) + 0.5rem);
  }
}

/* Mobile - Assurer que le contenu des drawers est entièrement visible */
@media (max-width: 768px) {
  .mobile-drawer {
    margin-bottom: env(safe-area-inset-bottom, 0);
  }
}

/* Empêcher le bounce sur iOS pour les éléments scrollables */
.overflow-y-auto,
.overflow-auto {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Désactiver le scroll horizontal de manière ciblée (pas sur les cartes Leaflet) */
body, .public-layout, main, section {
  overflow-x: hidden !important;
}

/* Fix pour éviter que le contenu soit caché derrière le clavier */
@media (max-width: 768px) {
  .keyboard-aware {
    will-change: transform;
  }
  
  /* Ajuster le padding du bas quand un input est focus */
  .bg-white.rounded-t-\[30px\]:has(input:focus),
  .bg-white.rounded-t-\[30px\]:has(textarea:focus) {
    padding-bottom: calc(env(safe-area-inset-bottom) + 20px);
  }
}

/* ==========================================
 * EFFET MENU LATÉRAL (inspiré almadani)
 * ========================================== */

/* Configuration pour l'effet 3D du menu */
body, html {
  overflow-x: hidden !important;
  position: relative;
  max-width: 100vw;
}

/* Permettre l'effet 3D */
#root {
  position: relative;
  min-height: 100vh;
  overflow: visible;
}

/* Mobile: gestion du scroll du contenu public */
.public-layout {
  position: relative;
  min-height: 100vh;
  overflow-x: hidden !important;
  max-width: 100vw;
}

/* Scroll activé quand le menu est fermé */
.public-layout.menu-closed {
  overflow-x: hidden !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
}

/* Scroll désactivé quand le menu est ouvert */
.public-layout.menu-open {
  overflow: hidden !important;
}

/* Animation fluide du scale et translation avec effet 3D */
@media (prefers-reduced-motion: no-preference) {
  .mobile-safe-height {
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), 
                border-radius 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  }
}

/* Améliorer l'effet 3D avec perspective */
body {
  perspective: 1500px;
  perspective-origin: center;
}

.mobile-safe-height {
  transform-style: preserve-3d;
  backface-visibility: hidden;
  will-change: transform, filter;
}

/* Animation de l'effet carte qui se détache */
@keyframes cardDetach {
  0% {
    transform: scale(1) translateX(0);
    filter: brightness(1);
  }
  100% {
    transform: scale(0.88) translateX(-180px);
    filter: brightness(0.85);
  }
}

/* ==========================================
 * RESPONSIVE DESIGN
 * ========================================== */

/* ==========================================
 * DESKTOP MODE - Layout côte à côte VRAI
 * ========================================== */
@media (min-width: 1024px) {
  /* Reset body pour desktop */
  body {
    background: #f5f5f5;
    overflow-x: hidden !important;
    overflow-y: auto;
    perspective: none !important;
    max-width: 100vw;
  }
  
  /* Désactiver les effets mobiles */
  .mobile-safe-height {
    transform: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    filter: none !important;
    height: 100vh !important;
    overflow: hidden !important;
  }

  /* BookingApp Desktop Layout - Structure rigide */
  .lg\:flex.h-screen.w-screen {
    position: relative;
    overflow: hidden;
  }

  /* Sidebar et panneau de réservation */
  .lg\:flex.h-screen.w-screen > div:not(.flex-1) {
    flex-shrink: 0;
    position: relative;
    z-index: 10;
  }

  /* Conteneur de la carte - reste dans ses limites */
  .lg\:flex.h-screen.w-screen > .flex-1 {
    position: relative;
    flex: 1;
    overflow: hidden;
    z-index: 1;
  }
  
  .mobile-safe-height.scale-\[0\.88\] {
    transform: none !important;
  }
  
  /* Masquer les éléments mobiles */
  .mobile-menu-button,
  .mobile-drawer-menu {
    display: none !important;
  }
  
  /* Le drawer mobile devient invisible sur desktop */
  .mobile-drawer {
    display: none !important;
  }
  
  /* La carte mobile devient invisible sur desktop */
  .desktop-map-fullscreen {
    display: none !important;
  }
}

/* Tablet (769px - 1023px) - Comportement mobile */
@media (min-width: 769px) and (max-width: 1023px) {
  body {
    background: #f3f4f6;
  }
  
  .mobile-safe-height {
    width: 100%;
  }
}

/* Tablet et Mobile - Pages publiques uniquement */
@media (max-width: 768px) {
  /* Réduire la translation sur mobile - UNIQUEMENT pour les pages publiques */
  .public-layout.-translate-x-\[100px\] {
    transform: translateX(-80px) scale(0.92) !important;
  }
}

@media (max-width: 480px) {
  /* Translation encore plus petite sur très petits écrans - UNIQUEMENT pour les pages publiques */
  .public-layout.-translate-x-\[100px\] {
    transform: translateX(-60px) scale(0.94) !important;
  }
}

/* ==========================================
 * DATEPICKER CUSTOM STYLES
 * ========================================== */

/* Style pour l'input datetime-local */
input[type="datetime-local"] {
  color-scheme: light;
  position: relative;
}

/* Style des icônes du datepicker */
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  position: absolute;
  left: 0;
  top: 0;
}

/* Chrome, Safari, Edge */
input[type="datetime-local"]::-webkit-datetime-edit {
  padding: 0;
  font-weight: 600;
}

input[type="datetime-local"]::-webkit-datetime-edit-fields-wrapper {
  padding: 0;
}

input[type="datetime-local"]::-webkit-datetime-edit-text {
  color: #6b7280;
  padding: 0 2px;
}

input[type="datetime-local"]::-webkit-datetime-edit-month-field,
input[type="datetime-local"]::-webkit-datetime-edit-day-field,
input[type="datetime-local"]::-webkit-datetime-edit-year-field,
input[type="datetime-local"]::-webkit-datetime-edit-hour-field,
input[type="datetime-local"]::-webkit-datetime-edit-minute-field {
  padding: 2px 4px;
  border-radius: 6px;
  color: #111827;
  background: transparent;
  transition: all 0.2s;
}

input[type="datetime-local"]::-webkit-datetime-edit-month-field:focus,
input[type="datetime-local"]::-webkit-datetime-edit-day-field:focus,
input[type="datetime-local"]::-webkit-datetime-edit-year-field:focus,
input[type="datetime-local"]::-webkit-datetime-edit-hour-field:focus,
input[type="datetime-local"]::-webkit-datetime-edit-minute-field:focus {
  background: #FFC629;
  color: #000;
  outline: none;
}

/* Style du calendrier qui s'ouvre (Chrome) */
input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover {
  background: transparent;
}

/* Firefox */
input[type="datetime-local"]::-moz-calendar-picker-indicator {
  opacity: 0;
}

/* Style placeholder pour datetime-local vide */
input[type="datetime-local"]:invalid {
  color: #9ca3af;
}

input[type="datetime-local"]:valid {
  color: #000;
}

/* ==========================================
 * REACT-DATEPICKER CUSTOM STYLES
 * ========================================== */

/* Popper wrapper */
.custom-datepicker-popper {
  z-index: 9999 !important;
}

/* Calendar container */
.custom-datepicker {
  font-family: 'Inter', sans-serif;
  border: none;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
  padding: 20px;
  background: white;
}

/* Header */
.react-datepicker__header {
  background: white;
  border-radius: 16px 16px 0 0;
  border: none;
  padding: 20px 16px 16px;
  margin-bottom: 16px;
  border-bottom: 2px solid #f3f4f6;
}

.react-datepicker__current-month {
  color: #111827;
  font-weight: 800;
  font-size: 18px;
  text-transform: capitalize;
  margin-bottom: 12px;
}

/* Navigation buttons - Mise en valeur */
.react-datepicker__navigation {
  top: 20px;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #FFC629;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(255, 198, 41, 0.3);
}

.react-datepicker__navigation:hover {
  background: #f59e0b;
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(255, 198, 41, 0.5);
}

.react-datepicker__navigation:active {
  transform: scale(0.95);
}

.react-datepicker__navigation-icon::before {
  border-color: #000;
  border-width: 3px 3px 0 0;
  width: 9px;
  height: 9px;
}

/* Day names */
.react-datepicker__day-name {
  color: #6b7280;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  width: 40px;
  line-height: 40px;
  margin: 2px;
  letter-spacing: 0.5px;
}

/* Days */
.react-datepicker__day {
  width: 40px;
  height: 40px;
  line-height: 40px;
  margin: 2px;
  border-radius: 10px;
  color: #111827;
  font-weight: 600;
  transition: all 0.2s;
}

.react-datepicker__day:hover {
  background: #FFC629;
  color: #000;
  transform: scale(1.05);
}

.react-datepicker__day--selected {
  background: #000 !important;
  color: #FFC629 !important;
  font-weight: 800;
  transform: scale(1.1);
}

.react-datepicker__day--keyboard-selected {
  background: rgba(255, 198, 41, 0.2);
  color: #000;
}

.react-datepicker__day--disabled {
  color: #d1d5db;
  cursor: not-allowed;
}

.react-datepicker__day--disabled:hover {
  background: transparent;
  transform: none;
}

.react-datepicker__day--outside-month {
  color: #9ca3af;
}

.react-datepicker__day--today {
  font-weight: 700;
  background: rgba(255, 198, 41, 0.2);
}

/* Time container */
.react-datepicker__time-container {
  border-left: 2px solid #f3f4f6;
}

.react-datepicker__time {
  background: white;
  border-radius: 0 0 16px 0;
}

.react-datepicker__header--time {
  background: white;
  border-radius: 0;
  padding: 12px;
  margin-bottom: 0;
  border-bottom: 2px solid #f3f4f6;
}

.react-datepicker__header--time .react-datepicker-time__header {
  color: #111827;
  font-weight: 700;
  font-size: 14px;
}

.react-datepicker__time-container .react-datepicker__time .react-datepicker__time-box {
  width: 100px;
}

.react-datepicker__time-list-item {
  padding: 8px 16px;
  font-weight: 600;
  transition: all 0.2s;
}

.react-datepicker__time-list-item:hover {
  background: #FFC629 !important;
  color: #000 !important;
}

.react-datepicker__time-list-item--selected {
  background: #000 !important;
  color: #FFC629 !important;
  font-weight: 800;
}

/* Input styling */
.react-datepicker-wrapper {
  width: 100%;
}

.react-datepicker__input-container {
  width: 100%;
}

/* Triangle pointer */
.react-datepicker__triangle {
  display: none;
}

/* Month/Year dropdown */
.react-datepicker__month-dropdown,
.react-datepicker__year-dropdown {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.react-datepicker__month-option,
.react-datepicker__year-option {
  padding: 8px 16px;
  font-weight: 600;
  transition: all 0.2s;
}

.react-datepicker__month-option:hover,
.react-datepicker__year-option:hover {
  background: #FFC629;
  color: #000;
}

.react-datepicker__month-option--selected,
.react-datepicker__year-option--selected {
  background: #000;
  color: #FFC629;
}
