/* ============================================================
   HANSIS — Mobile Navigation Ecosystem v2.0.0
   Restored + Premium UX Upgrade
   Covers: Mobile Bar, Search Overlay, Search Cards
   ============================================================ */

/* ─────────────────────────────────────────────────────────────
   MOBILE BOTTOM NAV BAR
   Display: ONLY on mobile (0–767px)
   Hidden on tablet (768px+) and desktop (1025px+)
   ───────────────────────────────────────────────────────────── */

.hansis-mobile-bar {
  /* Hidden by default — shown only at ≤767px */
  display: none;
  /* Layout */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(60px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  /* Visual — solid white, no glass effect */
  background: #ffffff;
  border-top: 1px solid var(--hansis-border);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.07);
  /* Z-index: above content, below overlays */
  z-index: 9000;
  /* No overflow — prevents CLS and horizontal scroll */
  overflow: hidden;
}

/* Force hidden on tablet and desktop — explicit override */
@media (min-width: 768px) {
  .hansis-mobile-bar {
    display: none !important;
  }
}

/* Show on mobile */
@media (max-width: 767px) {
  .hansis-mobile-bar {
    display: flex;
    align-items: stretch;
    justify-content: space-around;
  }

  /* Compensate page body for fixed bar */
  body:not(.elementor-template-canvas) {
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  }
}

/* ── NAV ITEM ─────────────────────────────────────────────── */
.hansis-mbar-item {
  /* Layout */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1;
  min-width: 0; /* prevent overflow */
  height: 60px;
  padding: 0 4px;
  /* Reset */
  background: none;
  border: none;
  text-decoration: none;
  cursor: pointer;
  font-family: var(--hansis-font);
  /* Tap target: minimum 44×44 per WCAG */
  position: relative;
  -webkit-tap-highlight-color: transparent;
  /* Transition */
  transition: color 0.18s ease;
  /* Default colour */
  color: var(--hansis-light);
}

/* Extend tap area without affecting layout */
.hansis-mbar-item::before {
  content: '';
  position: absolute;
  inset: -4px 0;
}

.hansis-mbar-item:active {
  transform: scale(0.93);
  transition: transform 0.08s ease;
}

/* Active / hover state */
.hansis-mbar-item.active,
.hansis-mbar-item:focus-visible {
  color: var(--hansis-primary);
  outline: none;
}

.hansis-mbar-item:focus-visible {
  outline: 2px solid var(--hansis-primary);
  outline-offset: -2px;
  border-radius: 10px;
}

/* Active indicator dot */
.hansis-mbar-item.active::after {
  content: '';
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--hansis-primary);
}

/* ── ICON WRAPPER ─────────────────────────────────────────── */
.hansis-mbar-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  position: relative;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.hansis-mbar-item.active .hansis-mbar-icon,
.hansis-mbar-item:active .hansis-mbar-icon {
  transform: translateY(-1px);
}

/* ── LABEL ────────────────────────────────────────────────── */
.hansis-mbar-label {
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  transition: color 0.18s ease;
}

/* ── CART BADGE ───────────────────────────────────────────── */
.hansis-mbar-cart-wrap {
  position: relative;
}

.hansis-mbar-cart-count {
  /* Hidden by default */
  position: absolute;
  top: -6px;
  right: -8px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--hansis-primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--hansis-font);
  line-height: 18px;
  text-align: center;
  border: 2px solid #fff;
  /* Hidden when empty */
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.hansis-mbar-cart-count.visible {
  opacity: 1;
  transform: scale(1);
}

/* Logged-in account icon filled tint */
.hansis-mbar-item.is-logged-in .hansis-mbar-icon svg {
  color: var(--hansis-primary);
}

/* ─────────────────────────────────────────────────────────────
   SEARCH OVERLAY
   z-index: 20000 (above everything)
   ───────────────────────────────────────────────────────────── */

.hansis-search-overlay {
  /* Fixed full-screen backdrop */
  position: fixed;
  inset: 0;
  z-index: 20000;
  /* Flex: modal at top-center */
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 64px 16px 24px;
  /* Backdrop */
  background: rgba(17, 24, 39, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  /* Hidden state */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, visibility 0s linear 0.22s;
  /* Prevent scroll passthrough */
  overscroll-behavior: contain;
}

.hansis-search-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.22s ease;
}

/* Prevent body scroll when overlay is open */
body.hansis-search-open {
  overflow: hidden;
}

/* ── MODAL PANEL ──────────────────────────────────────────── */
.hansis-search-modal {
  background: var(--hansis-white);
  border-radius: 20px;
  padding: 16px;
  width: min(620px, 100%);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.2);
  /* Slide-in animation */
  transform: translateY(-20px) scale(0.98);
  transition: transform 0.26s cubic-bezier(0.34, 1.2, 0.64, 1);
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hansis-search-overlay.open .hansis-search-modal {
  transform: translateY(0) scale(1);
}

/* ── SEARCH INPUT ROW ─────────────────────────────────────── */
.hansis-search-top {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 2px solid var(--hansis-primary);
  border-radius: 12px;
  padding: 8px 8px 8px 14px;
  background: var(--hansis-white);
  flex-shrink: 0;
}

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

.hansis-search-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  font-family: var(--hansis-font);
  font-size: 16px; /* 16px prevents iOS zoom */
  color: var(--hansis-text);
  background: transparent;
  caret-color: var(--hansis-primary);
}

.hansis-search-input::placeholder {
  color: var(--hansis-light);
}

.hansis-search-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: var(--hansis-muted);
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  line-height: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
/* Ensure SVG icon inherits color correctly — not affected by global reset removal */
.hansis-search-close svg {
  display: inline-block;
  flex-shrink: 0;
  color: inherit;
  stroke: currentColor;
}

.hansis-search-close:hover {
  background: var(--hansis-secondary);
  color: var(--hansis-primary);
}

/* ── RESULTS SCROLLABLE AREA ──────────────────────────────── */
.hansis-search-results {
  margin-top: 12px;
  overflow-y: auto;
  flex: 1;
  /* Custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--hansis-border) transparent;
}

.hansis-search-results::-webkit-scrollbar { width: 4px; }
.hansis-search-results::-webkit-scrollbar-track { background: transparent; }
.hansis-search-results::-webkit-scrollbar-thumb { background: var(--hansis-border); border-radius: 4px; }

/* ── EMPTY / ERROR STATES ─────────────────────────────────── */
.hansis-search-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 32px 16px;
  color: var(--hansis-muted);
  text-align: center;
  font-size: 14px;
}

.hansis-search-empty svg {
  color: var(--hansis-border);
}

.hansis-search-empty strong {
  color: var(--hansis-text);
}

.hansis-search-error {
  text-align: center;
  padding: 20px;
  font-size: 13px;
  color: #EF4444;
}

/* ─────────────────────────────────────────────────────────────
   SEARCH RESULT CARD
   Premium ecommerce card layout — NOT a list row
   ───────────────────────────────────────────────────────────── */

.hansis-search-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 8px;
  border-bottom: 1px solid var(--hansis-border);
  border-radius: 10px;
  transition: background 0.15s ease;
}

.hansis-search-card:last-child {
  border-bottom: none;
}

.hansis-search-card:hover {
  background: var(--hansis-bg);
}

/* Product image */
.hansis-scard-img-wrap {
  position: relative;
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--hansis-bg);
}

.hansis-scard-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.hansis-search-card:hover .hansis-scard-img-wrap img {
  transform: scale(1.05);
}

/* Discount badge on image */
.hansis-scard-discount {
  position: absolute;
  top: 6px;
  left: 6px;
  background: #EF4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--hansis-font);
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1.5;
  z-index: 2;
}

/* Card body */
.hansis-scard-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Product title */
.hansis-scard-title {
  font-size: 14px;
  font-weight: 600;
  font-family: var(--hansis-font);
  color: var(--hansis-text);
  line-height: 1.35;
  text-decoration: none;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.15s ease;
}

.hansis-scard-title:hover {
  color: var(--hansis-primary);
}

/* Stock status row */
.hansis-scard-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hansis-scard-stock {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--hansis-font);
  padding: 2px 8px;
  border-radius: 20px;
  line-height: 1.5;
}

.hansis-scard-stock.instock {
  background: #D1FAE5;
  color: #059669;
}

.hansis-scard-stock.outofstock {
  background: #FEE2E2;
  color: #DC2626;
}

.hansis-scard-stock.backorder {
  background: #FEF3C7;
  color: #D97706;
}

/* Pricing row */
.hansis-scard-pricing {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.hansis-scard-price-now {
  font-size: 17px;
  font-weight: 700;
  font-family: var(--hansis-font);
  color: var(--hansis-primary);
  line-height: 1;
}

/* WooCommerce injects currency symbol markup */
.hansis-scard-price-now .woocommerce-Price-amount,
.hansis-scard-price-now bdi {
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
}

.hansis-scard-price-old {
  font-size: 12px;
  font-weight: 400;
  font-family: var(--hansis-font);
  color: var(--hansis-light);
  text-decoration: line-through;
  line-height: 1;
}

.hansis-scard-price-old .woocommerce-Price-amount,
.hansis-scard-price-old bdi {
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
  text-decoration: inherit;
}

/* Action buttons row */
.hansis-scard-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Add to Cart */
.hansis-scard-atc {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--hansis-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: var(--hansis-font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
  white-space: nowrap;
  line-height: 1;
}

.hansis-scard-atc:hover {
  background: var(--hansis-primary-dk);
  transform: translateY(-1px);
}

.hansis-scard-atc.loading {
  background: #93C5FD;
  pointer-events: none;
  cursor: default;
}

.hansis-scard-atc.added {
  background: #10B981;
  pointer-events: none;
}

/* Out of stock label */
.hansis-scard-oos {
  display: inline-block;
  padding: 7px 14px;
  background: #F3F4F6;
  color: var(--hansis-light);
  border-radius: 8px;
  font-family: var(--hansis-font);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

/* View Product link */
.hansis-scard-view {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border: 1.5px solid var(--hansis-border);
  border-radius: 8px;
  font-family: var(--hansis-font);
  font-size: 12px;
  font-weight: 600;
  color: var(--hansis-muted);
  text-decoration: none;
  transition: border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
  line-height: 1;
}

.hansis-scard-view:hover {
  border-color: var(--hansis-primary);
  color: var(--hansis-primary);
}

/* Spinner animation for loading state */
@keyframes hansis-spin {
  to { transform: rotate(360deg); }
}

.hansis-spin {
  animation: hansis-spin 0.7s linear infinite;
}

/* ─────────────────────────────────────────────────────────────
   SEARCH SKELETON LOADERS
   Shown while AJAX request is in flight
   ───────────────────────────────────────────────────────────── */

.hansis-search-skeleton {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 8px;
  border-bottom: 1px solid var(--hansis-border);
}

.hansis-sk-img {
  width: 80px;
  height: 80px;
  border-radius: 10px;
  flex-shrink: 0;
  background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: hansis-shimmer 1.3s infinite;
}

.hansis-sk-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
}

.hansis-sk-line {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: hansis-shimmer 1.3s infinite;
}

.hansis-sk-line.w80 { width: 80%; }
.hansis-sk-line.w60 { width: 60%; }
.hansis-sk-line.w50 { width: 50%; }

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

/* ─────────────────────────────────────────────────────────────
   RESPONSIVE ADJUSTMENTS
   ───────────────────────────────────────────────────────────── */

/* Tablet: search overlay padding adjusted */
@media (min-width: 768px) and (max-width: 1024px) {
  .hansis-search-overlay {
    padding-top: 80px;
  }
  .hansis-search-modal {
    max-height: calc(100vh - 140px);
  }
}

/* Mobile: search overlay full experience */
@media (max-width: 767px) {
  .hansis-search-overlay {
    padding: 16px 12px;
    align-items: flex-start;
  }

  .hansis-search-modal {
    border-radius: 16px;
    padding: 14px;
    max-height: calc(100vh - 90px);
    /* On mobile, push below status bar */
    margin-top: env(safe-area-inset-top, 0px);
  }

  .hansis-search-input {
    font-size: 16px; /* prevent iOS zoom */
  }

  /* Compact search card on small screens */
  .hansis-scard-img-wrap {
    width: 64px;
    height: 64px;
  }

  .hansis-scard-title {
    font-size: 13px;
  }

  .hansis-scard-price-now {
    font-size: 15px;
  }

  .hansis-scard-atc {
    font-size: 11px;
    padding: 7px 10px;
  }

  .hansis-scard-view {
    font-size: 11px;
    padding: 7px 10px;
  }

  .hansis-sk-img {
    width: 64px;
    height: 64px;
  }
}

/* Very small: 320px */
@media (max-width: 360px) {
  .hansis-mbar-label {
    font-size: 9px;
  }

  .hansis-mbar-icon {
    width: 22px;
    height: 22px;
  }

  .hansis-scard-actions {
    gap: 6px;
  }

  .hansis-scard-atc,
  .hansis-scard-view {
    padding: 6px 8px;
    font-size: 11px;
  }
}

/* ─────────────────────────────────────────────────────────────
   ELEMENTOR CANVAS OVERRIDE
   Hide all nav chrome on full-canvas pages
   ───────────────────────────────────────────────────────────── */

.elementor-template-canvas .hansis-mobile-bar,
.elementor-template-canvas .hansis-search-overlay {
  display: none !important;
}
