/* ===========================================
   MENU ROW COMPONENT
   =========================================== */

.menu-row {
  display: flex;
  align-items: center;
  min-height: 72px;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #F0F0F0;
  gap: 12px;
}

/* Veg/Non-veg Indicator */
.menu-row__indicator {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

.menu-row__indicator img {
  display: block;
  width: 16px;
  height: 16px;
}

/* Name + Price */
.menu-row__info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.menu-row__name {
  font-family: 'Open Sans', sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: #1A1A1A;
  line-height: 1.3;
  word-break: break-word;
}

.menu-row__description {
  font-family: 'Open Sans', sans-serif;
  font-size: 12px;
  font-weight: 400;
  color: #6B7280;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.menu-row__price {
  font-family: 'Open Sans', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #333;
  line-height: 1.2;
}

/* Image (conditional) */
.menu-row__image {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  overflow: hidden;
}

.menu-row__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Actions Container */
.menu-row__actions {
  flex-shrink: 0;
  width: 100px;
  height: 36px;
}

/* ADD Button */
.menu-row__add-btn {
  position: relative;
  width: 100px;
  min-width: 100px !important;
  height: 36px;
  min-height: 36px;
  background: #fff !important;
  border: 1.5px solid #F28500 !important;
  border-radius: 8px;
  font-family: 'Open Sans', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #F28500 !important;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  /* 44px min tap target via padding */
  padding: 4px 0;
  margin: -4px 0;
  box-sizing: content-box;
  display: flex !important;
  align-items: center;
  justify-content: center;
  visibility: visible !important;
  opacity: 1 !important;
}

.menu-row__add-btn:active {
  background: #FFF5EE !important;
}

.menu-row__add-plus {
  position: absolute;
  top: 2px;
  right: 6px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

/* Quantity Controls */
.menu-row__qty-controls {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  align-items: center;
  justify-content: space-evenly;
  width: 100px;
  height: 36px;
  min-height: 36px;
  background: #F28500 !important;
  border-radius: 8px;
  padding: 0;
  box-sizing: border-box;
}

.menu-row__qty-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  min-width: 28px !important;
  height: 36px;
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.menu-row__qty-btn:active {
  opacity: 0.7;
}

.menu-row__qty-btn svg {
  display: block;
  width: 14px;
  height: 14px;
}

.menu-row__qty-value {
  font-family: 'Open Sans', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  min-width: 20px;
  text-align: center;
}

/* Closed State */
.menu-row__closed {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 36px;
  background: #E5E5E5;
  border-radius: 8px;
  font-family: 'Open Sans', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: #888;
}

/* ===========================================
   MENU SECTION (Category)
   =========================================== */

.menu-section {
  margin-bottom: 0;
}

.menu-section__header {
  position: sticky;
  top: 156px; /* Below sticky header (56px) + search (56px) + category nav (44px) */
  z-index: 8; /* Below category nav (z-index: 99) and search (z-index: 100) */
  background: #FAFAFA;
  padding: 12px 16px;
  margin: 0;
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #333;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #E5E5E5;
}

.menu-section__count {
  font-weight: 400;
  color: #888;
  margin-left: 8px;
}

/* ===========================================
   RESPONSIVE / MOBILE OPTIMIZATIONS
   =========================================== */

/* Ensure tap targets on touch devices */
@media (hover: none) and (pointer: coarse) {
  .menu-row__add-btn,
  .menu-row__qty-btn {
    min-height: 44px;
  }
}

/* Mobile: ensure hero doesn't overlap */
@media (max-width: 480px) {
  .menu-sticky-header__name {
    font-size: 15px;
    max-width: 40%;
  }

  .filter-pill {
    padding: 0 8px;
    font-size: 12px;
    height: 28px;
  }

  .filter-pill__icon {
    width: 12px;
    height: 12px;
  }

  .menu-hero {
    gap: 8px;
    padding: 10px 12px;
  }

  .menu-hero__name {
    font-size: 14px;
  }

  .menu-hero__status {
    font-size: 10px;
    padding: 3px 8px;
  }

  .menu-hero__table {
    font-size: 11px;
    padding: 3px 8px;
  }
}

/* Smaller screens - tighten padding */
@media (max-width: 360px) {
  .menu-row {
    padding: 12px 12px;
    gap: 10px;
  }

  .menu-row__image {
    width: 48px;
    height: 48px;
  }

  .menu-row__name {
    font-size: 14px;
  }

  .menu-sticky-header__name {
    font-size: 14px;
    max-width: 35%;
  }
}

/* Hide image on very small screens if space is tight */
@media (max-width: 320px) {
  .menu-row--has-image .menu-row__image {
    display: none;
  }

  .menu-row__actions {
    width: 88px;
  }

  .menu-row__add-btn,
  .menu-row__qty-controls {
    width: 88px;
  }
}

/* Tablet: comfortable spacing */
@media (min-width: 481px) and (max-width: 768px) {
  .menu-sticky-header__name {
    max-width: 45%;
  }

  .menu-hero {
    gap: 12px;
  }
}

/* Landscape phone fix - reduce sticky header heights */
@media (max-height: 500px) and (orientation: landscape) {
  .menu-sticky-header__inner {
    height: 44px;
  }

  .menu-search {
    padding: 4px 16px;
  }

  .category-nav {
    height: 36px;
    top: 92px; /* Adjusted for smaller heights */
  }

  .menu-section__header {
    top: 128px; /* Adjusted for smaller heights */
    padding: 8px 16px;
  }
}

/* ===========================================
   STICKY HEADER FOR MENU PAGE
   =========================================== */

.menu-sticky-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.menu-sticky-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 16px;
}

.menu-sticky-header__name {
  font-family: 'Montserrat', sans-serif;
  font-size: 18px;
  font-weight: 600;
  color: #1A1A1A;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 50%;
}

.menu-sticky-header__filters {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.menu-sticky-header__filters::-webkit-scrollbar {
  display: none;
}

.menu-sticky-header__search {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  color: #333;
}

/* ===========================================
   FILTER PILLS
   =========================================== */

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 12px;
  border-radius: 16px;
  border: 1px solid #E5E5E5;
  background: #fff;
  font-family: 'Open Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #333;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-pill:hover {
  border-color: #ccc;
}

.filter-pill--active {
  background: #F28500;
  border-color: #F28500;
  color: #fff;
}

.filter-pill__icon {
  width: 14px;
  height: 14px;
}

/* ===========================================
   CATEGORY NAVIGATION
   =========================================== */

.category-nav {
  position: sticky;
  top: 112px; /* Below sticky header (56px) + search bar (56px) */
  z-index: 99;
  background: #fff;
  border-bottom: 1px solid #E5E5E5;
  height: 44px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.category-nav::-webkit-scrollbar {
  display: none;
}

.category-nav__inner {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 16px;
  gap: 8px;
  min-width: max-content;
}

.category-nav__pill {
  flex-shrink: 0;
  height: 32px;
  padding: 0 16px;
  border-radius: 16px;
  background: #F5F5F5;
  border: none;
  font-family: 'Open Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: #333;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.category-nav__pill:hover {
  background: #EBEBEB;
}

.category-nav__pill--active {
  background: #F28500;
  color: #fff;
}

/* ===========================================
   MINI HERO
   =========================================== */

.menu-hero {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #E5E5E5;
}

.menu-hero__logo {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
}

.menu-hero__logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.menu-hero__info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.menu-hero__name {
  font-size: 16px;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-hero__status {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-family: 'Open Sans', sans-serif;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.menu-hero__status--open {
  background: #D1FAE5;
  color: #065F46;
}

.menu-hero__status--closed {
  background: #FEE2E2;
  color: #991B1B;
}

.menu-hero__table {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: #E8F5E9;
  border-radius: 12px;
  font-family: 'Open Sans', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: #2E7D32;
  flex-shrink: 0;
  white-space: nowrap;
}

.menu-hero__table-icon {
  width: 14px;
  height: 14px;
}

/* ===========================================
   PAGE CONTENT PADDING FOR CART BAR
   =========================================== */

.menu-page-content {
  padding-bottom: 100px; /* Space for sticky cart bar (64px) + safe margin */
}

@media (min-width: 768px) {
  .menu-page-content {
    padding-bottom: 120px; /* Desktop: cart bar is centered, needs more space */
  }
}

/* ===========================================
   IN-MENU SEARCH
   =========================================== */

.menu-search {
  position: sticky;
  top: 56px; /* Below sticky header */
  z-index: 100;
  background: #fff;
  padding: 8px 16px;
  border-bottom: 1px solid #E5E5E5;
}

.menu-search__inner {
  display: flex;
  align-items: center;
  height: 40px;
  background: #F5F5F5;
  border-radius: 8px;
  padding: 0 12px;
  gap: 8px;
}

.menu-search__icon {
  flex-shrink: 0;
  color: #6B7280;
}

.menu-search__input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: 'Open Sans', sans-serif;
  font-size: 15px;
  color: #1A1A1A;
  min-width: 0;
}

.menu-search__input::placeholder {
  color: #6B7280;
}

.menu-search__clear {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: none;
  align-items: center;
  justify-content: center;
  background: #E5E5E5;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: #666;
  transition: background 0.15s ease;
}

.menu-search__clear:hover {
  background: #D5D5D5;
}

.menu-search__clear.visible {
  display: flex;
}

/* Category nav and section header positioning is now default (with search present)
   These rules are kept for backwards compatibility but base styles are already correct */
.menu-search + .category-nav {
  top: 112px; /* 56px header + 56px search */
}

.menu-search ~ .menu-section .menu-section__header {
  top: 156px; /* 56px header + 56px search + 44px category nav */
}

/* When search is NOT present (fallback) */
.menu-sticky-header + .category-nav {
  top: 56px; /* Below sticky header only */
}

.menu-sticky-header + .category-nav ~ .menu-section .menu-section__header {
  top: 100px; /* 56px header + 44px category nav */
}

/* No results state */
.menu-no-results {
  padding: 48px 16px;
  text-align: center;
  color: #6B7280;
  font-family: 'Open Sans', sans-serif;
  font-size: 14px;
  display: none;
}

.menu-no-results.visible {
  display: block;
}

/* Hide menu section when empty due to search */
.menu-section.search-hidden {
  display: none;
}
