/**
 * @file
 * Styles for deals listing pages (All Deals, Search, Category pages).
 *
 * Based on Screen 19 (All Deals) and Screen 21 (Search List View) wireframes.
 */

/* ========================================
   LAYOUT
   ======================================== */

.deals-page-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 3rem;
  display: flex;
  gap: 2rem;
}

/* ========================================
   FILTERS SIDEBAR
   ======================================== */

.filters-sidebar {
  width: 220px;
  flex-shrink: 0;
}

.filters-card {
  background-color: #ffffff;
  border-radius: 12px;
  padding: 1.5rem;
  border: 2px solid #e5e7eb;
}

.filters-title {
  font-size: 16px;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 1.25rem;
}

/* Location Filter */
.location-filter {
  margin-bottom: 1rem;
}

/* Location Filter Toggle */
.location-filter-toggle {
  margin-bottom: 12px;
}

.toggle-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.toggle-label span {
  font-size: 14px;
  font-weight: 500;
  color: #1a1a2e;
}

.toggle-switch {
  position: relative;
  width: 48px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #e5e7eb;
  border-radius: 24px;
  transition: 0.2s ease;
}

.toggle-slider::before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  border-radius: 50%;
  transition: 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: #DA6630;
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(24px);
}

.location-filter-controls {
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
  margin-top: 12px;
}

.location-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.location-header span {
  font-size: 13px;
  color: #1a1a2e;
  font-weight: 500;
}

.location-header a {
  font-size: 12px;
  color: #6b7280;
  text-decoration: none;
}

.location-header a:hover {
  color: #DA6630;
}

/* Range Slider */
.range-slider {
  width: 100%;
  height: 6px;
  background: linear-gradient(to right, #ef4444 0%, #ef4444 30%, #fecaca 30%, #fecaca 100%);
  border-radius: 3px;
  position: relative;
  cursor: pointer;
}

.range-thumb {
  width: 14px;
  height: 14px;
  background-color: #ffffff;
  border: 2px solid #ef4444;
  border-radius: 50%;
  position: absolute;
  top: -4px;
  left: 30%;
  transform: translateX(-50%);
  cursor: grab;
}

.range-thumb:active {
  cursor: grabbing;
}

/* Filter Sections */
.filter-section {
  border-top: 1px solid #e5e7eb;
  padding-top: 1rem;
  margin-top: 1rem;
}

.filter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  padding: 0.5rem 0;
}

.filter-header:hover {
  color: #DA6630;
}

.filter-header span {
  font-size: 14px;
  font-weight: 500;
  color: #1a1a2e;
}

.filter-arrow {
  width: 8px;
  height: 8px;
  border-right: 1.5px solid #6b7280;
  border-bottom: 1.5px solid #6b7280;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}

.filter-section.expanded .filter-arrow {
  transform: rotate(-135deg);
}

.filter-options {
  display: none;
  padding: 0.75rem 0;
}

.filter-section.expanded .filter-options {
  display: block;
}

.filter-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
}

.filter-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.filter-checkbox label {
  font-size: 14px;
  color: #1a1a2e;
  cursor: pointer;
}

/* Category Filter - Multi-select */
.category-filter-list {
  max-height: 250px;
  overflow-y: auto;
}

.category-filter-list::-webkit-scrollbar {
  width: 6px;
}

.category-filter-list::-webkit-scrollbar-track {
  background: #f9fafb;
  border-radius: 3px;
}

.category-filter-list::-webkit-scrollbar-thumb {
  background: #e5e7eb;
  border-radius: 3px;
}

.category-filter-list::-webkit-scrollbar-thumb:hover {
  background: #6b7280;
}

.category-selected-count {
  font-size: 12px;
  color: #6b7280;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #e5e7eb;
}

/* Favorited Heart Button */
.deal-heart.favorited {
  color: #ef4444;
}

.deal-heart.favorited svg {
  fill: #ef4444;
  stroke: #ef4444;
}

/* Filter Buttons */
.btn-apply {
  width: 100%;
  padding: 0.75rem;
  background-color: #1a1a2e;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 1.25rem;
  transition: background-color 0.2s ease;
}

.btn-apply:hover {
  background-color: #2a2a3e;
}

.btn-clear {
  width: 100%;
  text-align: center;
  padding: 0.75rem;
  font-size: 13px;
  color: #6b7280;
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.2s ease;
}

.btn-clear:hover {
  color: #DA6630;
}

/* ========================================
   DEALS CONTENT AREA
   ======================================== */

.deals-content {
  flex: 1;
  min-width: 0;
}

/* Page Header */
.deals-page-header,
.deals-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.deals-title-section h1 {
  font-size: 24px;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 0.25rem;
}

.deals-count {
  font-size: 14px;
  color: #6b7280;
}

/* View Toggle */
.view-toggle {
  display: flex;
  gap: 0.5rem;
}

.view-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background-color: #ffffff;
  cursor: pointer;
  color: #6b7280;
  transition: all 0.2s ease;
}

.view-btn:hover {
  border-color: #DA6630;
  color: #DA6630;
}

.view-btn.active {
  background-color: #1a1a2e;
  border-color: #1a1a2e;
  color: white;
}

/* Active Filters */
.active-filters {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.active-filters > span {
  font-size: 13px;
  color: #6b7280;
}

.filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  background-color: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 20px;
  font-size: 13px;
  color: #1a1a2e;
}

.filter-tag .remove {
  cursor: pointer;
  color: #6b7280;
  font-size: 16px;
  line-height: 1;
  transition: color 0.2s ease;
}

.filter-tag .remove:hover {
  color: #ef4444;
}

/* ========================================
   DEALS GRID
   ======================================== */

.deals-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  /* margin-bottom: 2rem; */
}

/* List View */
.deals-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.deal-card.list-view {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1rem;
}

.deal-card.list-view .deal-card-image {
  height: 140px;
}

.deal-card.list-view .deal-card-content {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* ========================================
   PAGINATION
   ======================================== */

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 2rem;
}

.page-btn {
  min-width: 40px;
  height: 40px;
  padding: 0 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background-color: #ffffff;
  font-size: 14px;
  color: #1a1a2e;
  cursor: pointer;
  transition: all 0.2s ease;
}

.page-btn:hover {
  border-color: #DA6630;
  color: #DA6630;
}

.page-btn.active {
  background-color: #1a1a2e;
  color: white;
  border-color: #1a1a2e;
}

.page-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.page-ellipsis {
  padding: 0 0.5rem;
  color: #6b7280;
}

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

@media (max-width: 1024px) {
  .deals-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 767px) {
  .deals-page-container {
    flex-direction: column;
    padding: 1rem;
  }

  .filters-sidebar {
    width: 100%;
  }

  .deals-grid {
    grid-template-columns: 1fr;
  }

  .deal-card.list-view {
    grid-template-columns: 1fr;
  }
}

/* ========================================
   GEO-FILTER: LOADING OVERLAY
   ======================================== */

.deals-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
  min-height: 200px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e5e7eb;
  border-top-color: #DA6630;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.deals-grid.loading {
  opacity: 0.5;
  pointer-events: none;
}

/* ========================================
   GEO-FILTER: DISTANCE BADGE
   ======================================== */

.distance-badge {
  position: absolute;
  bottom: 12px;
  left: 12px;
  padding: 4px 10px;
  background-color: #1a1a2e;
  color: white;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.distance-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  background-color: #10b981;
  border-radius: 50%;
}

/* Deal location in card content */
.deal-location {
  font-size: 12px;
  color: #6b7280;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
}

.deal-location svg {
  color: #DA6630;
}

/* ========================================
   GEO-FILTER: EMPTY STATE ENHANCEMENT
   ======================================== */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: #ffffff;
  border-radius: 12px;
  border: 2px solid #e5e7eb;
}

.empty-state__icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  color: #d1d5db;
}

.empty-state__title {
  font-size: 18px;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 8px;
}

.empty-state__message {
  font-size: 14px;
  color: #6b7280;
}

/* ========================================
   GEO-FILTER: SLIDER ENHANCEMENTS
   ======================================== */

.location-filter {
  padding-bottom: 8px;
}

.range-slider {
  touch-action: none;
  user-select: none;
}

.range-thumb {
  touch-action: none;
  user-select: none;
  transition: transform 0.1s ease;
}

.range-thumb:hover {
  transform: translateX(-50%) scale(1.15);
}

.range-thumb:active {
  transform: translateX(-50%) scale(1.2);
}

/* ========================================
   LOCATION MODAL
   ======================================== */

.location-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.location-modal.active {
  display: flex;
}

.location-modal__backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.2s ease;
}

.location-modal__content {
  position: relative;
  background-color: #ffffff;
  border-radius: 12px;
  width: 100%;
  max-width: 420px;
  margin: 16px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  animation: slideUp 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.location-modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #e5e7eb;
}

.location-modal__header h3 {
  font-size: 18px;
  font-weight: 700;
  color: #1a1a2e;
  margin: 0;
}

.location-modal__close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  font-size: 24px;
  color: #6b7280;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.location-modal__close:hover {
  background-color: #f3f4f6;
  color: #1a1a2e;
}

.location-modal__body {
  padding: 24px;
}

.location-modal__field {
  margin-bottom: 16px;
}

.location-modal__field label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #1a1a2e;
  margin-bottom: 8px;
}

.location-modal__select {
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  color: #1a1a2e;
  background-color: #ffffff;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

.location-modal__select:focus {
  outline: none;
  border-color: #DA6630;
  box-shadow: 0 0 0 3px rgba(218, 102, 48, 0.1);
}

.location-modal__select:disabled {
  background-color: #f9fafb;
  color: #9ca3af;
  cursor: not-allowed;
}

.location-modal__divider {
  display: flex;
  align-items: center;
  margin: 20px 0;
}

.location-modal__divider::before,
.location-modal__divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background-color: #e5e7eb;
}

.location-modal__divider span {
  padding: 0 16px;
  font-size: 13px;
  color: #6b7280;
  text-transform: uppercase;
}

.location-modal__gps-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 500;
  color: #1a1a2e;
  background-color: #f9fafb;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.location-modal__gps-btn:hover {
  background-color: #f3f4f6;
  border-color: #d1d5db;
}

.location-modal__gps-btn:active {
  transform: scale(0.98);
}

.location-modal__gps-btn.loading {
  pointer-events: none;
  opacity: 0.7;
}

.location-modal__gps-btn svg {
  color: #DA6630;
}

.location-modal__footer {
  display: flex;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid #e5e7eb;
}

.location-modal__btn {
  flex: 1;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.location-modal__btn--cancel {
  background-color: #f3f4f6;
  color: #6b7280;
  border: none;
}

.location-modal__btn--cancel:hover {
  background-color: #e5e7eb;
  color: #1a1a2e;
}

.location-modal__btn--apply {
  background-color: #DA6630;
  color: #ffffff;
  border: none;
}

.location-modal__btn--apply:hover:not(:disabled) {
  background-color: #c55828;
  transform: translateY(-1px);
}

.location-modal__btn--apply:disabled {
  background-color: #fecaca;
  cursor: not-allowed;
}

/* Mobile responsive */
@media (max-width: 480px) {
  .location-modal__content {
    margin: 12px;
    max-width: none;
  }

  .location-modal__header {
    padding: 16px 20px;
  }

  .location-modal__body {
    padding: 20px;
  }

  .location-modal__footer {
    padding: 16px 20px;
    flex-direction: column-reverse;
  }

  .location-modal__btn {
    width: 100%;
  }
}
