/**
 * Mobile Filter Drawer Styles
 * A reusable slide-in drawer for mobile filter interfaces
 */

/* =============================================================================
   BACKDROP
   ============================================================================= */

.mobile-filter-drawer-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-filter-drawer-backdrop--visible {
  opacity: 1;
  visibility: visible;
}

/* =============================================================================
   DRAWER CONTAINER
   ============================================================================= */

.mobile-filter-drawer {
  position: fixed;
  top: 60px; /* Account for navbar height */
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 400px;
  background-color: #fff;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
}

.mobile-filter-drawer--open {
  transform: translateX(0);
}

/* =============================================================================
   HEADER
   ============================================================================= */

.mobile-filter-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
  background-color: #f9fafb;
}

.mobile-filter-drawer__title {
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
  margin: 0;
}

.mobile-filter-drawer__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 8px;
  color: #6b7280;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.mobile-filter-drawer__close:hover {
  background-color: #f3f4f6;
  color: #1f2937;
}

/* =============================================================================
   CONTENT / SECTIONS
   ============================================================================= */

.mobile-filter-drawer__content {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.mobile-filter-drawer__section {
  border-bottom: 1px solid #e5e7eb;
}

.mobile-filter-drawer__section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 16px 20px;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.15s ease;
}

.mobile-filter-drawer__section-header:hover {
  background-color: #f9fafb;
}

.mobile-filter-drawer__section-label {
  font-size: 15px;
  font-weight: 500;
  color: #374151;
}

.mobile-filter-drawer__section-chevron {
  color: #9ca3af;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.mobile-filter-drawer__section--expanded .mobile-filter-drawer__section-chevron {
  transform: rotate(180deg);
}

.mobile-filter-drawer__section-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  background-color: #f9fafb;
}

.mobile-filter-drawer__section--expanded .mobile-filter-drawer__section-content {
  /* max-height set dynamically via JS */
}

/* Content padding */
.mobile-filter-drawer__section-content > * {
  padding: 0 20px 20px 20px;
}

/* =============================================================================
   FOOTER
   ============================================================================= */

.mobile-filter-drawer__footer {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
  background-color: #fff;
}

.mobile-filter-drawer__btn {
  flex: 1;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mobile-filter-drawer__btn--reset {
  background-color: #f3f4f6;
  border: 1px solid #d1d5db;
  color: #374151;
}

.mobile-filter-drawer__btn--reset:hover {
  background-color: #e5e7eb;
}

.mobile-filter-drawer__btn--apply {
  background-color: #30a5bf;
  border: 1px solid #30a5bf;
  color: #fff;
}

.mobile-filter-drawer__btn--apply:hover {
  background-color: #2894ac;
}

/* =============================================================================
   MOBILE FILTER TRIGGER BUTTON
   ============================================================================= */

.mobile-filter-trigger {
  display: none; /* Hidden by default, shown via media query */
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background-color: #fff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.mobile-filter-trigger:hover {
  background-color: #f9fafb;
  border-color: #9ca3af;
}

.mobile-filter-trigger:active {
  background-color: #f3f4f6;
}

.mobile-filter-trigger svg {
  flex-shrink: 0;
  color: #6b7280;
}

.mobile-filter-trigger__text {
  flex-shrink: 0;
}

.mobile-filter-trigger__badge {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background-color: #30a5bf;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  border-radius: 10px;
}

/* =============================================================================
   FILTER CONTENT STYLES (inside drawer)
   ============================================================================= */

/* Override filter-selector-content styles when inside drawer */
.mobile-filter-drawer .filter-selector-content {
  position: static !important;
  display: block !important;
  width: 100% !important;
  padding: 0 !important;
  box-shadow: none !important;
  animation: none !important;
  background: transparent !important;
}

.mobile-filter-drawer .filter-selector-header {
  display: none !important;
}

.mobile-filter-drawer .filter-selector-footer {
  display: none !important;
}

.mobile-filter-drawer .filter-selector-options {
  max-height: none !important;
  overflow: visible !important;
  padding: 0 !important;
}

/* Radio/checkbox options styling in drawer */
.mobile-filter-drawer .filter-option {
  display: flex;
  align-items: center;
  padding: 10px 0 10px 20px;
  border-bottom: 1px solid #e5e7eb;
}

.mobile-filter-drawer .filter-option:last-child {
  border-bottom: none;
}

.mobile-filter-drawer .filter-option label {
  font-size: 14px;
  color: #374151;
  cursor: pointer;
}

.mobile-filter-drawer .filter-option input[type="radio"],
.mobile-filter-drawer .filter-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-right: 12px;
}

/* Form groups in drawer */
.mobile-filter-drawer .form-group {
  margin-bottom: 16px;
}

.mobile-filter-drawer .form-group:last-child {
  margin-bottom: 0;
}

.mobile-filter-drawer .form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #6b7280;
  margin-bottom: 6px;
}

.mobile-filter-drawer .form-group input[type="text"],
.mobile-filter-drawer .form-group input[type="number"],
.mobile-filter-drawer .form-group input[type="date"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  box-sizing: border-box;
  background-color: #fff;
}

.mobile-filter-drawer .form-group input[type="text"]:focus,
.mobile-filter-drawer .form-group input[type="number"]:focus,
.mobile-filter-drawer .form-group input[type="date"]:focus {
  outline: none;
  border-color: #30a5bf;
  box-shadow: 0 0 0 3px rgba(48, 165, 191, 0.1);
}

/* Slider styling in drawer */
.mobile-filter-drawer .slider-wrapper {
  padding: 10px 0;
}

.mobile-filter-drawer .range-slider-label {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 8px;
}

/* Date range picker in drawer */
.mobile-filter-drawer #date-range-picker-wrapper {
  margin-top: 12px;
}

.mobile-filter-drawer #date-range-picker {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mobile-filter-drawer .custom-date-wrapper {
  width: 100% !important;
}

.mobile-filter-drawer .custom-date-wrapper input {
  width: 100%;
  box-sizing: border-box;
}

/* Select dropdowns in drawer */
.mobile-filter-drawer select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  background-color: #fff;
  cursor: pointer;
}

/* Toggle switch in drawer */
.mobile-filter-drawer .theme-toggle {
  margin-top: 8px;
}

/* Market buttons in drawer */
.mobile-filter-drawer .market-buttons-drawer {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mobile-filter-drawer .market-option-drawer {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background-color: #fff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  color: #374151;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mobile-filter-drawer .market-option-drawer.selected {
  background-color: #30a5bf;
  border-color: #30a5bf;
  color: #fff;
}

.mobile-filter-drawer .market-option-drawer:not(.selected):hover {
  background-color: #f9fafb;
  border-color: #9ca3af;
}

/* Range inputs (min/max) in drawer */
.mobile-filter-drawer .drawer-range-inputs {
  display: flex;
  gap: 16px;
  align-items: flex-end;
}

.mobile-filter-drawer .drawer-range-inputs .drawer-range-field {
  flex: 1;
}

.mobile-filter-drawer .drawer-range-inputs .drawer-range-field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: #6b7280;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mobile-filter-drawer .drawer-range-inputs .drawer-input-wrapper {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mobile-filter-drawer .drawer-range-inputs .drawer-input-wrapper span {
  font-size: 14px;
  color: #6b7280;
}

.mobile-filter-drawer .drawer-range-inputs input[type="number"],
.mobile-filter-drawer .drawer-range-inputs input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  box-sizing: border-box;
  background-color: #fff;
}

.mobile-filter-drawer .drawer-range-inputs input[type="number"]:focus,
.mobile-filter-drawer .drawer-range-inputs input[type="text"]:focus {
  outline: none;
  border-color: #30a5bf;
  box-shadow: 0 0 0 3px rgba(48, 165, 191, 0.1);
}

/* =============================================================================
   RESPONSIVE - Show trigger on mobile
   ============================================================================= */

@media (max-width: 641px) {
  .mobile-filter-trigger {
    display: flex;
    width: 100%;
    justify-content: center;
  }

  /* Show mobile trigger wrapper */
  .filter-wrapper--mobile-trigger {
    display: block !important;
  }

  /* Hide desktop filters when drawer is available */
  .filters-section .filter-wrapper--desktop {
    display: none !important;
  }

  /* Keep search visible */
  .filters-section .filter-wrapper--search {
    display: block !important;
  }
}

/* Larger phones / small tablets - hide mobile elements on desktop */
@media (min-width: 642px) {
  .mobile-filter-drawer,
  .mobile-filter-drawer-backdrop {
    display: none !important;
  }

  .filter-wrapper--mobile-trigger {
    display: none !important;
  }
}
