/* ============================================================
   Flashmac Smart Search — Modal
   Primary: #eb3f93  |  Gradient: #EB3F93 → #F5956F
   ============================================================ */

:root {
  --fss-pink:        #eb3f93;
  --fss-pink-dark:   #c4307a;
  --fss-pink-light:  #fdf0f7;
  --fss-orange:      #f97316;
  --fss-grad-start:  #EB3F93;
  --fss-grad-end:    #F5956F;
  --fss-dark:        #1a1a1a;
  --fss-gray:        #6b7280;
  --fss-light:       #f9fafb;
  --fss-border:      #e5e7eb;
  --fss-white:       #ffffff;
  --fss-radius:      10px;
  --fss-radius-lg:   16px;
  --fss-card-shadow: 0 1px 4px rgba(0,0,0,.06), 0 4px 18px rgba(0,0,0,.08);
  --fss-ease:        .18s cubic-bezier(.4,0,.2,1);
}

/* ── Overlay ──────────────────────────────────────────────── */
.fss-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 999999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.fss-overlay.is-open {
  opacity: 1;
  pointer-events: all;
}

/* ── Modal — full width, slides in from top ───────────────── */
.fss-modal {
  background: var(--fss-white);
  width: 100%;
  max-width: 100%;
  max-height: 85vh;
  border-radius: 0 0 var(--fss-radius-lg) var(--fss-radius-lg);
  box-shadow: 0 8px 40px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(-100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}

.fss-overlay.is-open .fss-modal {
  transform: translateY(0);
}

/* ── Header — gradient-border pill (same as site search bar) ─ */
.fss-header {
  flex-shrink: 0;
  padding: 14px 20px;
  background: var(--fss-white);
}

/* The pill with gradient border */
.fss-search-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px 10px 18px;
  border-radius: 50px;
  border: 2px solid transparent;
  background:
    linear-gradient(var(--fss-white), var(--fss-white)) padding-box,
    linear-gradient(90deg, var(--fss-grad-start), var(--fss-grad-end)) border-box;
  transition: box-shadow var(--fss-ease);
}

.fss-search-wrap:focus-within {
  box-shadow: 0 0 0 3px rgba(235, 63, 147, .13);
}

.fss-search-icon {
  color: var(--fss-pink);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.fss-input {
  flex: 1;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  -webkit-appearance: none;
  font-size: 21px;
  font-weight: 400;
  color: var(--fss-dark);
  background: transparent !important;
  line-height: 1.4;
  min-width: 0;
  font-family: inherit;
  caret-color: var(--fss-pink);
  padding: 0;
  border-radius: 0;
}

.fss-input::placeholder { color: #bfc5ce; }

.fss-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--fss-gray);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 50%;
  transition: color var(--fss-ease), background var(--fss-ease);
  margin-left: 2px;
}

.fss-close:hover {
  color: var(--fss-dark);
  background: var(--fss-light);
}

/* separator below header */
.fss-header-sep {
  height: 1px;
  background: var(--fss-border);
  flex-shrink: 0;
}

/* ── Recent searches bar ──────────────────────────────────── */
.fss-recent-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  border-bottom: 1px solid var(--fss-border);
  flex-shrink: 0;
  background: var(--fss-light);
  flex-wrap: wrap;
}

.fss-recent-bar.has-items { display: flex; }

.fss-recent-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--fss-gray);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.fss-recent-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  flex: 1;
}

/* chip */
.fss-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 14px 7px 16px;
  background: #fff;
  border: 1.5px solid #d1d5db;
  border-radius: 50px;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1;
  color: #1a1a1a;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color var(--fss-ease);
}

.fss-chip:hover {
  border-color: #9ca3af;
}

.fss-chip-text {
  pointer-events: none;
}

.fss-chip-remove {
  all: unset !important;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
  color: #adb5bd !important;
  display: flex !important;
  align-items: center !important;
  flex-shrink: 0;
  transition: color var(--fss-ease);
}

.fss-chip-remove:hover {
  color: #6b7280 !important;
}

.fss-clear-all {
  background: none;
  border: none;
  color: var(--fss-pink);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  cursor: pointer;
  white-space: nowrap;
  padding: 0;
  font-family: inherit;
  margin-left: auto;
  transition: color var(--fss-ease);
}

.fss-clear-all:hover { color: var(--fss-pink-dark); }

/* ── Body ─────────────────────────────────────────────────── */
.fss-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.fss-sidebar {
  width: 185px;
  flex-shrink: 0;
  border-right: 1px solid var(--fss-border);
  padding: 20px 0;
  overflow-y: auto;
  background: var(--fss-light);
}

.fss-sidebar-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--fss-gray);
  margin: 0 0 6px;
  padding: 0 18px;
}

.fss-popular-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.fss-popular-list li { margin: 0; }

.fss-popular-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px;
  font-size: 13.5px;
  color: var(--fss-dark);
  text-decoration: none;
  cursor: pointer;
  gap: 6px;
  transition: background var(--fss-ease), color var(--fss-ease), padding-left var(--fss-ease);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fss-popular-item .fss-popular-arrow {
  opacity: 0;
  flex-shrink: 0;
  color: var(--fss-pink);
  transition: opacity var(--fss-ease), transform var(--fss-ease);
}

.fss-popular-item:hover,
.fss-popular-item.is-active {
  background: var(--fss-white);
  color: var(--fss-pink);
  padding-left: 22px;
}

.fss-popular-item:hover .fss-popular-arrow,
.fss-popular-item.is-active .fss-popular-arrow {
  opacity: 1;
  transform: translateX(2px);
}

.fss-popular-skeleton {
  height: 11px;
  background: linear-gradient(90deg, #eee 25%, #e4e4e4 50%, #eee 75%);
  background-size: 200% 100%;
  animation: fss-shimmer 1.5s infinite;
  border-radius: 4px;
  margin: 10px 18px;
}

@keyframes fss-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Content area ─────────────────────────────────────────── */
.fss-content {
  flex: 1;
  min-width: 0;
  padding: 18px 22px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.fss-content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-shrink: 0;
}

.fss-content-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--fss-gray);
  margin: 0;
}

.fss-view-all {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--fss-pink);
  text-decoration: none;
  padding: 7px 18px;
  border: 1.5px solid var(--fss-pink);
  border-radius: 50px;
  transition: background var(--fss-ease), color var(--fss-ease);
  line-height: 1;
  white-space: nowrap;
}

.fss-view-all:hover { background: var(--fss-pink); color: #fff; }

/* ── Products wrapper — flex with inline arrows ───────────── */
.fss-products-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.fss-products-scroll {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-behavior: smooth;
}

.fss-products-scroll::-webkit-scrollbar { display: none; }

.fss-products-grid {
  display: flex;
  gap: 12px;
  padding: 4px 0 8px;
  width: max-content;
}

/* ── Nav arrows — inline siblings of the scroll ──────────── */
.fss-nav-btn {
  flex-shrink: 0;
  background: var(--fss-white) !important;
  border: 1.5px solid #d1d5db !important;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex !important;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #1a1a1a !important;
  box-shadow: 0 1px 6px rgba(0,0,0,.12);
  transition: border-color var(--fss-ease), box-shadow var(--fss-ease);
  padding: 0;
  line-height: 1;
}

.fss-nav-btn:hover {
  border-color: var(--fss-pink) !important;
  color: var(--fss-pink) !important;
  box-shadow: 0 2px 12px rgba(235,63,147,.22);
}

.fss-nav-btn svg {
  display: block;
  fill: none;
  stroke: currentColor !important;
  stroke-width: 2.5;
  pointer-events: none;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ── Product card ─────────────────────────────────────────── */
.fss-card {
  width: 172px;
  flex-shrink: 0;
  background: var(--fss-white);
  border: 1px solid var(--fss-border);
  border-radius: var(--fss-radius);
  overflow: hidden;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: box-shadow var(--fss-ease), transform var(--fss-ease), border-color var(--fss-ease);
}

.fss-card:hover {
  box-shadow: var(--fss-card-shadow);
  transform: translateY(-3px);
  border-color: #d1d5db;
  color: inherit;
  text-decoration: none;
}

/* Discount badge */
.fss-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--fss-orange);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 5px;
  line-height: 1.35;
  z-index: 2;
  box-shadow: 0 1px 4px rgba(249,115,22,.3);
}

.fss-badge.fss-badge-hot {
  background: var(--fss-pink);
  box-shadow: 0 1px 4px rgba(235,63,147,.3);
}

/* Image */
.fss-card-image {
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--fss-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

.fss-card-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform .3s ease;
}

.fss-card:hover .fss-card-image img { transform: scale(1.05); }

/* Body */
.fss-card-body {
  padding: 10px 11px 13px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.fss-card-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--fss-dark);
  line-height: 1.35;
  margin-bottom: 7px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.fss-card-separator {
  width: 26px;
  height: 2px;
  background: linear-gradient(90deg, var(--fss-grad-start), var(--fss-grad-end));
  border-radius: 2px;
  margin-bottom: 7px;
  flex-shrink: 0;
}

.fss-card-specs {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  flex: 1;
}

.fss-card-specs li {
  font-size: 11.5px;
  color: var(--fss-gray);
  line-height: 1.6;
}

.fss-card-prices { margin-top: auto; }

.fss-price-regular {
  font-size: 11.5px;
  color: #9ca3af;
  text-decoration: line-through;
  display: block;
  line-height: 1.3;
}

.fss-price-regular .woocommerce-Price-amount { font-size: 11.5px; color: #9ca3af; }

.fss-price-sale {
  font-size: 14px;
  font-weight: 800;
  color: var(--fss-pink);
  display: block;
  line-height: 1.3;
}

.fss-price-sale .woocommerce-Price-amount { font-size: 14px; color: var(--fss-pink); }

.fss-price-only {
  font-size: 14px;
  font-weight: 700;
  color: var(--fss-dark);
  display: block;
}

.fss-price-only .woocommerce-Price-amount { font-size: 14px; color: var(--fss-dark); }

/* ── No results ───────────────────────────────────────────── */
.fss-no-results {
  text-align: center;
  padding: 40px 20px 24px;
  color: var(--fss-gray);
}

.fss-no-results svg { margin-bottom: 12px; opacity: .35; }

.fss-no-results p { font-size: 15px; margin: 0; line-height: 1.6; }

/* ── Spinner ──────────────────────────────────────────────── */
.fss-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 48px;
}

.fss-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--fss-border);
  border-top-color: var(--fss-pink);
  border-radius: 50%;
  animation: fss-spin .65s linear infinite;
}

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

/* ── Skeleton cards ───────────────────────────────────────── */
.fss-card-skeleton {
  width: 172px;
  flex-shrink: 0;
  background: var(--fss-white);
  border: 1px solid var(--fss-border);
  border-radius: var(--fss-radius);
  overflow: hidden;
}

.fss-skel-img {
  aspect-ratio: 1;
  background: linear-gradient(90deg, #f3f4f6 25%, #eaebec 50%, #f3f4f6 75%);
  background-size: 200% 100%;
  animation: fss-shimmer 1.5s infinite;
}

.fss-skel-body { padding: 10px 11px; }

.fss-skel-line {
  height: 9px;
  background: linear-gradient(90deg, #f3f4f6 25%, #eaebec 50%, #f3f4f6 75%);
  background-size: 200% 100%;
  animation: fss-shimmer 1.5s infinite;
  border-radius: 4px;
  margin-bottom: 8px;
}

.fss-skel-line.short  { width: 52%; }
.fss-skel-line.medium { width: 76%; }
.fss-skel-line.long   { width: 92%; }

/* ── Touch-action: kill 300ms tap delay on all interactive elements ── */
.fss-nav-btn,
.fss-close,
.fss-chip,
.fss-chip-remove,
.fss-popular-item,
.fss-view-all,
.fss-clear-all,
.fss-card,
#fss-overlay {
  touch-action: manipulation;
}

/* Smooth momentum scrolling on iOS */
.fss-products-scroll,
.fss-content,
.fss-sidebar {
  -webkit-overflow-scrolling: touch;
}

/* ── Responsive — tablet ──────────────────────────────────── */
@media (max-width: 860px) {
  .fss-modal {
    max-height: 88dvh;     /* dvh shrinks when iOS keyboard appears */
    max-height: 88svh;     /* svh fallback: stable viewport, ignores keyboard */
    border-radius: 0 0 12px 12px;
  }
  .fss-sidebar  { display: none; }
  .fss-content  { padding: 14px 14px 20px; }
  .fss-header   { padding: 12px 14px; }
  .fss-search-wrap { padding: 9px 12px 9px 16px; gap: 10px; }

  /* MUST stay ≥ 16px on mobile or iOS auto-zooms the page */
  .fss-input    { font-size: 16px !important; }

  .fss-recent-bar { padding: 7px 14px; }
  .fss-card, .fss-card-skeleton { width: 150px; }

  /* Nav arrows are unnecessary on touch — swipe does the job */
  .fss-nav-btn  { display: none !important; }
}

/* ── Responsive — phone ───────────────────────────────────── */
@media (max-width: 480px) {
  .fss-modal { max-height: 92dvh; max-height: 92svh; }
  .fss-header { padding: 10px 12px; }
  .fss-search-wrap { padding: 8px 10px 8px 14px; }
  .fss-content { padding: 12px 12px 16px; }
  .fss-recent-bar { padding: 6px 12px; flex-wrap: nowrap; overflow-x: auto; }
  .fss-recent-chips { flex-wrap: nowrap; }
  .fss-card, .fss-card-skeleton { width: 140px; }
  .fss-card-name { font-size: 12px; }
  .fss-content-header { margin-bottom: 10px; }

  /* Tap targets: close + chip-remove must be ≥ 44px for accessibility */
  .fss-close { width: 40px; height: 40px; }
}

/* ── Safe-area insets (iPhone notch / Dynamic Island) ─────── */
@supports (padding: env(safe-area-inset-top)) {
  .fss-modal {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ── Reduced motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .fss-overlay, .fss-modal, .fss-card, .fss-card-image img,
  .fss-chip, .fss-nav-btn, .fss-popular-item, .fss-spinner {
    transition: none !important;
    animation: none !important;
  }
}
