/* ==========================================
   POPUP SELEZIONE SEDE
   ========================================== */

#warehouse-popup-overlay {
  position: sticky;
  top: 0;
  z-index: 9999;
  padding: 12px 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.94));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

#warehouse-popup {
  background: linear-gradient(135deg, #fff8ef 0%, #ffffff 100%);
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 16px;
  border-radius: 18px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.1);
  text-align: left;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  animation: none;
}

@media (prefers-reduced-motion: reduce) {
  #warehouse-popup {
    animation: none;
  }
}

#warehouse-popup h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: #111827;
}

#warehouse-popup p {
  margin: 0;
  font-size: 14px;
  color: #475569;
  line-height: 1.4;
}

.warehouse-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.warehouse-btn {
  min-width: 160px;
  padding: 12px 18px;
  font-size: 16px;
  font-weight: 700;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #b91c1c;
  color: #fff;
  box-shadow: 0 8px 20px rgba(185, 28, 28, 0.18);
  
  /* Migliora risposta touch */
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.warehouse-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(185, 28, 28, 0.24);
}

.warehouse-btn:active {
  transform: translateY(-1px);
}

.warehouse-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Stile per il focus da tastiera per accessibilità WCAG */
.warehouse-btn:focus-visible {
  outline: 3px solid #b91c1c;
  outline-offset: 3px;
}

/* ==========================================
   BADGE FISSO (SEDE SELEZIONATA)
   ========================================== */

.warehouse-badge {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 999998;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 0, 0, 0.10);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  backdrop-filter: saturate(120%);
  -webkit-backdrop-filter: saturate(120%);
}

.warehouse-badge-icon {
  font-size: 14px;
  line-height: 1;
  opacity: 0.9;
}

.warehouse-badge-text {
  font-size: 13px;
  font-weight: 600;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.warehouse-badge-btn {
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 10px;
  line-height: 1;
  opacity: 0.85;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.warehouse-badge-btn:hover {
  opacity: 1;
  transform: translateY(-1px);
  background: rgba(0, 0, 0, 0.05);
}

.warehouse-badge-btn:active {
  transform: translateY(0);
}

/* ==========================================
   PULSANTE NEL MENU - VERSIONE ELEGANTE
   ========================================== */

.menu-item-warehouse-switch {
  position: relative;
}

.warehouse-menu-switch {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  padding: 8px 14px !important;
  background: transparent !important;
  color: inherit !important;
  border-radius: 6px !important;
  font-weight: 400 !important;
  font-size: 14px !important;
  transition: all 0.2s ease !important;
  text-decoration: none !important;
  border: 1px solid rgba(0, 0, 0, 0.08) !important;
  opacity: 0.85;
}

.warehouse-menu-switch:hover {
  background: rgba(0, 0, 0, 0.04) !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
  opacity: 1;
  transform: translateY(-1px);
}

.warehouse-icon {
  font-size: 13px;
  opacity: 0.7;
}

.warehouse-current {
  font-weight: 500;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.warehouse-arrow {
  opacity: 0.5;
  font-size: 11px;
  font-weight: 300;
}

/* Variante scura per menu con sfondo scuro */
@media (prefers-color-scheme: dark) {
  .warehouse-menu-switch {
    border-color: rgba(255, 255, 255, 0.1) !important;
  }
  
  .warehouse-menu-switch:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
  }
}

/* ==========================================
   STATO LOADING
   ========================================== */

.warehouse-btn.loading {
  position: relative;
  color: transparent;
}

.warehouse-btn.loading::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  top: 50%;
  left: 50%;
  margin-left: -10px;
  margin-top: -10px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ==========================================
   NOTIFICA CARRELLO
   ========================================== */

.woocommerce-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

#cart-change-warehouse {
  white-space: nowrap;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  color: #fff !important;
  border: none !important;
  padding: 8px 18px !important;
  border-radius: 20px !important;
  font-weight: 600 !important;
  transition: all 0.2s ease !important;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#cart-change-warehouse:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

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

@media (max-width: 768px) {
  #warehouse-popup {
    padding: 16px;
    flex-direction: column;
    align-items: flex-start;
  }
  
  #warehouse-popup h2 {
    font-size: 18px;
  }
  
  .warehouse-buttons {
    width: 100%;
    justify-content: stretch;
  }
  
  .warehouse-btn {
    min-width: 100%;
    padding: 14px 18px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  
  .warehouse-menu-switch {
    font-size: 13px !important;
    padding: 6px 10px !important;
    gap: 4px;
    -webkit-tap-highlight-color: transparent !important;
    touch-action: manipulation !important;
  }
  
  .warehouse-icon {
    font-size: 12px;
  }
  
  .warehouse-current {
    max-width: 90px;
    font-size: 12px;
  }
  
  .warehouse-arrow {
    display: none;
  }
  
  #cart-change-warehouse {
    padding: 10px 20px !important;
    -webkit-tap-highlight-color: transparent !important;
    touch-action: manipulation !important;
  }
}

/* ==========================================
   VARIANTE ULTRA-MINIMALISTA (OPZIONALE)
   Decommentare se si vuole un menu ancora più discreto
   ========================================== */

/*
.warehouse-menu-switch {
  border: none !important;
  background: transparent !important;
  padding: 6px 10px !important;
}

.warehouse-menu-switch:hover {
  background: rgba(0, 0, 0, 0.05) !important;
}

.warehouse-icon {
  opacity: 0.5;
}
*/
