/**
 * Search overlay, mobile menu drawer, floating contact buttons
 *
 * @package BaitAlKaram
 */

body.has-overlay { overflow: hidden; }

/* =========================================================
   Search overlay
   ========================================================= */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(16px, 8vh, 96px) 16px 16px;
}
.search-overlay[hidden] { display: none; }
.search-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 20, 24, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.35s ease;
}
.search-overlay.is-open .search-overlay-backdrop { opacity: 1; }
.search-panel {
  position: relative;
  width: min(760px, 100%);
  max-height: calc(100svh - 32px);
  overflow: auto;
  background: var(--paper);
  border-radius: 22px;
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.55);
  padding: 14px 14px 18px;
  opacity: 0;
  transform: translateY(-18px) scale(0.98);
  transition: opacity 0.35s ease, transform 0.42s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.search-overlay.is-open .search-panel { opacity: 1; transform: none; }

.search-form {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-page);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 6px 8px 6px 14px;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.search-form:focus-within {
  border-color: var(--red);
  box-shadow: 0 0 0 4px rgba(186, 32, 41, 0.1);
  background: #fff;
}
.search-form-icon { display: inline-flex; color: var(--ink-light); flex: none; }
.search-form-icon svg { width: 22px; height: 22px; }
.search-form input[type="search"] {
  flex: 1;
  min-width: 0;
  height: 48px;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 17px;
  color: var(--ink);
  outline: none;
  -webkit-appearance: none;
}
.search-form input::-webkit-search-cancel-button { display: none; }
.search-form input::placeholder { color: rgba(82, 82, 82, 0.7); }
.search-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--red);
  opacity: 0;
  flex: none;
  transition: opacity 0.2s ease;
}
.search-overlay.is-loading .search-spinner { opacity: 1; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.search-close {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: var(--ink-light);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease;
}
.search-close svg { width: 20px; height: 20px; }
.search-close:hover { background: var(--mist); color: var(--red); }

.search-quick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 16px 6px 6px;
}
.search-quick-label { font-size: 12px; font-weight: 600; color: var(--ink-light); margin-inline-end: 4px; }
.search-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  transition: border-color 0.25s ease, color 0.25s ease, transform 0.25s ease;
}
.search-chip small { font-size: 11px; color: var(--ink-light); font-weight: 600; }
.search-chip:hover { border-color: var(--red); color: var(--red); transform: translateY(-1px); }
.search-chip--all { background: var(--ink); color: #fff; border-color: var(--ink); }
.search-chip--all:hover { background: var(--red); border-color: var(--red); color: #fff; }

.search-results { padding: 8px 4px 0; }
.search-hint,
.search-empty {
  margin: 14px 8px 6px;
  font-size: 13.5px;
  color: var(--ink-light);
}
.search-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.search-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  border-radius: 14px;
  color: var(--ink);
  transition: background 0.22s ease, transform 0.22s ease;
  animation: search-in 0.35s ease both;
}
@keyframes search-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.search-item:hover,
.search-item:focus-visible { background: var(--bg-page); transform: translateX(-3px); outline: none; }
.search-item-img {
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.search-item-img img { width: 86%; height: 86%; object-fit: contain; }
.search-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.search-item-title { font-size: 14.5px; font-weight: 600; line-height: 1.45; }
.search-item-meta { font-size: 12px; color: var(--ink-light); display: flex; flex-wrap: wrap; gap: 8px; }
.search-item-meta bdi { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.search-item-price { flex: none; font-size: 13px; font-weight: 700; color: var(--red); white-space: nowrap; }
.search-item-price.is-ask { color: var(--ink-light); font-weight: 600; font-size: 12px; }
.search-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 10px 0 0;
  padding: 12px;
  border-radius: 12px;
  border: 1.5px dashed var(--line);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  transition: border-color 0.25s ease, color 0.25s ease;
}
.search-more:hover { border-color: var(--red); color: var(--red); }
.search-more .jelly-arrow { width: 16px; height: 11px; }

/* Inline search form on the results page */
.search-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  width: min(380px, 100%);
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 4px 4px 4px 14px;
}
.search-inline:focus-within { border-color: var(--red); box-shadow: 0 0 0 4px rgba(186, 32, 41, 0.1); }
.search-inline input {
  flex: 1;
  min-width: 0;
  height: 42px;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 15px;
  outline: none;
}
.search-inline input::-webkit-search-cancel-button { display: none; }
.search-inline button {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 9px;
  background: var(--ink);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.25s ease;
}
.search-inline button svg { width: 18px; height: 18px; }
.search-inline button:hover { background: var(--red); }
.products-empty p { margin: 0 0 8px; }
.products-empty p:first-child { font-size: 17px; font-weight: 700; color: var(--ink); }

/* =========================================================
   Mobile menu drawer
   ========================================================= */
.mobile-menu { position: fixed; inset: 0; z-index: 110; }
.mobile-menu[hidden] { display: none; }
.mobile-menu-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 20, 24, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.35s ease;
}
.mobile-menu.is-open .mobile-menu-backdrop { opacity: 1; }
.mobile-menu-panel {
  position: absolute;
  top: 0;
  bottom: 0;
  inset-inline-start: 0;
  width: min(340px, 86vw);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  overflow-y: auto;
  border-inline-end: 1px solid var(--line);
  box-shadow: 30px 0 80px -30px rgba(0, 0, 0, 0.4);
  transform: translateX(104%);
  transition: transform 0.48s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.mobile-menu.is-open .mobile-menu-panel { transform: none; }
.mobile-menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.mobile-menu-brand {
  display: flex;
  align-items: center;
  min-width: 0;
}
.mobile-menu-brand .brand-logo { height: 40px; max-width: 180px; }
.mobile-menu-close {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease;
}
.mobile-menu-close svg { width: 18px; height: 18px; }
.mobile-menu-close:hover { background: var(--red); color: #fff; }

.mobile-menu-nav { display: flex; flex-direction: column; padding: 14px 0; }
.mobile-menu-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 6px;
  border-bottom: 1px solid var(--line);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  opacity: 0;
  transform: translateX(14px);
  transition: color 0.25s ease, opacity 0.4s ease, transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.mobile-menu.is-open .mobile-menu-nav a { opacity: 1; transform: none; }
.mobile-menu.is-open .mobile-menu-nav a:nth-child(1) { transition-delay: 0.08s; }
.mobile-menu.is-open .mobile-menu-nav a:nth-child(2) { transition-delay: 0.13s; }
.mobile-menu.is-open .mobile-menu-nav a:nth-child(3) { transition-delay: 0.18s; }
.mobile-menu.is-open .mobile-menu-nav a:nth-child(4) { transition-delay: 0.23s; }
.mobile-menu.is-open .mobile-menu-nav a:nth-child(5) { transition-delay: 0.28s; }
.mobile-menu.is-open .mobile-menu-nav a:nth-child(6) { transition-delay: 0.33s; }
.mobile-menu-nav a small {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-light);
  background: var(--mist);
  padding: 2px 8px;
  border-radius: 999px;
}
.mobile-menu-nav a .jelly-arrow { margin-inline-start: auto; width: 18px; height: 12px; color: var(--ink-light); }
.mobile-menu-nav a.is-current { color: var(--red); }
.mobile-menu-nav a.is-current .jelly-arrow { color: var(--red); }
.mobile-menu-nav a:active .jelly-arrow { transform: translateX(-4px); }

.mobile-menu-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px 0 14px;
}
.mobile-menu-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-page);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  transition: border-color 0.25s ease, color 0.25s ease;
}
.mobile-menu-links a svg { width: 18px; height: 18px; }
.mobile-menu-links a:hover { border-color: var(--red); color: var(--red); }

.mobile-menu-contact { margin-top: auto; display: grid; gap: 8px; padding-top: 14px; }
.mobile-menu-wa,
.mobile-menu-call {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 50px;
  border-radius: 12px;
  font-size: 14.5px;
  font-weight: 700;
}
.mobile-menu-wa svg, .mobile-menu-call svg { width: 20px; height: 20px; }
.mobile-menu-wa { color: #fff; background: linear-gradient(115deg, #1fa855, #25d366 55%, #128c7e); }
.mobile-menu-call { color: var(--ink); border: 1.5px solid var(--ink); }

/* =========================================================
   Floating contact buttons
   ========================================================= */
.float-contact {
  position: fixed;
  z-index: 90;
  inset-inline-start: 22px;
  bottom: 22px;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-start;
  gap: 10px;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s ease, transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
  pointer-events: none;
}
.float-contact.is-ready { opacity: 1; transform: none; pointer-events: auto; }
.float-btn {
  display: inline-flex;
  align-items: center;
  gap: 0;
  height: 52px;
  padding: 0 6px;
  border-radius: 999px;
  color: #fff;
  box-shadow: 0 14px 34px -14px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.08);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.3s ease, gap 0.3s ease;
  will-change: transform;
}
.float-btn-icon {
  width: 40px;
  height: 40px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.float-btn-icon svg { width: 22px; height: 22px; }
.float-btn-label {
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  opacity: 0;
  font-size: 13.5px;
  font-weight: 700;
  transition: max-width 0.45s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s ease, padding 0.3s ease;
}
.float-btn:hover,
.float-btn:focus-visible { transform: translateY(-3px); box-shadow: 0 20px 40px -14px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.08); outline: none; }
.float-btn:hover .float-btn-label,
.float-btn:focus-visible .float-btn-label { max-width: 140px; opacity: 1; padding-inline-end: 12px; }
.float-btn--wa {
  background: linear-gradient(135deg, #25d366, #128c7e);
  position: relative;
}
.float-btn--wa::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.45);
  animation: float-pulse 2.8s ease-out infinite;
  pointer-events: none;
}
@keyframes float-pulse {
  0% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.45); }
  70% { box-shadow: 0 0 0 14px rgba(37, 211, 102, 0); }
  100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}
.float-btn--call { background: var(--ink); height: 46px; }
.float-btn--call .float-btn-icon { width: 34px; height: 34px; }
.float-btn--call .float-btn-icon svg { width: 19px; height: 19px; }
.float-contact.is-hidden { opacity: 0; transform: translateY(24px); pointer-events: none; }

@media (max-width: 700px) {
  .float-contact { inset-inline-start: 14px; bottom: 16px; gap: 8px; }
  .float-btn { height: 48px; }
  .float-btn-icon { width: 36px; height: 36px; }
  .float-btn--call { height: 42px; }
  /* Product pages already have the sticky order bar on mobile */
  body.single-product .float-contact,
  body.page-contact .float-contact { display: none; }
  .search-overlay { padding: 10px; align-items: flex-start; }
  .search-panel { border-radius: 18px; padding: 10px 10px 14px; max-height: calc(100svh - 20px); }
  .search-form input[type="search"] { font-size: 16px; height: 44px; }
  .search-item-img { width: 50px; height: 50px; }
}
@media (prefers-reduced-motion: reduce) {
  .search-panel, .mobile-menu-panel, .mobile-menu-nav a, .float-contact, .float-btn, .search-item { transition: none; animation: none; }
  .float-btn--wa::before { animation: none; }
}
