/* Base styles */
:root {
  /* Component measurements */
  --icon-size: 1.5rem;
  --text-size: 0.75rem;
  --line-height: 1.25;
  --vertical-gap: 0.2rem;
  --menu-padding: 0.25rem;
  --background-color: #0f172a;
  --menu-height: 3.25rem;
  --search-height: 2.625rem;
  --dock-inset-x: 0.75rem;

  /* Safe area for mobile */
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow-x: hidden;
  background-color: var(--background-color);
  overflow-y: scroll;
  scrollbar-gutter: stable; /* Reserves space for the scrollbar */
}

body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  width: 100%;
  overflow-x: hidden;
  background-color: var(--background-color);
  position: relative;
}

/* Add padding to main content area for all pages */
main, .main-content, #main-content, [role="main"] {
  padding-top: 0;
}

@media (max-width: 768px) {
  main, .main-content, #main-content, [role="main"] {
    padding-top: 0;
  }
}

/* Menu Container */
.menu-container {
  width: 100%;
  background: transparent;
  position: relative;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  justify-content: center;
  height: var(--menu-height);
}

/* Menu Items */
.menu {
  display: grid;
  width: 100%;
  max-width: 800px;
  height: 100%;
  padding: 0;
  margin: 0 auto;
}

/* Common styles for bottom/top nav tabs only — scoped so dropdown contents never inherit column layout */
.menu .menu-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.375rem;
  font-size: var(--text-size);
  line-height: var(--line-height);
  gap: var(--vertical-gap);
  text-decoration: none;
  color: rgb(156 163 175);
  position: relative;
  background: transparent;
  height: 100%;
  width: 100%;
  border: none;
  cursor: pointer;
}

/* SVG Icon styles */
.menu-icon {
  position: relative;
  display: block;
  flex-shrink: 0;
  width: var(--icon-size);
  height: var(--icon-size);
  overflow: hidden;
}

.menu-icon svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  stroke: currentColor;
}

.menu-icon > img.icon-outline,
.menu-icon > img.icon-filled {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  object-fit: contain;
  filter: brightness(0) invert(1);
  transition: opacity 120ms ease-out;
  pointer-events: none;
}

.menu-icon > img.icon-outline {
  opacity: 0.5;
  z-index: 1;
}

.menu-icon > img.icon-filled {
  opacity: 0;
  z-index: 2;
}

/* Desktop hover effects */
@media (hover: hover) and (pointer: fine) {
  .menu .menu-tab:hover .menu-icon img.icon-outline {
    opacity: 0;
  }
  .menu .menu-tab:hover .menu-icon img.icon-filled {
    opacity: 1;
  }
}

/* Active states for all devices */
.menu .menu-tab.active .menu-icon img.icon-outline,
.menu .menu-tab[aria-expanded="true"] .menu-icon img.icon-outline,
.menu .menu-tab.menu-open .menu-icon img.icon-outline {
  opacity: 0;
}
.menu .menu-tab.active .menu-icon img.icon-filled,
.menu .menu-tab[aria-expanded="true"] .menu-icon img.icon-filled,
.menu .menu-tab.menu-open .menu-icon img.icon-filled {
  opacity: 1;
}

/* Desktop hover effects for text and icon opacity */
@media (hover: hover) and (pointer: fine) {
  .menu .menu-tab:hover {
    color: rgb(255 255 255);
  }
}

/* Active states for all devices */
.menu .menu-tab.active,
.menu .menu-tab[aria-expanded="true"],
.menu .menu-tab.menu-open {
  color: rgb(255 255 255);
}


.menu-icon svg path,
.menu-icon svg circle {
  fill: none;
  stroke: currentColor;
}

/* Desktop hover effects for SVG paths */
@media (hover: hover) and (pointer: fine) {
  .menu .menu-tab:hover .menu-icon svg path,
  .menu .menu-tab:hover .menu-icon svg circle {
    fill: rgb(255 255 255);
    stroke: rgb(255 255 255);
  }
}

/* Active states for SVG paths */
.menu .menu-tab.active .menu-icon svg path,
.menu .menu-tab[aria-expanded="true"] .menu-icon svg path,
.menu .menu-tab.menu-open .menu-icon svg path,
.menu .menu-tab.active .menu-icon svg circle,
.menu .menu-tab[aria-expanded="true"] .menu-icon svg circle,
.menu .menu-tab.menu-open .menu-icon svg circle {
  fill: rgb(255 255 255);
  stroke: rgb(255 255 255);
}

.menu .menu-tab > span:last-child {
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-align: center;
  opacity: 1;
}

/* Mobile-specific styles */
@media (max-width: 768px) {
  html {
    background-color: var(--ui-bg, #0f172a);
  }

  /* Match page background so overscroll never flashes a different shade */
  body,
  body.bg-surface-sunken {
    background-color: var(--ui-bg, #0f172a);
  }

  .menu {
    max-width: none;
  }

  body {
    padding-bottom: var(--menu-height);
  }

  .menu-container {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--menu-height) + var(--safe-area-bottom));
    padding-bottom: var(--safe-area-bottom);
    background: var(--ui-bg, #0f172a);
    border-top: none;
    z-index: 40;
  }

  /* Menu popups — rounded panel above the bar */
  .dropdown-menu {
    position: fixed !important;
    top: auto !important;
    bottom: calc(var(--menu-height) + var(--safe-area-bottom));
    left: var(--dock-inset-x, 0.75rem) !important;
    right: var(--dock-inset-x, 0.75rem) !important;
    width: auto;
    min-width: 0;
    max-width: none;
    margin: 0;
    padding: 0.375rem;
    transform: none !important;
    background: var(--ui-bg, #0f172a) !important;
    border: 1px solid var(--ui-chrome-border, rgba(148, 163, 184, 0.18)) !important;
    border-bottom: none !important;
    border-radius: var(--ui-radius-lg, 0.75rem);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    box-shadow: var(--ui-dropdown-shadow, 0 8px 24px rgba(0, 0, 0, 0.36));
    color: var(--ui-text, #e2e8f0);
    z-index: 50;
    max-height: 80vh;
    overflow-y: auto;
    overflow-x: hidden;
  }

  /* Pinned search — bare input, flush on menu (no gap) */
  .fixed-search-container {
    position: fixed !important;
    top: auto !important;
    bottom: calc(var(--menu-height) + var(--safe-area-bottom));
    left: 0 !important;
    right: 0 !important;
    width: auto;
    min-width: 0;
    max-width: none;
    margin: 0;
    padding: 0.375rem 0.75rem 0 !important;
    transform: none !important;
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    z-index: 39;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    color: var(--ui-text, #e2e8f0);
  }

  body.shop-search-docked:not(.keyboard-open) .fixed-search-container input,
  body.shop-search-docked:not(.keyboard-open) .fixed-search-container .ui-search-input {
    border-bottom: none !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    box-shadow: var(--ui-dropdown-shadow, 0 8px 24px rgba(0, 0, 0, 0.36)) !important;
  }

  .fixed-search-container input,
  .fixed-search-container .ui-search-input {
    width: 100%;
    min-height: 2.25rem !important;
    height: auto;
    font-size: 0.875rem !important;
    font-weight: 400;
    line-height: 1.25 !important;
    color: var(--ui-text, #e2e8f0) !important;
    -webkit-text-fill-color: var(--ui-text, #e2e8f0);
    caret-color: var(--ui-text, #e2e8f0);
    background: var(--ui-bg, #0f172a) !important;
    border: 1px solid var(--ui-chrome-border, rgba(148, 163, 184, 0.18)) !important;
    border-radius: var(--ui-radius, 0.5rem) !important;
    box-shadow: none !important;
    padding: 0.5rem 0.75rem 0.5rem 2.125rem !important;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2394a3b8'><path d='M10 18a7.952 7.952 0 0 0 4.897-1.688l4.396 4.396 1.414-1.414-4.396-4.396A7.952 7.952 0 0 0 18 10c0-4.411-3.589-8-8-8s-8 3.589-8 8 3.589 8 8 8zm0-14c3.309 0 6 2.691 6 6s-2.691 6-6 6-6-2.691-6-6 2.691-6 6-6z'/></svg>") !important;
    background-repeat: no-repeat !important;
    background-position: left 0.625rem center !important;
    background-size: 1rem !important;
  }

  .fixed-search-container input::placeholder {
    color: var(--ui-text-muted, #94a3b8) !important;
    opacity: 1;
  }

  .fixed-search-container input:hover,
  .fixed-search-container .ui-search-input:hover {
    border-color: var(--ui-chrome-hover-border, rgba(148, 163, 184, 0.28)) !important;
  }

  .fixed-search-container input:focus,
  .fixed-search-container input:focus-visible,
  .fixed-search-container .ui-search-input:focus,
  .fixed-search-container .ui-search-input:focus-visible {
    background: var(--ui-bg, #0f172a) !important;
    border-color: var(--ui-chrome-hover-border, rgba(148, 163, 184, 0.28)) !important;
    box-shadow: none !important;
    color: #fff !important;
    -webkit-text-fill-color: #fff;
    outline: none;
  }

  .fixed-search-container .ui-search-input {
    background-image: none;
  }

  body.shop-search-docked {
    padding-bottom: calc(var(--shop-dock-reserve, calc(var(--menu-height) + var(--search-height))) + var(--safe-area-bottom));
  }

  body.shop-search-docked.keyboard-open {
    padding-bottom: var(--safe-area-bottom);
  }

  body.keyboard-open .fixed-search-container {
    top: var(--search-dock-top, 0) !important;
    bottom: auto !important;
    left: 0 !important;
    right: 0 !important;
    width: auto !important;
    z-index: 60;
    padding: 0 0.75rem 0 !important;
    margin: 0 !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }

  body.shop-search-docked.keyboard-open .fixed-search-container input,
  body.shop-search-docked.keyboard-open .fixed-search-container .ui-search-input {
    border-top: none !important;
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
    border-bottom: 1px solid var(--ui-chrome-border, rgba(148, 163, 184, 0.18)) !important;
    border-bottom-left-radius: var(--ui-radius, 0.5rem) !important;
    border-bottom-right-radius: var(--ui-radius, 0.5rem) !important;
    box-shadow: var(--ui-dropdown-shadow, 0 8px 24px rgba(0, 0, 0, 0.36)) !important;
  }

  /* Reset hover states on mobile to prevent sticky hover */
  .menu .menu-tab {
    color: rgb(156 163 175) !important;
  }
  
  .menu .menu-tab.active,
  .menu .menu-tab[aria-expanded="true"],
  .menu .menu-tab.menu-open {
    color: rgb(255 255 255) !important;
  }

  .menu .menu-tab.active .menu-icon img.icon-outline,
  .menu .menu-tab[aria-expanded="true"] .menu-icon img.icon-outline {
    opacity: 0;
  }

  .menu .menu-tab.active .menu-icon img.icon-filled,
  .menu .menu-tab[aria-expanded="true"] .menu-icon img.icon-filled {
    opacity: 1;
  }
}

/* Dropdown styles */
.dropdown-container {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 0;
  padding: 0.375rem;
  background: var(--ui-bg, #0f172a);
  border: 1px solid var(--ui-chrome-border, rgba(148, 163, 184, 0.18));
  border-top: none;
  border-bottom: none;
  border-radius: 0 0 var(--ui-radius-lg, 0.75rem) var(--ui-radius-lg, 0.75rem);
  box-shadow: var(--ui-dropdown-shadow, 0 8px 24px rgba(0, 0, 0, 0.36));
  z-index: 50;
  width: max-content;
  min-width: 12rem;
  max-width: min(90vw, 16rem);
  top: 100%;
  color: var(--ui-text, #e2e8f0);
  opacity: 0;
  visibility: hidden;
  overflow: hidden;
}

.dropdown-menu.flex {
  width: 18rem;
  max-width: min(90vw, 18rem);
}

@media (min-width: 769px) {
  #orders-dropdown.dropdown-menu {
    width: 26rem;
    min-width: 26rem;
    max-width: min(90vw, 26rem);
  }
}

.submenu-menu {
  margin: 0;
  padding: 0;
  border-radius: 0;
  overflow: hidden;
}

.dropdown-menu.is-open {
  opacity: 1;
  visibility: visible;
}

/* Tailwind's .block utility must not override flex dropdown shells */
.dropdown-menu.flex.is-open {
  display: flex;
}

/* Dropdown rows — explicit layout (no Tailwind dependency) */
.dropdown-menu .ui-dropdown-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.dropdown-menu .ui-dropdown-item img {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  margin-right: 0;
}

.dropdown-menu .submenu-toggle {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.dropdown-menu .submenu-toggle-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.dropdown-menu .submenu-toggle-chevron {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-shrink: 0;
  gap: 0.125rem;
}

.dropdown-menu > .pb-1 {
  padding: 0;
}

/* Shop Panel specific padding */
.shop-panel .dropdown-menu {
  padding: 1rem;
}

/* Mobile dropdown content spacing */
@media (max-width: 768px) {
  .dropdown-menu [role="menu"].pb-1 {
    padding-bottom: 0;
    padding-top: 0.25rem;
  }
}

/* Shop Panel Styles */
.shop-panel {
  position: fixed;
  width: 100%;
  max-width: 800px;
  left: 50%;
  transform: translateX(-50%);
  background: rgb(31 41 55);
  border: 1px solid rgb(55 65 81);
  border-radius: 0.75rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
  z-index: 60;
  opacity: 0;
  visibility: hidden;
}

.shop-panel.active {
  opacity: 1;
  visibility: visible;
}

.shop-panel-content {
  padding: 1rem;
}

.shop-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.shop-panel-close {
  background: none;
  border: none;
  color: rgb(156 163 175);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
}

.shop-panel-close:hover {
  color: rgb(255 255 255);
}

.shop-panel-search {
  margin-bottom: 1rem;
}

.shop-panel-results {
  color: rgb(156 163 175);
}

/* Desktop positioning */
@media (min-width: 769px) {
  .shop-panel {
    top: calc(var(--menu-height) + 1rem);
  }
}

/* Mobile positioning */
@media (max-width: 768px) {
  .shop-panel {
    bottom: calc(var(--menu-height) + 1rem);
  }
}

.menu.grid-cols-4 {
  grid-template-columns: repeat(4, 1fr);
}
.menu.grid-cols-5 {
  grid-template-columns: repeat(5, 1fr);
}

/* Card styles moved to shop.css — do not duplicate here */

/* Make scrollbar float over content */
::-webkit-scrollbar {
  width: 8px;
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(156, 163, 175, 0.5);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(156, 163, 175, 0.7);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(156, 163, 175, 0.5) transparent;
}

/* Prevent overflow in dropdown items */
.dropdown-menu [role="menuitem"] {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Ensure flex items in orders dropdown don't overflow */
.dropdown-menu .flex {
  min-width: 0;
}

.dropdown-menu .flex-grow {
  min-width: 0;
  flex: 1 1 0%;
}

/* Specific flex layout fixes for order items */
.dropdown-menu .flex-1 {
  flex: 1 1 0%;
  min-width: 0;
}

.dropdown-menu .flex-shrink-0 {
  flex-shrink: 0;
}

.dropdown-menu .whitespace-nowrap {
  white-space: nowrap;
}

@media (max-width: 768px) {
  body .dropdown-menu.is-open,
  body .dropdown-menu.flex.is-open {
    left: 0.75rem !important;
    right: 0.75rem !important;
  }
}