/* Custom styles - Tailwind does the heavy lifting */

/* Prevent iOS Safari zoom on input focus (requires font-size >= 16px) */
@media screen and (max-width: 767px) {
  input, select, textarea {
    font-size: 16px !important;
  }
}

.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator {
  display: inline-block;
}

.htmx-request.htmx-indicator {
  display: inline-block;
}

/* Fade in animation for htmx swaps */
.htmx-added {
  opacity: 0;
}

.htmx-added {
  animation: fadeIn 0.3s ease-in forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Sold overlay */
.item-sold::after {
  content: 'SOLD';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.5);
  color: white;
  font-weight: bold;
  font-size: 1.25rem;
  border-radius: inherit;
}

.item-sold {
  position: relative;
  overflow: hidden;
}

/* ========== Search Bar ========== */

.search-bar-wrapper {
  display: flex;
  align-items: center;
  background: white;
  border: 2px solid #e5e7eb;
  border-radius: 1rem;
  padding: 0.25rem 0.25rem 0.25rem 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-bar-wrapper:focus-within {
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.search-icon {
  width: 1.25rem;
  height: 1.25rem;
  color: #9ca3af;
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 0.625rem 0.75rem;
  font-size: 1rem;
  background: transparent;
  color: #111827;
}

.search-input::placeholder {
  color: #9ca3af;
}

.search-btn {
  background: #059669;
  color: white;
  padding: 0.625rem 1.5rem;
  border-radius: 0.75rem;
  font-weight: 600;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.search-btn:hover {
  background: #047857;
}

/* ========== Location Status ========== */

.location-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 0.5rem;
}

.location-status.location-error {
  background: #fef3c7;
  border-color: #fde68a;
}

/* ========== Category Chips ========== */

.category-chip {
  padding: 0.375rem 0.875rem;
  border-radius: 9999px;
  font-size: 0.8125rem;
  font-weight: 500;
  background: white;
  color: #4b5563;
  border: 1px solid #e5e7eb;
  cursor: pointer;
  transition: all 0.15s;
}

.category-chip:hover {
  background: #f0fdf4;
  border-color: #10b981;
  color: #059669;
}

.category-chip-active {
  background: #059669;
  color: white;
  border-color: #059669;
}

.category-chip-active:hover {
  background: #047857;
  border-color: #047857;
  color: white;
}

/* ========== Wishlist Heart Button ========== */

.wishlist-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  color: #9ca3af;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color 0.2s, transform 0.15s;
  flex-shrink: 0;
  padding: 0;
  text-decoration: none;
}

.wishlist-btn:hover {
  color: #ef4444;
  transform: scale(1.15);
}

.wishlist-btn.wishlisted {
  color: #ef4444;
}

.wishlist-btn.wishlisted:hover {
  color: #dc2626;
}

/* Heart pop animation on save */
@keyframes heartPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.wishlist-btn.wishlisted {
  animation: heartPop 0.3s ease-out;
}

/* ========== Sale Cart Bottom Sheet ========== */

.sale-cart-sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.sale-cart-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  transition: background 0.3s ease;
}

.sale-cart-visible .sale-cart-overlay {
  background: rgba(0, 0, 0, 0.4);
}

.sale-cart-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-radius: 1rem 1rem 0 0;
  padding: 1.5rem;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  transform: translateY(100%);
  transition: transform 0.3s ease;
  max-height: 70vh;
  overflow-y: auto;
}

.sale-cart-visible .sale-cart-content {
  transform: translateY(0);
}

/* Safe area for iOS */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .sale-cart-content {
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
  }
}

/* Desktop: center and constrain width */
@media (min-width: 640px) {
  .sale-cart-content {
    left: 50%;
    right: auto;
    transform: translate(-50%, 100%);
    width: 100%;
    max-width: 28rem;
    border-radius: 1rem;
    margin-bottom: 2rem;
  }

  .sale-cart-visible .sale-cart-content {
    transform: translate(-50%, 0);
  }
}

/* ========== Floating Cart FAB (DoorDash-style) ========== */

.sale-cart-fab {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) scale(0);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #059669;
  color: white;
  border: none;
  border-radius: 9999px;
  padding: 0.875rem 1.5rem;
  box-shadow: 0 4px 20px rgba(5, 150, 105, 0.4);
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.15s;
  font-family: inherit;
  white-space: nowrap;
}

.sale-cart-fab.visible {
  transform: translateX(-50%) scale(1);
}

.sale-cart-fab:hover {
  background: #047857;
}

.sale-cart-fab:active {
  transform: translateX(-50%) scale(0.95);
}

.sale-cart-fab-text {
  font-weight: 600;
  font-size: 0.9375rem;
}

.sale-cart-fab-divider {
  width: 1px;
  height: 1.25rem;
  background: rgba(255, 255, 255, 0.3);
}

.sale-cart-fab-badge {
  background: white;
  color: #059669;
  font-weight: 700;
  font-size: 0.75rem;
  min-width: 1.25rem;
  height: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  padding: 0 0.375rem;
}

.sale-cart-fab-total {
  font-weight: 600;
  font-size: 0.9375rem;
}

/* Safe area for iOS */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .sale-cart-fab {
    bottom: calc(1.5rem + env(safe-area-inset-bottom));
  }
}

/* ========== Scrollbar Hide Utility (mobile only) ========== */

.scrollbar-hide {
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}

.scrollbar-hide::-webkit-scrollbar {
  display: none;  /* Chrome, Safari, Opera */
}

/* Show scrollbar on desktop */
@media (min-width: 640px) {
  .scrollbar-hide {
    scrollbar-width: thin;  /* Firefox */
    scrollbar-color: #d1d5db transparent;
  }

  .scrollbar-hide::-webkit-scrollbar {
    display: block;
    height: 6px;
  }

  .scrollbar-hide::-webkit-scrollbar-track {
    background: transparent;
  }

  .scrollbar-hide::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
  }

  .scrollbar-hide::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
  }
}
