/* ============================================ */
/* AddressForm Component - Styles             */
/* Composant réutilisable formulaire adresse  */
/* ============================================ */

/* === Variables (héritées de design-tokens) === */
.address-form {
  --af-primary: var(--primary, #D4AF37);
  --af-primary-light: var(--primary-light, #F4D03F);
  --af-primary-dark: var(--primary-dark, #B8941F);
  --af-accent: var(--accent, #FF8C42);
  --af-success: var(--success, #10B981);
  --af-error: var(--error, #EF4444);
  --af-bg: var(--bg-light, #FFFFFF);
  --af-bg-secondary: var(--bg-light-secondary, #F9FAFB);
  --af-surface: #FFFFFF;
  --af-border: var(--gray-200, #E5E7EB);
  --af-border-light: var(--gray-100, #F3F4F6);
  --af-text: var(--text-primary, #1A1A2E);
  --af-text-secondary: var(--text-secondary, #4B5563);
  --af-text-muted: var(--text-muted, #9CA3AF);
  --af-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  --af-shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);
  --af-shadow-gold: 0 8px 30px rgba(212, 175, 55, 0.25);
  --af-radius: 12px;
  --af-radius-lg: 16px;
  --af-radius-full: 9999px;
  --af-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === Container principal === */
.address-form {
  background: var(--af-surface);
  border: 2px solid var(--af-border);
  border-radius: var(--af-radius-lg);
  padding: 20px;
  font-family: var(--font-family, 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
}

.address-form.loading {
  pointer-events: none;
  opacity: 0.7;
}

/* === Titre / Header === */
.address-form-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--af-border-light);
}

.address-form-header-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--af-primary), var(--af-accent));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.address-form-header-icon i {
  color: white;
  font-size: 1.1rem;
}

.address-form-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--af-text);
}

.address-form-header p {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--af-text-muted);
}

/* === Section recherche === */
.address-form-search {
  position: relative;
  margin-bottom: 16px;
}

.address-form-search-input {
  width: 100%;
  padding: 14px 16px 14px 44px;
  border: 2px solid var(--af-border);
  border-radius: var(--af-radius);
  font-size: 0.95rem;
  color: var(--af-text);
  background: var(--af-bg-secondary);
  transition: var(--af-transition);
  box-sizing: border-box;
}

.address-form-search-input::placeholder {
  color: var(--af-text-muted);
}

.address-form-search-input:focus {
  outline: none;
  border-color: var(--af-primary);
  background: var(--af-surface);
  box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.15);
}

.address-form-search-input:focus-visible {
  outline: 2px solid #D4AF37;
  outline-offset: 2px;
}

.address-form-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--af-text-muted);
  font-size: 1rem;
  pointer-events: none;
}

.address-form-search-input:focus + .address-form-search-icon,
.address-form-search-input:not(:placeholder-shown) + .address-form-search-icon {
  color: var(--af-primary);
}

/* === Suggestions === */
.address-form-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--af-surface);
  border: 2px solid var(--af-primary);
  border-top: none;
  border-radius: 0 0 var(--af-radius) var(--af-radius);
  max-height: 280px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  margin-top: -2px;
}

.address-form-suggestions.show {
  display: block;
}

.address-form-suggestion-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.2s;
  border-bottom: 1px solid var(--af-border-light);
}

.address-form-suggestion-item:last-child {
  border-bottom: none;
}

.address-form-suggestion-item:hover {
  background: rgba(212, 175, 55, 0.08);
}

.address-form-suggestion-item i {
  color: var(--af-primary);
  font-size: 0.9rem;
  flex-shrink: 0;
  width: 16px;
  text-align: center;
}

.address-form-suggestion-item span {
  font-size: 0.9rem;
  color: var(--af-text);
  line-height: 1.4;
}

.address-form-suggestion-item.loading,
.address-form-suggestion-item.no-results {
  justify-content: center;
  color: var(--af-text-muted);
  cursor: default;
  padding: 16px;
}

.address-form-suggestion-item.loading:hover,
.address-form-suggestion-item.no-results:hover {
  background: transparent;
}

.address-form-suggestion-item.loading i {
  animation: spin 1s linear infinite;
}

/* === Adresse sélectionnée === */
.address-form-selected {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.08), rgba(255, 140, 66, 0.08));
  border-radius: var(--af-radius);
  margin-bottom: 16px;
}

.address-form-selected-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--af-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.address-form-selected-icon i {
  font-size: 1rem;
}

.address-form-selected-info {
  flex: 1;
  min-width: 0;
}

.address-form-selected-street {
  display: block;
  font-weight: 600;
  color: var(--af-text);
  font-size: 0.95rem;
}

.address-form-selected-city {
  display: block;
  font-size: 0.85rem;
  color: var(--af-text-muted);
  margin-top: 2px;
}

.address-form-clear-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.05);
  color: var(--af-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--af-transition);
  flex-shrink: 0;
}

.address-form-clear-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--af-error);
}

/* === Carte === */
.address-form-map-container {
  border-radius: var(--af-radius);
  overflow: hidden;
  border: 2px solid var(--af-border);
  height: 220px;
  margin-bottom: 16px;
  position: relative;
}

.address-form-map {
  width: 100%;
  height: 100%;
  background: var(--af-bg-secondary);
}

.address-form-map-hint {
  position: absolute;
  bottom: 10px;
  left: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.75rem;
  text-align: center;
  pointer-events: none;
  z-index: 1000;
}

/* === Champs du formulaire === */
.address-form-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.address-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.address-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.address-form-group.full-width {
  grid-column: 1 / -1;
}

.address-form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--af-text);
}

.address-form-label .required {
  color: var(--af-error);
  margin-left: 2px;
}

.address-form-input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--af-border);
  border-radius: var(--af-radius);
  font-size: 0.9rem;
  color: var(--af-text);
  background: var(--af-surface);
  transition: var(--af-transition);
  box-sizing: border-box;
}

.address-form-input::placeholder {
  color: var(--af-text-muted);
}

.address-form-input:focus {
  outline: none;
  border-color: var(--af-primary);
  box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.15);
}

.address-form-input:focus-visible {
  outline: 2px solid #D4AF37;
  outline-offset: 2px;
}

.address-form-input.error {
  border-color: var(--af-error);
}

.address-form-input.error:focus {
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15);
}

.address-form-textarea {
  resize: vertical;
  min-height: 70px;
}

.address-form-error {
  font-size: 0.8rem;
  color: var(--af-error);
  display: none;
}

.address-form-group.has-error .address-form-error {
  display: block;
}

/* === Séparateur === */
.address-form-divider {
  height: 1px;
  background: var(--af-border-light);
  margin: 8px 0;
}

/* === Bouton validation === */
.address-form-submit {
  width: 100%;
  padding: 14px 24px;
  background: linear-gradient(135deg, var(--af-primary), var(--af-accent));
  border: none;
  border-radius: var(--af-radius);
  color: white;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--af-transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}

.address-form-submit:hover {
  transform: translateY(-2px);
  box-shadow: var(--af-shadow-gold);
}

.address-form-submit:active {
  transform: translateY(0);
}

.address-form-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.address-form-submit i {
  font-size: 1rem;
}

/* === État validé === */
.address-form.validated {
  border-color: var(--af-success);
}

.address-form.validated .address-form-header-icon {
  background: var(--af-success);
}

.address-form-validated-badge {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.05));
  border-radius: var(--af-radius);
  margin-top: 12px;
}

.address-form.validated .address-form-validated-badge {
  display: flex;
}

.address-form-validated-badge i {
  color: var(--af-success);
  font-size: 1.1rem;
}

.address-form-validated-badge span {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--af-success);
}

.address-form-edit-btn {
  margin-left: auto;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--af-success);
  border-radius: 6px;
  color: var(--af-success);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--af-transition);
}

.address-form-edit-btn:hover {
  background: var(--af-success);
  color: white;
}

/* === Mode compact (dans modal) === */
.address-form.compact {
  padding: 16px;
}

.address-form.compact .address-form-header {
  margin-bottom: 16px;
  padding-bottom: 12px;
}

.address-form.compact .address-form-header-icon {
  width: 36px;
  height: 36px;
}

.address-form.compact .address-form-header h3 {
  font-size: 0.95rem;
}

.address-form.compact .address-form-map-container {
  height: 180px;
}

.address-form.compact .address-form-input {
  padding: 10px 12px;
  font-size: 0.85rem;
}

.address-form.compact .address-form-submit {
  padding: 12px 20px;
  font-size: 0.9rem;
}

/* === Mode inline (sans bordure) === */
.address-form.inline {
  border: none;
  padding: 0;
  background: transparent;
}

.address-form.inline .address-form-header {
  display: none;
}

/* === Responsive === */
@media (max-width: 600px) {
  .address-form {
    padding: 16px;
  }

  .address-form-row {
    grid-template-columns: 1fr;
  }

  .address-form-map-container {
    height: 180px;
  }

  .address-form-header-icon {
    width: 40px;
    height: 40px;
  }

  .address-form-header h3 {
    font-size: 0.95rem;
  }

  .address-form-search-input {
    padding: 12px 14px 12px 40px;
    font-size: 0.9rem;
  }
}

/* === Animation spinner === */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* === Leaflet overrides === */
.address-form-map .leaflet-control-zoom {
  border: none !important;
  box-shadow: var(--af-shadow) !important;
}

.address-form-map .leaflet-control-zoom a {
  background: var(--af-surface) !important;
  color: var(--af-text) !important;
  border: none !important;
}

.address-form-map .leaflet-control-zoom a:hover {
  background: var(--af-bg-secondary) !important;
}

.address-form-map .leaflet-popup-content-wrapper {
  border-radius: var(--af-radius) !important;
  box-shadow: var(--af-shadow-lg) !important;
}

.address-form-map .leaflet-popup-tip {
  box-shadow: none !important;
}

/* === États dark mode (si supporté) === */
@media (prefers-color-scheme: dark) {
  .address-form.auto-dark {
    --af-bg: #1F2937;
    --af-bg-secondary: #374151;
    --af-surface: #1F2937;
    --af-border: #4B5563;
    --af-border-light: #374151;
    --af-text: #F9FAFB;
    --af-text-secondary: #D1D5DB;
    --af-text-muted: #9CA3AF;
  }
}
