/* ============================================================================
   CAPRICE DESIGN SYSTEM — FORMS & SELECTS
   Version: 1.0.0
   Centralized styling for form inputs, selects, options, and Choices.js
   ============================================================================ */

/* ============================================================================
   FORM GROUP — STRUCTURE
   ============================================================================ */

.form-group {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 12px;
  font-weight: 600;
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  position: relative;
  padding-left: 0;
}

.form-group label::before {
  content: '';
  position: absolute;
  left: -2px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  border-radius: 2px;
  transition: height 0.3s ease;
}

.form-group:focus-within label::before {
  height: 100%;
}

/* ============================================================================
   FORM GROUP — INPUTS, TEXTAREAS, SELECTS
   ============================================================================ */

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, rgba(255, 62, 181, 0.05), rgba(227, 0, 73, 0.03));
  border: 2px solid rgba(255, 62, 181, 0.25);
  border-radius: 12px;
  color: var(--blanc-pur);
  font-size: 1rem;
  font-family: var(--font-primary);
  font-weight: 500;
  transition: all 0.3s ease;
  outline: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.form-group textarea {
  resize: vertical;
  min-height: 150px;
  line-height: 1.6;
  font-size: 0.95rem;
}

/* Valid input indicator */
.form-group input:valid:not(:placeholder-shown),
.form-group select:valid:not([value=""]),
.form-group textarea:valid:not(:placeholder-shown) {
  border-color: rgba(255, 62, 181, 0.3);
}

.form-group input:valid:not(:placeholder-shown):not(:focus),
.form-group select:valid:not([value=""]):not(:focus),
.form-group textarea:valid:not(:placeholder-shown):not(:focus) {
  background: linear-gradient(135deg, rgba(255, 62, 181, 0.06), rgba(227, 0, 73, 0.04));
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--rose-fuchsia);
  background: linear-gradient(135deg, rgba(255, 62, 181, 0.08), rgba(227, 0, 73, 0.05));
  box-shadow: 0 0 25px rgba(255, 62, 181, 0.4), 0 4px 15px rgba(0, 0, 0, 0.2);
  transform: translateY(-2px);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: rgba(255, 255, 255, 0.35);
  font-style: italic;
  font-weight: 400;
}

.form-group input:hover,
.form-group select:not(:focus):hover {
  border-color: rgba(255, 62, 181, 0.35);
  box-shadow: 0 4px 12px rgba(255, 62, 181, 0.15);
}

/* Input number styling */
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Form row grid layout */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

/* ============================================================================
   SELECT — BASE STYLING
   ============================================================================ */

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 12 12'%3E%3Cpath fill='%23ff3eb5' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 18px center;
  padding-right: 45px;
  position: relative;
}

select:hover {
  border-color: rgba(255, 62, 181, 0.4);
  background-color: rgba(255, 62, 181, 0.07);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 62, 181, 0.2);
}

select:focus {
  border-color: rgba(255, 62, 181, 0.5);
  background-color: rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 15px rgba(255, 62, 181, 0.1);
}

select:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

select[multiple] {
  background-image: none;
  padding-right: 15px;
}

/* ============================================================================
   OPTION — DROPDOWN ITEMS
   ============================================================================ */

option {
  background-color: #0a0a0a !important;
  color: #FFFFFF !important;
  padding: 12px 15px;
  font-weight: 500;
  font-size: 0.95rem;
}

option:hover {
  background-color: #2a2a2a !important;
  color: #FFFFFF !important;
}

option:checked,
option:active,
option[selected] {
  background-color: #000000 !important;
  background: linear-gradient(135deg, #FF3EB5, #E30049) !important;
  color: #FFFFFF !important;
  font-weight: 600;
}

option[value=""] {
  color: #999999 !important;
  font-style: italic;
  background-color: #0a0a0a !important;
}

/* ============================================================================
   CHOICES.JS — DARK THEME
   ============================================================================ */

/* Container principal */
.choices {
  margin-bottom: 0;
  font-size: 1rem;
  position: relative;
}

.choices.is-open {
  z-index: 100000 !important;
  position: relative !important;
}

.choices__inner {
  background: linear-gradient(135deg, rgba(255, 62, 181, 0.05), rgba(227, 0, 73, 0.03)) !important;
  border: 2px solid rgba(255, 62, 181, 0.25) !important;
  border-radius: 12px !important;
  padding: 12px 15px !important;
  min-height: 50px !important;
  color: #FFFFFF !important;
  font-family: var(--font-primary);
  font-weight: 500 !important;
  transition: all 0.3s ease !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
}

.choices__inner:hover {
  border-color: rgba(255, 62, 181, 0.35) !important;
  box-shadow: 0 4px 12px rgba(255, 62, 181, 0.15) !important;
}

.choices.is-focused .choices__inner,
.choices.is-open .choices__inner {
  border-color: var(--rose-fuchsia) !important;
  background: linear-gradient(135deg, rgba(255, 62, 181, 0.08), rgba(227, 0, 73, 0.05)) !important;
  box-shadow: 0 0 25px rgba(255, 62, 181, 0.4), 0 4px 15px rgba(0, 0, 0, 0.2) !important;
}

/* Valeur sélectionnée */
.choices__list--single .choices__item {
  color: #FFFFFF !important;
  font-weight: 500 !important;
}

.choices__placeholder {
  color: rgba(255, 255, 255, 0.35) !important;
  font-style: italic !important;
  opacity: 1 !important;
}

/* Dropdown menu */
.choices__list--dropdown {
  background-color: #0a0a0a !important;
  border: 2px solid rgba(255, 62, 181, 0.4) !important;
  border-radius: 12px !important;
  margin-top: 8px !important;
  padding: 8px 0 !important;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(255, 62, 181, 0.3) !important;
  z-index: 100001 !important;
  position: absolute !important;
  overflow: hidden !important;
  animation: choicesDropdown 0.2s ease forwards;
}

/* Choices.js imbrique un .choices__list interne (role="listbox") DANS le
   conteneur .choices__list--dropdown. Le scroll ne doit s'appliquer qu'à cette
   liste interne — le mettre aussi sur le conteneur externe crée deux barres
   de défilement imbriquées. On exclut .fs-portal (dropdown "portail" custom de
   map.html) qui calcule sa propre hauteur dynamiquement en JS selon l'espace
   écran disponible. */
.choices__list--dropdown:not(.fs-portal) .choices__list {
  max-height: 300px !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
}


.choices__list--dropdown .choices__item {
  background-color: transparent !important;
  color: #FFFFFF !important;
  padding: 12px 20px !important;
  font-size: 0.95rem !important;
  font-weight: 500 !important;
  transition: all 0.2s ease !important;
}

/* Hover sur les options */
.choices__list--dropdown .choices__item--selectable.is-highlighted {
  background: linear-gradient(90deg, rgba(255, 62, 181, 0.25), rgba(255, 62, 181, 0.15)) !important;
  color: #FFFFFF !important;
}

/* Option sélectionnée dans le dropdown */
.choices__list--dropdown .choices__item--selectable[aria-selected="true"] {
  background: linear-gradient(135deg, #FF3EB5, #E30049) !important;
  color: #FFFFFF !important;
  font-weight: 600 !important;
}

/* Option désactivée (placeholder) */
.choices__item--disabled {
  color: #999999 !important;
  font-style: italic !important;
  background-color: transparent !important;
}

/* Champ de recherche dans le dropdown */
.choices__input {
  background-color: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid rgba(255, 62, 181, 0.3) !important;
  border-radius: 8px !important;
  color: #FFFFFF !important;
  padding: 8px 12px !important;
  margin: 5px 10px 10px !important;
}

.choices__input:focus {
  border-color: var(--rose-fuchsia) !important;
  outline: none !important;
  box-shadow: 0 0 10px rgba(255, 62, 181, 0.3) !important;
}

.choices__input::placeholder {
  color: rgba(255, 255, 255, 0.4) !important;
}

/* Icône de dropdown (flèche) */
.choices::after {
  border-color: #FF3EB5 transparent transparent !important;
  margin-top: -2px !important;
  transition: transform 0.3s ease !important;
}

.choices.is-open::after {
  border-color: transparent transparent #FF3EB5 !important;
  margin-top: 0 !important;
}

/* Message "No results" */
.choices__item--choice.has-no-results {
  color: rgba(255, 255, 255, 0.6) !important;
  background-color: transparent !important;
  font-style: italic !important;
}

/* Animation du dropdown */
@keyframes choicesDropdown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fix pour les selects dans les form-groups */
.form-group {
  position: relative;
  z-index: auto;
}

.form-group .choices {
  width: 100%;
}

.form-group .choices__inner {
  width: 100%;
}

/* Supprimer le style natif du select (caché par Choices.js) */
.form-group select.choices__input--cloned {
  display: none !important;
}

/* Supprimer les flèches des inputs type="number" sur tous les navigateurs */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* ============================================================================
   RESPONSIVE — FORMS
   ============================================================================ */

@media (max-width: 768px) {
  .form-group input,
  .form-group textarea,
  .form-group select {
    font-size: 16px; /* Prevent iOS auto-zoom on focus */
    padding: 13px;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .form-group label {
    font-size: 0.88rem;
  }

  .choices__inner {
    padding: 10px 13px !important;
    font-size: 16px !important; /* iOS zoom prevention */
  }

  .choices__list--dropdown:not(.fs-portal) .choices__list {
    max-height: 220px !important;
  }
}

@media (max-width: 480px) {
  .form-group input,
  .form-group textarea,
  .form-group select {
    padding: 12px;
    border-radius: 10px;
  }

  .form-group textarea {
    min-height: 120px;
  }

  .form-group label {
    font-size: 0.82rem;
    margin-bottom: 8px;
  }

  .choices__inner {
    padding: 9px 12px !important;
    min-height: 44px !important;
    border-radius: 10px !important;
  }
}

/* ============================================================================
   TOGGLE SWITCH — composant réutilisable
   ============================================================================ */

.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
  flex-shrink: 0;
  cursor: pointer;
}

.switch input.work-switch {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}

.switch-slider {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  transition: background 0.25s ease, border-color 0.25s ease;
  pointer-events: none;
}

.switch-slider::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
  transition: transform 0.25s ease;
}

.switch input.work-switch:checked ~ .switch-slider {
  background: linear-gradient(135deg, var(--rose-fuchsia, #FF3EB5), var(--rouge-passion, #E30049));
  border-color: transparent;
}

.switch input.work-switch:checked ~ .switch-slider::before {
  transform: translateX(22px);
}

.switch input.work-switch:focus-visible ~ .switch-slider {
  box-shadow: 0 0 0 3px rgba(255, 62, 181, 0.35);
}

/* Label texte à côté du switch */
.switch-option {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.switch-option span {
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.4;
}
