/* ============================================
   SUPERMARKET FILTER - STICKY WRAPPER
   ============================================ */

.sp-market-filter-sticky {
  position: sticky;
  top: 64px; /* navbar height */
  z-index: 1020; /* below navbar (1030) but above content */
  padding-top: 0.5rem;
  padding-bottom: 0;
  transition: box-shadow 0.2s ease;
}

.sp-market-filter-sticky.is-stuck {
  background: rgba(248, 249, 250, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.sp-market-filter-sticky.is-stuck .sp-market-filter {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  margin-bottom: 0;
}

/* Adjust for taller navbar on tablet */
@media (min-width: 576px) {
  .sp-market-filter-sticky {
    top: 68px;
  }
}

/* Adjust for taller navbar on desktop */
@media (min-width: 768px) {
  .sp-market-filter-sticky {
    top: 72px;
  }
}

/* ============================================
   SUPERMARKET FILTER COMPONENT
   ============================================ */

.sp-market-filter {
  background: white;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  margin-bottom: 1.5rem;
  overflow: hidden;
  transition: box-shadow 0.3s ease;
}

.sp-market-filter:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

/* Header row: wraps the toggle button + share button + flag as flex siblings */
.sp-market-filter__header-row {
  display: flex;
  align-items: center;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  position: relative;
  z-index: 1;
}

/* Header toggle button takes all available space */
.sp-market-filter__header {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 0.5rem 1rem 1.25rem;
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.2s ease;
  font-size: 1rem;
  font-weight: 600;
  color: #1a1a1a;
  user-select: none;
}

.sp-market-filter__header-row:hover {
  background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
}

.sp-market-filter__icon {
  font-size: 1.5rem;
}

.sp-market-filter__title {
  flex: 1;
  text-align: left;
}

.sp-market-filter__count {
  font-size: 0.8rem;
  font-weight: 500;
  color: #6c757d;
  margin-left: 0;
  line-height: 1.2;
}

@media (max-width: 400px) {
  .sp-market-filter__count {
    font-size: 0.7rem;
  }
  .sp-market-filter__icon {
    font-size: 1.2rem;
  }
}

.sp-market-filter__chevron {
  transform: rotate(0deg);
  transition: transform 0.3s ease;
  color: #6c757d;
}

.sp-market-filter__header[aria-expanded="true"] .sp-market-filter__chevron {
  transform: rotate(180deg);
}

/* Body */
.sp-market-filter__body {
  border-top: 1px solid #e9ecef;
  max-height: 600px;
  opacity: 1;
  transition: max-height 0.3s ease, opacity 0.2s ease;
  overflow: hidden;
}

.sp-market-filter__body.is-collapsed {
  max-height: 0 !important;
  opacity: 0 !important;
  visibility: hidden !important;
  overflow: hidden !important;
  border-top: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* List */
.sp-market-filter__list {
  max-height: 400px;
  overflow-y: auto;
}

/* Scrollbar styling */
.sp-market-filter__list::-webkit-scrollbar {
  width: 8px;
}

.sp-market-filter__list::-webkit-scrollbar-track {
  background: #f1f3f5;
}

.sp-market-filter__list::-webkit-scrollbar-thumb {
  background: #adb5bd;
  border-radius: 4px;
}

.sp-market-filter__list::-webkit-scrollbar-thumb:hover {
  background: #868e96;
}

/* Market Items */
.sp-market-filter__item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid #f1f3f5;
  cursor: pointer;
  transition: background 0.2s ease;
}

.sp-market-filter__item:last-child {
  border-bottom: none;
}

.sp-market-filter__item:hover {
  background: #f8f9fa;
}

.sp-market-filter__item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: #136213;
}

.sp-market-filter__logo {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sp-market-filter__logo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.sp-market-filter__logo span {
  font-size: 1.5rem;
}

.sp-market-filter__name {
  flex: 1;
  font-weight: 600;
  color: #1a1a1a;
  font-size: 0.9375rem;
}

/* Distance badges */
.sp-market-filter__distance {
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  white-space: nowrap;
}

.sp-market-filter__distance--near {
  background: #d4edda;
  color: #155724;
}

.sp-market-filter__distance--medium {
  background: #fff3cd;
  color: #856404;
}

.sp-market-filter__distance--far {
  background: #f8d7da;
  color: #721c24;
}

/* Actions */
.sp-market-filter__actions {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: #f8f9fa;
  border-top: 1px solid #e9ecef;
}

.sp-market-filter__action--primary {
  flex: 1;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, #136213 0%, #0a4a0a 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sp-market-filter__action--primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(19, 98, 19, 0.3);
}

.sp-market-filter__action--primary:active {
  transform: translateY(0);
}

.sp-market-filter__action--secondary {
  padding: 0.75rem 1rem;
  background: white;
  color: #6c757d;
  border: 2px solid #e9ecef;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sp-market-filter__action--secondary:hover {
  border-color: #136213;
  color: #136213;
  background: #f8f9fa;
}

/* Hint for anonymous users */
.sp-market-filter__hint {
  padding: 0.875rem 1.25rem;
  background: #e7f5ff;
  border-top: 1px solid #339af0;
  font-size: 0.875rem;
  color: #1864ab;
  text-align: center;
}

.sp-market-filter__hint a {
  color: #1864ab;
  text-decoration: underline;
  font-weight: 600;
}

.sp-market-filter__hint a:hover {
  color: #0c4a6e;
}

/* Mobile optimizations */
@media (max-width: 768px) {
  .sp-market-filter {
    border-radius: 12px;
    margin-bottom: 1rem;
  }

  .sp-market-filter__header {
    padding: 0.875rem 1rem;
    font-size: 0.9375rem;
  }

  .sp-market-filter__item {
    padding: 0.75rem 1rem;
  }

  .sp-market-filter__name {
    font-size: 0.875rem;
  }

  .sp-market-filter__actions {
    flex-direction: column;
    gap: 0.5rem;
  }

  .sp-market-filter__action--primary,
  .sp-market-filter__action--secondary {
    width: 100%;
    padding: 0.875rem;
  }

  .sp-market-filter__action--secondary {
    order: 2;
  }

  .sp-market-filter__action--primary {
    order: 1;
  }

  .sp-market-filter__logo {
    width: 35px;
    height: 35px;
  }
}

/* Small mobile devices */
@media (max-width: 480px) {
  .sp-market-filter__header {
    padding: 0.75rem 0.875rem;
  }

  .sp-market-filter__item {
    padding: 0.625rem 0.875rem;
    gap: 0.5rem;
  }

  .sp-market-filter__logo {
    width: 30px;
    height: 30px;
  }

  .sp-market-filter__distance {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  .sp-market-filter__chevron,
  .sp-market-filter__header,
  .sp-market-filter__item,
  .sp-market-filter__action--primary,
  .sp-market-filter__action--secondary {
    transition: none;
  }
}

/* Focus states for keyboard navigation */
.sp-market-filter__header:focus-visible,
.sp-market-filter__item input:focus-visible,
.sp-market-filter__action--primary:focus-visible,
.sp-market-filter__action--secondary:focus-visible {
  outline: 2px solid #136213;
  outline-offset: 2px;
}

/* Country flag in filter header row */
.sp-market-filter__country-flag {
  font-size: 1.4rem;
  text-decoration: none;
  display: flex;
  align-items: center;
  padding: 4px 8px;
  margin-right: 0.5rem;
  border-radius: 8px;
  flex-shrink: 0;
  line-height: 1;
  transition: background 0.15s ease;
}

.sp-market-filter__country-flag:hover {
  background: rgba(0, 0, 0, 0.08);
}

/* Override global 44px min-size on header-row buttons/links */
.sp-market-filter__header-row button,
.sp-market-filter__header-row a {
  min-width: 0 !important;
  min-height: 0 !important;
}

/* Share button embedded in the filter header row */
.sp-market-filter__share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: none;
  border-radius: 8px;
  color: #6c757d;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.sp-market-filter__share-btn:hover {
  background: rgba(0, 0, 0, 0.08);
  color: #136213;
}

.sp-market-filter__share-btn:focus-visible {
  outline: 2px solid #136213;
  outline-offset: 2px;
}

/* ============================================
   CITY SELECTOR (dropdown — scales to any number of cities)
   ============================================ */

.sp-market-filter__city-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  border-bottom: 1px solid #e9ecef;
}

.sp-market-filter__city-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #495057;
  white-space: nowrap;
}

.sp-market-filter__city-select {
  flex: 1;
  padding: 0.35rem 0.5rem;
  border: 1px solid #ced4da;
  border-radius: 8px;
  background: #fff;
  font-size: 0.8rem;
  color: #212529;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 20 20' fill='%236c757d'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  padding-right: 1.5rem;
}

.sp-market-filter__city-select:focus {
  border-color: #2e7d32;
  box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.15);
}

@media (prefers-reduced-motion: reduce) {
  .sp-market-filter__share-btn {
    transition: none;
  }
}

/* When filter is collapsed and sticky, compact header */
.sp-market-filter-sticky.is-stuck .sp-market-filter__body.is-collapsed + .sp-market-filter__header {
  padding-top: 0.625rem;
  padding-bottom: 0.625rem;
}

/* Loading state (optional, for future use) */
.sp-market-filter--loading {
  opacity: 0.6;
  pointer-events: none;
}

.sp-market-filter--loading .sp-market-filter__action--primary::after {
  content: '⏳';
  margin-left: 0.5rem;
}

/* ============================================
   CITY SWITCH CONFIRMATION MODAL
   ============================================ */

.sp-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0);
  -webkit-backdrop-filter: blur(0);
  transition: background 0.2s ease, backdrop-filter 0.2s ease;
  padding: 1rem;
}

.sp-confirm-overlay.is-visible {
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.sp-confirm-card {
  background: #fff;
  border-radius: 20px;
  padding: 2rem 1.75rem 1.5rem;
  max-width: 340px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  transform: scale(0.9) translateY(20px);
  opacity: 0;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
}

.sp-confirm-overlay.is-visible .sp-confirm-card {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.sp-confirm-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  line-height: 1;
}

.sp-confirm-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 0.5rem;
}

.sp-confirm-text {
  font-size: 0.9375rem;
  color: #495057;
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

.sp-confirm-text strong {
  color: #136213;
  font-weight: 700;
}

.sp-confirm-warning {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  margin-bottom: 1.25rem;
  background: #fff3cd;
  color: #664d03;
  border-radius: 10px;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.3;
}

.sp-confirm-warning i {
  font-size: 1rem;
  flex-shrink: 0;
}

.sp-confirm-actions {
  display: flex;
  gap: 0.75rem;
}

.sp-confirm-actions--stack {
  flex-direction: column;
  gap: 0.5rem;
}

.sp-confirm-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  min-height: 0 !important;
  min-width: 0 !important;
}

.sp-confirm-btn--cancel {
  background: #f1f3f5;
  color: #495057;
}

.sp-confirm-btn--cancel:hover {
  background: #e9ecef;
  color: #212529;
}

.sp-confirm-btn--accept {
  background: linear-gradient(135deg, #136213 0%, #0a4a0a 100%);
  color: #fff;
}

.sp-confirm-btn--accept:hover {
  box-shadow: 0 4px 12px rgba(19, 98, 19, 0.35);
  transform: translateY(-1px);
}

.sp-confirm-btn--accept:active {
  transform: translateY(0);
}

.sp-confirm-btn--danger {
  background: #fff;
  color: #dc3545;
  border: 2px solid #f1f3f5;
}

.sp-confirm-btn--danger:hover {
  background: #fff5f5;
  border-color: #dc3545;
}

.sp-confirm-btn--danger i {
  margin-right: 0.25rem;
}

.sp-confirm-btn--accept i {
  margin-right: 0.25rem;
}

.sp-confirm-btn:focus-visible {
  outline: 2px solid #136213;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .sp-confirm-overlay,
  .sp-confirm-card,
  .sp-confirm-btn {
    transition: none;
  }
}

/* ============================================
   CART TRANSFER BANNER
   ============================================ */

.sp-transfer-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  margin: 0 0.5rem 1rem;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 600;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.sp-transfer-banner.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.sp-transfer-banner--success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.sp-transfer-banner--partial {
  background: #fff3cd;
  color: #664d03;
  border: 1px solid #ffecb5;
}

.sp-transfer-banner--empty {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.sp-transfer-banner__content {
  flex: 1;
  line-height: 1.4;
}

.sp-transfer-banner__content i {
  margin-right: 0.25rem;
}

.sp-transfer-banner__close {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
  padding: 0.25rem;
  font-size: 0.875rem;
  min-width: 0 !important;
  min-height: 0 !important;
}

.sp-transfer-banner__close:hover {
  opacity: 1;
}
