/* ========================================
 * AMENITY-BADGE.CSS - AMENITY FILTER BADGE STYLES
 * FILE: /css/discover/components/amenity-badge.css
 * VERSION: v=20250101
 * ======================================== */
/*
 * PURPOSE: Professional amenity filter badges with clear buttons
 * COVERAGE: Desktop (top bar) + mobile (below top bar) responsive rules
 * FEATURES: Responsive positioning, dark mode support, smooth transitions
 * IMPORTED BY: discover.html
 * STATUS: ACTIVE
 */

/* Base badge styling - Similar to datetime but with distinct color scheme */
.amenity-filter-badge {
  display: flex;
  align-items: center;
  padding: 0.375rem 0.75rem;
  background: var(--discover-amenity-badge-surface, rgba(240, 253, 244, 0.9));
  border: 1px solid var(--discover-amenity-badge-border, rgba(22, 101, 52, 0.26));
  border-radius: var(--border-radius-base, 0.5rem);
  transition: transform var(--transition-base, 0.2s ease), opacity var(--transition-base, 0.2s ease);
  white-space: nowrap;
  max-width: min(100%, 16rem);
  flex-shrink: 0;
  height: fit-content;
  min-height: 1.75rem;
  min-width: 0;
}

.amenity-filter-badge:hover {
  background: var(--discover-amenity-badge-surface-hover, rgba(236, 250, 241, 0.96));
  border-color: var(--discover-amenity-badge-border-hover, rgba(22, 101, 52, 0.36));
}

/* Base badge text — truncate long amenity labels */
.amenity-filter-badge .badge-text {
  color: var(--discover-amenity-badge-text, #164536);
  font-weight: 500;
  line-height: 1.25rem;
  display: block;
  min-width: 0;
  max-width: 12.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Clear button — size/centering: filter-badge-clear.css */
.amenity-filter-badge .badge-clear-btn {
  padding: 0 !important;
}

.amenity-filter-badge .badge-clear-btn:hover {
  background: rgba(22, 101, 52, 0.08);
}

.amenity-filter-badge .badge-clear-btn:active {
  transform: scale(0.95);
}

.amenity-filter-badge .badge-clear-btn svg {
  color: var(--discover-amenity-badge-icon, rgba(22, 101, 52, 0.72));
}

.amenity-filter-badge .badge-clear-btn:hover svg {
  color: var(--discover-amenity-badge-icon-hover, #123d2c);
}

/* Badges container */
.amenity-filter-badges-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
  flex-shrink: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.amenity-filter-badges-container::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

/* Commercial active filter - amber/orange (matches amenities popup Commercial control) */
.amenity-filter-badge.amenity-filter-badge--commercial {
  background: rgba(255, 247, 237, 0.95);
  border-color: rgba(217, 119, 6, 0.45);
}

.amenity-filter-badge.amenity-filter-badge--commercial:hover {
  background: rgba(255, 237, 213, 0.98);
  border-color: rgba(217, 119, 6, 0.6);
}

.amenity-filter-badge.amenity-filter-badge--commercial .badge-text {
  color: #9a3412;
}

.amenity-filter-badge.amenity-filter-badge--commercial .badge-clear-btn:hover {
  background: rgba(217, 119, 6, 0.12);
}

.amenity-filter-badge.amenity-filter-badge--commercial .badge-clear-btn svg {
  color: #c2410c;
}

.amenity-filter-badge.amenity-filter-badge--commercial .badge-clear-btn:hover svg {
  color: #9a3412;
}

.dark .amenity-filter-badge.amenity-filter-badge--commercial {
  background: rgba(180, 83, 9, 0.28);
  border-color: rgba(251, 191, 36, 0.42);
}

.dark .amenity-filter-badge.amenity-filter-badge--commercial:hover {
  background: rgba(180, 83, 9, 0.38);
  border-color: rgba(251, 191, 36, 0.55);
}

.dark .amenity-filter-badge.amenity-filter-badge--commercial .badge-text {
  color: #fde68a;
}

.dark .amenity-filter-badge.amenity-filter-badge--commercial .badge-clear-btn:hover {
  background: rgba(251, 191, 36, 0.15);
}

.dark .amenity-filter-badge.amenity-filter-badge--commercial .badge-clear-btn svg {
  color: #fbbf24;
}

.dark .amenity-filter-badge.amenity-filter-badge--commercial .badge-clear-btn:hover svg {
  color: #fde68a;
}

/* Dark mode support */
.dark .amenity-filter-badge {
  background: var(--discover-amenity-badge-dark-surface, rgba(15, 56, 34, 0.42));
  border-color: var(--discover-amenity-badge-dark-border, rgba(45, 212, 115, 0.26));
}

.dark .amenity-filter-badge:hover {
  background: var(--discover-amenity-badge-dark-surface-hover, rgba(15, 56, 34, 0.52));
  border-color: var(--discover-amenity-badge-dark-border-hover, rgba(45, 212, 115, 0.38));
}

.dark .amenity-filter-badge .badge-text {
  color: var(--discover-amenity-badge-dark-text, #b6e9c9);
}

.dark .amenity-filter-badge .badge-clear-btn:hover {
  background: rgba(45, 212, 115, 0.12);
}

.dark .amenity-filter-badge .badge-clear-btn svg {
  color: var(--discover-amenity-badge-dark-icon, rgba(186, 244, 208, 0.88));
}

.dark .amenity-filter-badge .badge-clear-btn:hover svg {
  color: var(--discover-amenity-badge-dark-icon-hover, #d1fae5);
}

/* Desktop badge - in list-header applied-filter rail (≥1101px) */
@media (min-width: 1101px) {
  /* Hidden by default; AmenityFilterBadge toggles .hidden. Show only when populated. */
  #amenity-filter-badges-desktop {
    display: none;
    align-items: center;
    margin-left: 0 !important;
    flex: 1 1 0;
    min-width: 0;
    overflow-x: auto !important;
  }

  .listings-applied-filters-rail--desktop #amenity-filter-badges-desktop,
  .discover-top-bar-bottom-row #amenity-filter-badges-desktop {
    margin-left: 0 !important;
    align-self: center !important;
  }

  #amenity-filter-badges-desktop:not(.hidden) {
    display: flex !important;
  }

  .listings-applied-filters-rail--desktop .amenity-filter-badges-container,
  .discover-top-bar-bottom-row .amenity-filter-badges-container {
    max-width: none;
  }

  #amenity-filter-badges-sheet {
    display: none !important;
  }
}

/* Mobile/Tablet badge - in list-header applied-filter rail (≤1100px) */
@media (max-width: 1100px) {
  #amenity-filter-badges-desktop {
    display: none !important;
  }

  /* Mobile badge container - now inside wrapper, no longer fixed */
  #amenity-filter-badges-sheet {
    display: flex;
    align-items: center;
    position: static; /* No longer fixed - inside wrapper */
    flex: 0 0 auto;
    min-width: max-content;
    width: max-content;
    height: auto;
    background: transparent;
    border: none;
    padding: 0;
    box-shadow: none;
  }

  .dark #amenity-filter-badges-sheet {
    background: transparent;
    border: none;
  }

  #amenity-filter-badges-sheet-container {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap; /* Prevent wrapping - will scroll horizontally */
    width: max-content;
    max-width: none;
    margin: 0;
    padding: 0;
    flex-shrink: 0;
  }

  .mobile-filter-badges-wrapper {
    pointer-events: none;
  }

  .mobile-filter-badges-container {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    overflow-y: visible;
    overscroll-behavior-x: contain;
    scroll-padding-inline: 1rem;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    pointer-events: auto;
  }

  .mobile-filter-badges-container::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
  }

  .mobile-filter-badges-container.is-overflowing {
    padding-right: 1.75rem !important;
    mask-image: linear-gradient(to right, #000 calc(100% - 2.25rem), transparent);
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2.25rem), transparent);
  }

  /* High contrast on map: badges in mobile wrapper sit on map with solid background and shadow */
  #mobile-filter-badges-wrapper .amenity-filter-badge {
    background: var(--discover-amenity-badge-map-surface, rgba(252, 252, 251, 0.98)) !important;
    border: 1px solid var(--discover-amenity-badge-map-border, rgba(22, 101, 52, 0.32)) !important;
    box-shadow: var(--discover-amenity-badge-map-shadow, 0 2px 12px rgba(28, 25, 23, 0.1), 0 1px 2px rgba(28, 25, 23, 0.05)) !important;
  }

  #mobile-filter-badges-wrapper .amenity-filter-badge:hover {
    background: rgba(255, 255, 255, 0.99) !important;
    border-color: var(--discover-amenity-badge-map-border-hover, rgba(22, 101, 52, 0.42)) !important;
    box-shadow: var(--discover-amenity-badge-map-shadow-hover, 0 4px 16px rgba(28, 25, 23, 0.12), 0 1px 3px rgba(28, 25, 23, 0.06)) !important;
  }

  #mobile-filter-badges-wrapper .amenity-filter-badge .badge-text {
    color: var(--discover-amenity-badge-map-text, #174a36) !important;
    font-weight: 600 !important;
  }

  #mobile-filter-badges-wrapper .amenity-filter-badge .badge-clear-btn svg {
    color: var(--discover-amenity-badge-map-icon, rgba(23, 74, 54, 0.88)) !important;
  }

  #mobile-filter-badges-wrapper .amenity-filter-badge .badge-clear-btn:hover svg {
    color: var(--discover-amenity-badge-map-icon-hover, #0f2e1f) !important;
  }

  .dark #mobile-filter-badges-wrapper .amenity-filter-badge {
    background: var(--discover-amenity-badge-map-dark-surface, rgba(15, 56, 34, 0.9)) !important;
    border-color: var(--discover-amenity-badge-map-dark-border, rgba(45, 212, 115, 0.34)) !important;
    box-shadow: var(--discover-amenity-badge-map-dark-shadow, 0 2px 12px rgba(0, 0, 0, 0.28), 0 1px 2px rgba(0, 0, 0, 0.16)) !important;
  }

  .dark #mobile-filter-badges-wrapper .amenity-filter-badge:hover {
    background: var(--discover-amenity-badge-map-dark-surface-hover, rgba(15, 56, 34, 0.94)) !important;
    border-color: var(--discover-amenity-badge-map-dark-border-hover, rgba(45, 212, 115, 0.46)) !important;
    box-shadow: var(--discover-amenity-badge-map-dark-shadow-hover, 0 4px 16px rgba(0, 0, 0, 0.32), 0 1px 3px rgba(0, 0, 0, 0.18)) !important;
  }

  .dark #mobile-filter-badges-wrapper .amenity-filter-badge .badge-text {
    color: var(--discover-amenity-badge-dark-text, #b6e9c9) !important;
    font-weight: 600 !important;
  }

  .dark #mobile-filter-badges-wrapper .amenity-filter-badge .badge-clear-btn svg {
    color: var(--discover-amenity-badge-dark-icon, rgba(186, 244, 208, 0.88)) !important;
  }

  .dark #mobile-filter-badges-wrapper .amenity-filter-badge .badge-clear-btn:hover svg {
    color: var(--discover-amenity-badge-dark-icon-hover, #d1fae5) !important;
  }

  #mobile-filter-badges-wrapper .amenity-filter-badge.amenity-filter-badge--commercial {
    background: rgba(255, 247, 237, 0.97) !important;
    border-color: rgba(217, 119, 6, 0.55) !important;
  }

  #mobile-filter-badges-wrapper .amenity-filter-badge.amenity-filter-badge--commercial:hover {
    background: rgba(255, 237, 213, 0.99) !important;
    border-color: rgba(217, 119, 6, 0.7) !important;
  }

  #mobile-filter-badges-wrapper .amenity-filter-badge.amenity-filter-badge--commercial .badge-text {
    color: #9a3412 !important;
  }

  #mobile-filter-badges-wrapper .amenity-filter-badge.amenity-filter-badge--commercial .badge-clear-btn svg {
    color: #7c2d12 !important;
  }

  .dark #mobile-filter-badges-wrapper .amenity-filter-badge.amenity-filter-badge--commercial {
    background: rgba(120, 53, 15, 0.92) !important;
    border-color: rgba(251, 191, 36, 0.5) !important;
  }

  .dark #mobile-filter-badges-wrapper .amenity-filter-badge.amenity-filter-badge--commercial:hover {
    background: rgba(146, 64, 14, 0.96) !important;
    border-color: rgba(251, 191, 36, 0.65) !important;
  }

  .dark #mobile-filter-badges-wrapper .amenity-filter-badge.amenity-filter-badge--commercial .badge-text {
    color: #fde68a !important;
  }

  .dark #mobile-filter-badges-wrapper .amenity-filter-badge.amenity-filter-badge--commercial .badge-clear-btn svg {
    color: #fffbeb !important;
  }
}

/* Touch devices need the clear affordance visible without relying on hover. */
@media (max-width: 1100px) and (hover: none) and (pointer: coarse) {
  #mobile-filter-badges-wrapper .amenity-filter-badge .badge-clear-btn {
    background: rgba(22, 101, 52, 0.08) !important;
    border: 1px solid rgba(22, 101, 52, 0.22) !important;
    color: var(--discover-amenity-badge-map-text, #174a36) !important;
  }

  #mobile-filter-badges-wrapper .amenity-filter-badge .badge-clear-btn svg {
    color: var(--discover-amenity-badge-map-icon, rgba(23, 74, 54, 0.88)) !important;
    stroke-width: 2.5 !important;
  }

  #mobile-filter-badges-wrapper .amenity-filter-badge .badge-clear-btn svg path {
    stroke: var(--discover-amenity-badge-map-icon, rgba(23, 74, 54, 0.88)) !important;
    stroke-width: 2.5 !important;
  }

  .dark #mobile-filter-badges-wrapper .amenity-filter-badge .badge-clear-btn svg {
    color: var(--discover-amenity-badge-dark-icon, rgba(186, 244, 208, 0.88)) !important;
  }

  .dark #mobile-filter-badges-wrapper .amenity-filter-badge .badge-clear-btn svg path {
    stroke: var(--discover-amenity-badge-dark-icon, rgba(186, 244, 208, 0.88)) !important;
  }

  #mobile-filter-badges-wrapper .amenity-filter-badge.amenity-filter-badge--commercial .badge-clear-btn svg {
    color: #7c2d12 !important;
  }

  #mobile-filter-badges-wrapper .amenity-filter-badge.amenity-filter-badge--commercial .badge-clear-btn svg path {
    stroke: #7c2d12 !important;
  }

  .dark #mobile-filter-badges-wrapper .amenity-filter-badge.amenity-filter-badge--commercial .badge-clear-btn svg {
    color: #fffbeb !important;
  }

  .dark #mobile-filter-badges-wrapper .amenity-filter-badge.amenity-filter-badge--commercial .badge-clear-btn svg path {
    stroke: #fffbeb !important;
  }

  .dark #mobile-filter-badges-wrapper .amenity-filter-badge .badge-clear-btn {
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(186, 244, 208, 0.28) !important;
    color: var(--discover-amenity-badge-dark-text, #b6e9c9) !important;
  }

  #mobile-filter-badges-wrapper .amenity-filter-badge.amenity-filter-badge--commercial .badge-clear-btn {
    background: rgba(154, 52, 18, 0.12) !important;
    border-color: rgba(154, 52, 18, 0.24) !important;
    color: #7c2d12 !important;
  }

  .dark #mobile-filter-badges-wrapper .amenity-filter-badge.amenity-filter-badge--commercial .badge-clear-btn {
    background: rgba(255, 255, 255, 0.16) !important;
    border-color: rgba(255, 255, 255, 0.26) !important;
    color: #fffbeb !important;
  }
}

/* Tablet adjustments (768px - 1100px) - handled by wrapper container */

/* Small mobile (640px and below) — compact chips with ellipsis, not full-bleed strips */
@media (max-width: 640px) {
  #amenity-filter-badges-sheet-container {
    gap: 0.375rem !important;
    min-width: 0 !important;
    overflow: visible !important;
  }

  .amenity-filter-badge {
    padding: 0.2rem 0.4rem;
    font-size: 0.7rem;
    min-height: 1.45rem;
    max-width: min(72vw, 14rem);
  }

  .amenity-filter-badge .badge-text {
    font-size: 0.7rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* iPhone and narrow phones (430px and below) */
@media (max-width: 430px) {
  #amenity-filter-badges-sheet-container {
    gap: 0.25rem !important;
  }

  .amenity-filter-badge {
    padding: 0.2rem 0.34rem !important;
    font-size: 0.6875rem !important;
    min-height: 1.5rem !important;
    max-width: min(70vw, 12.5rem) !important;
  }

  .amenity-filter-badge .badge-text {
    font-size: 0.6875rem !important;
    line-height: 1.125rem !important;
    max-width: 100% !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
}

/* Small phones (375px and below) */
@media (max-width: 375px) {
  #amenity-filter-badges-sheet-container {
    gap: 0.25rem !important;
  }

  .amenity-filter-badge {
    padding: 0.2rem 0.35rem;
    font-size: 0.6875rem;
    min-height: 1.5rem;
    max-width: min(68vw, 11.5rem);
  }

  .amenity-filter-badge .badge-text {
    font-size: 0.6875rem;
    line-height: 1.125rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* Extra small screens (320px and below) */
@media (max-width: 320px) {
  #amenity-filter-badges-sheet-container {
    gap: 0.2rem !important;
  }

  .amenity-filter-badge {
    padding: 0.15rem 0.25rem !important;
    font-size: 0.625rem !important;
    min-height: 1.25rem !important;
    max-width: min(66vw, 10rem) !important;
  }

  .amenity-filter-badge .badge-text {
    font-size: 0.625rem !important;
    line-height: 1rem !important;
    max-width: 100% !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
}

/* =============================================================================
 * Amenities / Refine popup chrome lives in components/map.css only.
 * This file owns applied amenity filter badges — do not redeclare #amenities-popup here.
 * ============================================================================= */
