/* ============================
   MOBILE HEADER VARIABLES
============================ */
:root {
  --mobileHeaderH: 190px;
  --mobileHeaderGap: 0px;
}

/* ============================
   DESKTOP DEFAULT
============================ */
.header-desktop {
  display: block;
}

.header-mobile,
.sm-mobile-drawer {
  display: none;
}


/* ============================
   MOBILE VIEW
============================ */
@media (max-width: 991.98px) {

  .header-desktop {
    display: none !important;
  }

  .header-mobile {
    display: block !important;
    background: transparent;
    z-index: 1050;
  }

  /* MAIN MOBILE HEADER WRAPPER */
  .sm-mobile-header {
    background: #000000;
    padding: 4px 6px 1px;
    border-radius: 0 !important;
    color: white;
    position: relative;
    /* CRITICAL for absolute stack */
    min-height: 190px;
    /* Ensure space for the stack */
  }

  /* Generic row layout */
  .sm-mobile-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
  }

  /* Brand */
  .sm-mobile-brand {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 4px !important;
    flex: 1 !important;
    margin-right: 0 !important;
    text-align: center !important;
    position: relative !important;
    z-index: 101 !important;
    pointer-events: auto !important;
  }

  /* Logo in the main mobile header (not just the drawer) */
  .sm-mobile-header .sm-mobile-logo {
    height: 62px;
    width: 62px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.25);
    margin-bottom: 2px;
    display: block !important;
  }

  /* Keep the legacy class name working for the drawer */
  .sm-mobile-logo {
    height: 52px;
    width: 52px;
    border-radius: 50%;
    object-fit: cover;
  }

  .sm-mobile-title {
    font-size: 18px;
    font-weight: 700;
    color: white;
    line-height: 1.2;
    text-align: center !important;
    display: block !important;
    white-space: normal !important;
    word-break: break-word !important;
    max-width: calc(100vw - 130px); /* leave room for the actions stack on the right */
  }

  .sm-mobile-description {
    font-family: "Poppins", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif !important;
    font-size: 13px;
    color: #ffffff !important;
    font-weight: 700 !important;
    display: block !important;
    line-height: 1.2;
    text-align: center !important;
    margin-top: 4px !important;
    margin-bottom: 10px !important;
  }

  .brand-text-container {
    align-items: center !important;
    justify-content: center !important;
  }

  /* Menu */
  .sm-mobile-menu-btn {
    font-size: 28px;
    background: none;
    border: none;
    color: white;
    padding: 0;
    margin: 0;
  }

  /* Status Group (Mobile) */
  .sm-status-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 8px;
  }

  .status-badge {
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    display: inline-block;
    text-transform: uppercase;
  }

  .status-badge.open {
    background: #2ECC71;
  }

  .status-badge.closed {
    background: #C0392B;
  }

  /* Mobile closed note under status badge */
  .mobile-closed-note {
    margin-top: 4px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, .9);
    line-height: 1.2;
  }



  /* VERTICAL STACK FOR ACTIONS (Hamburger -> Cart -> Search+Book) */
  .header-actions-v-stack {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-end !important;
    justify-content: space-between !important;
    /* Restore vertical centering */
    position: absolute !important;
    right: 6px !important;
    top: 6px !important;
    bottom: 4px !important; /* Increased for breathing room */
    z-index: 102 !important;
    pointer-events: none !important; /* Allow clicks to pass through to the logo */
  }

  .header-actions-v-stack button,
  .header-actions-v-stack a {
    pointer-events: auto !important; /* Re-enable clicks for the actual buttons */
  }

  /* BRAND ALIGNMENT */
  .header-main-row {
    align-items: flex-start !important;
  }

  /* Correct margin for actions within stack */
  .sm-mobile-actions {
    display: flex;
    align-items: center;
    margin-bottom: 2px !important;
    /* 2 pixel gap below the cart button */
  }

  /* NEW BOTTOM ROW: Search + Book */
  .bottom-actions-row {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    margin-right: 0 !important;
  }

  .sm-mobile-book-btn {
    background: #FFC107 !important;
    color: #000 !important;
    font-size: 13px !important;
    font-weight: 800 !important;
    text-decoration: none !important;
    padding: 0 12px !important; /* Reduced padding from 16px */
    border-radius: 12px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 44px !important;
    /* Slightly shorter for stacking */
    border: none !important;
    white-space: nowrap !important;
    margin-right: 0 !important;
    margin-top: 0 !important;
  }

  /* Hamburger Menu Button */
  .sm-mobile-menu-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 32px;
    padding: 0;
    line-height: 1;
    display: block !important;
    cursor: pointer;
    margin-bottom: 0 !important;
  }

  /* Search + Cart Row - removed as it's now in the stack */
  .search-cart-row,
  .book-row {
    display: none !important;
  }

  /* Book Row at bottom */
  .book-row {
    justify-content: flex-end !important;
    margin-top: 4px !important;
    /* Reduced for tighter stacking */
    margin-bottom: 4px !important;
  }

  /* Cart + Search button base */
  .sm-mobile-cart-btn {
    background: #FFC107 !important;
    padding: 12px 14px;
    border-radius: 12px;
    color: black;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none !important;
  }


  /* Consolidate sizing for ALL header buttons (Cart, Search) */
  .sm-mobile-actions .sm-mobile-cart-btn,
  .bottom-actions-row .sm-mobile-search-btn {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;

    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;

    line-height: 1 !important;
    flex: 0 0 44px !important;
    border-radius: 12px !important;

    background: linear-gradient(145deg, #FFD000, #FFC107) !important;
    border: 1px solid #E6AE06 !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1) !important;
  }

  /* Keep the icons stable */
  .sm-mobile-actions .sm-mobile-cart-btn svg,
  .sm-mobile-actions .sm-mobile-search-btn svg {
    width: 22px !important;
    height: 22px !important;
    display: block !important;
  }

  /* Cart styling inherited from header.css now */

  .sm-mobile-cart-btn * {
    text-decoration: none !important;
  }


  /* Search button behaves like cart but square */
  .sm-mobile-search-btn {
    border: 0;
    padding: 0 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
  }

  .sm-mobile-search-btn svg {
    width: 22px;
    height: 22px;
    color: #111;
    stroke: currentColor;
  }

  /* Legacy empty block for diffing */

  /* Drawer Backdrop */
  .drawer-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9998;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .drawer-backdrop.open {
    display: block;
    opacity: 1;
  }

  /* Drawer Container */
  .sm-mobile-drawer {
    display: block;
    position: fixed;
    top: 0;
    right: -100%;
    width: 280px;
    height: 100%;
    background: #151515;
    z-index: 9999;
    padding: 24px;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.5);
    transition: right 0.3s cubic-bezier(0.82, 0.085, 0.395, 0.895);
    border-left: 1px solid #333;
    overflow-y: auto;
  }

  .sm-mobile-drawer.open {
    right: 0;
  }

  /* Close Button */
  .close-drawer-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s;
  }

  .close-drawer-btn:hover,
  .close-drawer-btn:active {
    background: rgba(255, 255, 255, 0.2);
  }

  /* Drawer Logo & Title */
  .drawer-logo {
    height: 80px;
    width: 80px;
    border-radius: 50%;
    object-fit: cover;
    margin: 30px auto 16px;
    display: block;
    border: 3px solid #333;
  }

  .sm-mobile-drawer h2 {
    text-align: center;
    margin-bottom: 4px;
    font-size: 20px;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.5px;
  }

  .drawer-description {
    font-family: "Poppins", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif !important;
    text-align: center;
    font-size: 13px;
    color: rgba(245, 239, 230, 0.7) !important;
    margin-bottom: 24px;
    font-weight: 500;
  }

  /* Drawer Links */
  .drawer-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .drawer-links a {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    font-size: 16px;
    font-weight: 600;
    color: #f8f9fa !important;
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.2s ease;
    background: transparent;
  }

  .drawer-links a svg {
    stroke: #aaa;
    transition: stroke 0.2s ease;
  }

  .drawer-links a:hover,
  .drawer-links a:active {
    background: rgba(255, 255, 255, 0.05);
    color: #FFC107 !important;
    transform: translateX(4px);
  }

  .drawer-links a:hover svg,
  .drawer-links a:active svg {
    stroke: #FFC107;
  }

  /* Drawer Menu Toggle (Collapsible) */
  .drawer-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }

  .drawer-menu-toggle .chevron-icon {
    stroke: #888;
    transition: transform 0.3s ease, stroke 0.2s ease;
  }

  .drawer-menu-toggle[aria-expanded="true"] .chevron-icon {
    transform: rotate(180deg);
    stroke: #FFC107;
  }

  .drawer-menu-toggle[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.05);
    color: #FFC107 !important;
  }

  .drawer-menu-toggle[aria-expanded="true"] svg:not(.chevron-icon) {
    stroke: #FFC107;
  }

  /* Sub-links (Categories) Styling */
  .drawer-categories-inner {
    display: flex;
    flex-direction: column;
    padding-bottom: 8px;
    gap: 4px;
    border-left: 2px solid rgba(255, 255, 255, 0.05);
    margin-left: 24px;
    padding-left: 8px;
    margin-top: 4px;
  }

  .drawer-links a.drawer-sub-link {
    font-size: 14px;
    font-weight: 500;
    color: #adb5bd !important;
    padding: 8px 12px;
    gap: 8px;
    border-radius: 8px;
  }

  .drawer-links a.drawer-sub-link:hover,
  .drawer-links a.drawer-sub-link.active {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.03);
    transform: translateX(3px);
  }

  .drawer-links a.drawer-sub-link span {
    font-size: 11px !important;
  }

  /* Logout special styling */
  .drawer-links a.logout-link {
    margin-top: 16px;
    border-top: 1px solid #333;
    border-radius: 0;
    padding-top: 20px;
    color: #E74C3C !important;
  }

  .drawer-links a.logout-link svg {
    stroke: #E74C3C;
  }

  .drawer-links a.logout-link:hover {
    background: transparent;
    color: #c0392b !important;
  }

  .drawer-links a.logout-link:hover svg {
    stroke: #c0392b;
  }

  a.sm-mobile-brand,
  a.sm-mobile-brand:link,
  a.sm-mobile-brand:visited,
  a.sm-mobile-brand:hover,
  a.sm-mobile-brand:focus,
  a.sm-mobile-brand:active {
    text-decoration: none !important;
    color: inherit !important;
    -webkit-tap-highlight-color: transparent;
  }
}

/* ============================
   MOBILE CATEGORY BAR
============================ */
.category-bar {
  background: #000000 !important;
  padding: 6px 0;
  position: -webkit-sticky !important;
  position: sticky !important;
  top: calc(var(--mobileHeaderH, 0px) + var(--mobileHeaderGap, 0px)) !important;
  z-index: 1025 !important;
}

/* Remove Bootstrap container padding ONLY for category bar */
.category-bar .container {
  max-width: 100% !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

@media (max-width: 991.98px) {

  /* Scrollable row (MOBILE ONLY) */
  .category-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden !important;
    scroll-behavior: smooth;
    padding: 6px 12px;
    -ms-overflow-style: none;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    max-width: 100%;
    box-sizing: border-box;
  }

  .category-scroll::-webkit-scrollbar {
    display: none;
  }

  .category-bar {
    margin-top: -5px !important;
  }

  /* Let text auto-expand the pill */
  .category-pill {
    flex: 0 0 auto !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
    word-break: normal !important;
    text-align: center !important;
    padding-left: 14px !important;
    padding-right: 14px !important;
    min-height: 38px !important;
    height: auto !important;
    line-height: normal !important;
  }
}


/* Category pill style (INACTIVE = yellow) */
.category-pill {
  white-space: nowrap;
  flex-shrink: 0;
  border-radius: 30px !important;
  padding: 6px 14px !important;
  font-size: 14px !important;

  background: #FFC107 !important;
  border: 2px solid #FFB300 !important;
  color: #111 !important;

  font-weight: 600 !important;
  transition: 0.2s;

  /* Disable press and hold functionality natively */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Highlighted pill for selected category (ACTIVE = white) */
.category-pill.btn-warning,
.category-pill.btn-warning:not(:disabled):not(.disabled),
.category-pill.btn-warning:not(:disabled):not(.disabled):hover,
.category-pill.btn-warning:not(:disabled):not(.disabled):focus,
.category-pill.btn-warning:not(:disabled):not(.disabled):active {
  background: #fff !important;
  border-color: #fff !important;
  color: #111 !important;
  font-weight: 800 !important;
  filter: none !important;
}

/* ============================
   MOBILE SEARCH POPUP (Modal)
============================ */
@media (max-width: 991.98px) {
  .mobile-search-dialog {
    max-width: 100%;
    width: 100%;
    margin: 0;
    margin-top: var(--mobileHeaderH, 70px);
    height: auto;
  }

  .mobile-search-content {
    border-radius: 0 0 18px 18px;
    min-height: auto;
  }

  .mobile-search-content .modal-header {
    padding-top: 14px;
    padding-bottom: 8px;
    background-color: #000000 !important;
    color: #fff !important;
    border-radius: 0;
  }

  .mobile-search-content .modal-header .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%) !important;
    opacity: 1 !important;
  }

  .mobile-search-content .modal-title {
    color: #fff !important;
  }

  .mobile-search-content .modal-body {
    padding-top: 10px;
    padding-bottom: 16px;
  }
}

.modal-search-btn {
  background: #F6A623 !important;
  border: 0 !important;
  color: #111 !important;
  font-weight: 800;
  border-radius: 12px;
  padding: 12px 14px;
}

.modal-search-btn:active {
  transform: scale(.99);
}

.mobile-search-form-modal {
  position: relative;
}

.mobile-search-input {
  width: 100%;
  height: 46px;
  border-radius: 999px !important;
  padding: 0 46px 0 16px;
  border: 1px solid #404040 !important;
  background: #262626 !important;
  color: #fff !important;
  caret-color: #ffd700 !important;
  outline: none !important;
  transition: all 0.2s ease-in-out;
}

.mobile-search-input:focus {
  outline: none !important;
  background-color: #fff !important;
  border-color: #FFD700 !important;
  color: #000 !important;
  box-shadow: 0 0 0 2px rgba(255, 215, 0, 0.4) !important;
}

/* ============================
   AUTOCOMPLETE (mobile modal)
============================ */
.autocomplete-wrap {
  position: relative;
  width: 100%;
}

.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;

  background: #262626 !important;
  border: 1px solid #444 !important;
  border-radius: 10px;

  margin-top: 6px;
  padding: 8px 0;

  max-height: 300px;
  overflow-y: auto;

  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.45);

  z-index: 9999;
  display: none;
}

.autocomplete-item {
  padding: 12px 18px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: #333 !important;
}

.autocomplete-item .name {
  font-size: 16px;
  color: #fff !important;
}

/* Ensure meta text is also visible on mobile */
.autocomplete-item .meta .category {
  color: #adb5bd !important;
}

.autocomplete-item .meta .price {
  color: #ffd700 !important;
  font-weight: 600;
}

/* ============================
   CLEAR BUTTON (used in modal + desktop too)
============================ */
.has-clear {
  padding-right: 52px !important;
}

.search-clear-btn {
  position: absolute !important;
  right: 10px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;

  width: 30px !important;
  height: 30px !important;
  border: 0 !important;
  border-radius: 999px !important;

  background: rgba(255, 255, 255, 0.15) !important;
  color: #fff !important;

  display: none;
  align-items: center !important;
  justify-content: center !important;

  padding: 0 !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
}

.search-clear-btn:hover {
  background: rgba(255, 255, 255, 0.25) !important;
  color: #fff !important;
}

.search-clear-btn:active {
  transform: translateY(-50%) translateY(1px) scale(.97) !important;
}

/* ============================
   STICKY HEADER (mobile)
============================ */
.header-mobile {
  position: -webkit-sticky !important;
  position: sticky !important;
  top: 0 !important;
  z-index: 1030 !important;
  background: transparent;
}

/* ============================
   DESKTOP: Category bar STICKY
============================ */
@media (min-width: 992px) {
  .category-bar {
    position: sticky !important;
    top: 0 !important;
    z-index: 100 !important;
  }
}

/* Mobile: ADD line between header and category bar */
@media (max-width: 991.98px) {
  .header-mobile {
    border-bottom: 1px solid #ffffff !important;
  }
}

/* Mobile LANDSCAPE: disable sticky header + sticky category bar */
@media (max-width: 991.98px) and (orientation: landscape) {
  .header-mobile {
    position: relative !important;
    /* was sticky */
    top: auto !important;
  }

  /* Slightly smaller logo and title in landscape */
  .sm-mobile-logo {
    height: 42px !important;
    width: 42px !important;
  }

  .sm-mobile-title {
    font-size: 17px !important;
  }

  /* Compact status badge */
  .status-badge {
    font-size: 11px !important;
    padding: 4px 10px !important;
  }

  .status-row .status-badge {
    margin-top: -10px !important;
  }

  .mobile-closed-note {
    font-size: 10px !important;
    margin-top: -4px !important;
  }

  .category-bar {
    position: relative !important;
    /* was sticky */
    top: auto !important;
  }

  .category-pill {
    font-size: 12px !important;
    padding: 4px 10px !important;
    min-height: 32px !important;
  }
}

/* If you forced mobile header on tablets via (hover:none)/(pointer:coarse), 
   this makes sure landscape tablets also lose sticky */
@media (orientation: landscape) and (hover: none) and (pointer: coarse) {
  .header-mobile {
    position: relative !important;
    top: auto !important;
  }

  .category-bar {
    position: relative !important;
    top: auto !important;
  }
}