/* Stili personalizzati per il checkout */

/* Container principale */
.checkout-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #f3f4f6;
  padding: 1rem;
}

/* Card del form */
.checkout-card {
  background: white;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 36rem;
  border: 1px solid #e5e7eb;
}

/* Header della card */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 1.5rem 0;
}

.card-title {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.2;
  margin: 0;
}

.card-subtitle {
  font-size: 0.875rem;
  color: #6b7280;
  margin-top: 0.25rem;
}

/* Logo */
.logo {
  width: 3rem;
  height: 3rem;
  border-radius: 0.5rem;
  margin-right: 1.5rem;
}

/* Custom Select con ricerca */
.custom-select-wrapper {
  position: relative;
  width: 100%;
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  background: white;
  user-select: none;
}

.custom-select-value {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select-arrow {
  margin-left: 0.5rem;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.custom-select-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  display: none;
  max-height: 300px;
  overflow: hidden;
}

.custom-select-dropdown.active {
  display: block;
  animation: slideDown 0.2s ease-out;
}

.custom-select-dropdown.active ~ .custom-select-trigger .custom-select-arrow {
  transform: rotate(180deg);
}

.custom-select-search {
  width: 100%;
  padding: 0.75rem;
  border: none;
  border-bottom: 1px solid #e5e7eb;
  font-size: 0.875rem;
  outline: none;
}

.custom-select-search:focus {
  border-bottom-color: #3b82f6;
  background-color: #f9fafb;
}

.custom-select-options {
  max-height: 240px;
  overflow-y: auto;
  overflow-x: hidden;
}

.custom-select-option {
  padding: 0.625rem 0.75rem;
  cursor: pointer;
  font-size: 0.875rem;
  transition: background-color 0.15s;
  user-select: none;
}

.custom-select-option:hover,
.custom-select-option.highlighted {
  background-color: #f3f4f6;
}

.custom-select-option.selected {
  background-color: #eff6ff;
  color: #2563eb;
  font-weight: 500;
}

.custom-select-option.selected:hover {
  background-color: #dbeafe;
}

.custom-select-no-results {
  padding: 1rem;
  text-align: center;
  color: #6b7280;
  font-size: 0.875rem;
}

/* Scrollbar personalizzata per le opzioni */
.custom-select-options::-webkit-scrollbar {
  width: 6px;
}

.custom-select-options::-webkit-scrollbar-track {
  background: #f9fafb;
}

.custom-select-options::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

.custom-select-options::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Form styles */
.form-body {
  padding: 1.5rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.form-input {
  display: flex;
  height: 2.5rem;
  width: 100%;
  border-radius: 0.375rem;
  border: 1px solid #d1d5db;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  transition: all 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-input:disabled {
  background-color: #f9fafb;
  cursor: not-allowed;
}

/* Radio buttons */
.radio-group {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
}

.radio-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.radio-input {
  width: 1rem;
  height: 1rem;
  color: #3b82f6;
}

.radio-label {
  font-size: 0.875rem;
}

/* Checkbox buttons */
.checkbox-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.75rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.375rem;
  transition: all 0.2s;
  background-color: #ffffff;
}

.checkbox-wrapper:hover {
  border-color: #3b82f6;
  background-color: #f9fafb;
}

.checkbox-input {
  width: 1.125rem;
  height: 1.125rem;
  margin-top: 0.125rem;
  cursor: pointer;
  flex-shrink: 0;
  accent-color: #3b82f6;
}

.checkbox-label {
  font-size: 0.875rem;
  line-height: 1.5;
  color: #374151;
  cursor: pointer;
  user-select: none;
}

.checkbox-link {
  color: #3b82f6;
  text-decoration: underline;
  font-weight: 500;
  transition: color 0.2s;
}

.checkbox-link:hover {
  color: #2563eb;
}

/* Messaggi di errore */
.error-message {
  color: #ef4444;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* Grid layout per campi affiancati */
.form-row {
  display: flex;
  gap: 1rem;
  flex-direction: row;
}

.form-col {
  flex: 1;
}

/* Submit button */
.submit-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  height: 2.5rem;
  padding: 0.5rem 1rem;
  width: 100%;
  background-color: #3b82f6;
  color: white;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s;
}

.submit-button:hover:not(:disabled) {
  background-color: #2563eb;
}

.submit-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.form-footer {
  padding: 1.5rem;
  border-top: 1px solid #e5e7eb;
}

/* Responsive */
@media (max-width: 640px) {
  .form-row {
    flex-direction: column;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .logo {
    margin-top: 1rem;
    margin-right: 0;
  }
}

/* Animazioni */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.3s ease-in-out;
}

/* Assicura che i campi azienda e privato siano sempre in colonna */
#companyFields,
#privatoFields {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Il form-row mantiene la direzione orizzontale per nome/cognome */
.form-row {
  display: flex;
  gap: 1rem;
  flex-direction: row;
}

/* Mantieni la struttura del layout anche quando i campi sono nascosti */
.form-group[style*="display: none"] {
  visibility: hidden;
  height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

/* Su mobile, anche nome/cognome vanno in colonna */
@media (max-width: 640px) {
  .form-row {
    flex-direction: column;
  }

  /* Mantieni lo spacing corretto su mobile anche con campi nascosti */
  .form-group[style*="display: none"] + .form-group {
    margin-top: 1rem;
  }
}

/* Evidenziazione speciale per il campo VIES */
#vies-field {
  background-color: #fef3c7; /* Giallo chiaro */
  border: 2px solid #f59e0b; /* Bordo giallo/arancione */
  border-radius: 0.5rem;
  padding: 1rem;
  margin: 0.5rem 0;
  position: relative;
}

#vies-field::before {
  content: "⚠️";
  position: absolute;
  top: -8px;
  left: 12px;
  background-color: #f59e0b;
  color: white;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

#vies-field .form-label {
  color: #92400e; /* Testo più scuro per contrasto */
  font-weight: 600;
  margin-bottom: 0.75rem;
}

#vies-field .radio-wrapper {
  background-color: white;
  border: 1px solid #d97706;
  border-radius: 0.375rem;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  transition: all 0.2s;
  cursor: pointer;
}

#vies-field .radio-wrapper:hover {
  background-color: #fef3c7;
  border-color: #f59e0b;
}

#vies-field .radio-wrapper:has(input:checked) {
  background-color: #fbbf24;
  border-color: #f59e0b;
  color: #92400e;
  font-weight: 500;
}

#vies-field .radio-input:checked {
  accent-color: #f59e0b;
}

/* Animazione di entrata per il campo VIES */
#vies-field.fade-in-vies {
  animation: slideInVies 0.4s ease-out;
}

@keyframes slideInVies {
  from {
    opacity: 0;
    transform: translateY(-20px);
    max-height: 0;
    padding: 0;
  }
  to {
    opacity: 1;
    transform: translateY(0);
    max-height: 200px;
    padding: 1rem;
  }
}

/* Stili specifici per mantenere la responsività con campi nascosti dinamicamente */
.form-body {
  transition: all 0.3s ease-in-out;
}

/* Assicura che il layout rimanga stabile quando i campi CAP/Provincia cambiano visibilità */
.form-row:has(.form-group[style*="display: none"]) {
  justify-content: flex-start;
}

/* Gestione specifica per la riga CAP/Provincia */
#zip.form-input[style*="display: none"] ~ * {
  flex-basis: 100%;
}

/* Mantieni l'altezza minima del container per evitare salti del layout */
.checkout-card {
  min-height: auto;
  transition: height 0.3s ease-in-out;
}

/* Gestione della transizione quando i campi cambiano stato */
.form-group {
  transition: all 0.3s ease-in-out;
}

.form-group[style*="display: none"] {
  opacity: 0;
  transform: translateY(-10px);
  margin-bottom: 0 !important;
}

/* Classe per nascondere i campi mantenendo la struttura responsive */
.form-group.hidden-field {
  opacity: 0;
  visibility: hidden;
  height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease-in-out;
}

/* Gestione speciale per form-row con campi nascosti */
.form-row:has(.hidden-field) .form-col:not(:has(.hidden-field)) {
  flex-basis: 100%;
  max-width: 100%;
}

/* Quando il campo città è nascosto, il paese prende tutta la larghezza */
.form-row:has(#city.hidden-field) .form-col:has(#country-select-container),
.form-row:has(.form-group:has(#city).hidden-field)
  .form-col:has(#country-select-container) {
  flex-basis: 100%;
  max-width: 100%;
}

/* Tooltip per VIES */
.vies-label-wrapper {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.vies-tooltip-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.vies-tooltip-label {
  font-size: 0.75rem;
  color: #6b7280;
  font-weight: 500;
}

.vies-tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background-color: #3b82f6;
  color: white;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
  cursor: help;
  user-select: none;
  flex-shrink: 0;
}

.vies-tooltip:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 25px;
  right: 0;
  transform: translateX(0);
  background-color: #1f2937;
  color: white;
  padding: 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.4;
  white-space: nowrap;
  max-width: 280px;
  white-space: normal;
  width: 280px;
  z-index: 1001;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.vies-tooltip:hover::before {
  content: "";
  position: absolute;
  bottom: 20px;
  right: 10px;
  transform: translateX(0);
  border: 5px solid transparent;
  border-top-color: #1f2937;
  z-index: 1001;
}
