/**
 * Guest Menu Page Styles
 * Styles specific to the guest menu page including language selector and dynamic theming
 */

/* Dynamic theming with CSS custom properties */
:root {
  --menu-background-color: #f8f9fa; /* Default fallback - overridden by restaurant settings */
  --menu-button-color: #C27800; /* Default fallback - overridden by restaurant settings */
}

/* ── Restaurant Header Image ─────────────────────────────── */
.menu-header {
  margin-bottom: 0;
  text-align: center;
  background: transparent !important;
  padding: 0 !important;
  color: inherit !important;
}

.restaurant-image-container {
  position: relative;
  width: 100%;
  border-radius: 0 0 12px 12px;
  overflow: hidden;
  background: transparent;
}

.restaurant-header-image {
  width: 100%;
  height: 250px;
  object-fit: cover;
  display: block;
}

/* ── Language Selector (overlaid on image) ────────────────── */
.language-selector {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 10;
  margin: 0;
  text-align: right;
}

.language-selector--standalone {
  position: static;
  margin: 0.75rem 0;
  text-align: right;
}

.language-dropdown {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  display: inline-block;
}

.language-selector--standalone .language-dropdown {
  background: white;
  border: 1px solid var(--color-gray-300);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.language-dropdown select {
  background: transparent;
  border: none;
  font-size: 0.9rem;
  cursor: pointer;
}

/* WiFi password copy functionality */
.wifi-password-copy {
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
  background: rgba(194, 120, 0, 0.1);
  border: 1px solid rgba(194, 120, 0, 0.2);
  display: inline-block;
  user-select: none;
}

.wifi-password-copy:hover {
  background: rgba(194, 120, 0, 0.2);
  border-color: rgba(194, 120, 0, 0.4);
  transform: translateY(-1px);
}

.wifi-password-copy:active {
  transform: translateY(0);
}

.copy-icon {
  margin-left: 6px;
  font-size: 0.9em;
  opacity: 0.7;
  transition: all 0.2s ease;
}

.copy-icon svg {
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
}

.wifi-password-copy:hover .copy-icon {
  opacity: 1;
}

/* ── Restaurant Contact Info ─────────────────────────────── */
.restaurant-contact-info {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.contact-item {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.contact-item a {
  color: var(--menu-button-color);
  text-decoration: none;
}

.contact-item a:hover {
  text-decoration: underline;
}

/* SVG contact icons (map pin, phone) */
.contact-icon-svg {
  width: 18px;
  height: 18px;
  fill: var(--menu-button-color);
  flex-shrink: 0;
  margin-top: 2px;
}

/* ── Social Media Icons ──────────────────────────────────── */
.social-icons {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.social-icon-link {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.social-icon-link:hover {
  opacity: 0.7;
  transform: translateY(-1px);
}

.social-icon-svg {
  width: 20px;
  height: 20px;
  fill: var(--menu-button-color);
}

/* ── Order Type Toggle ───────────────────────────────────── */
.order-type-toggle {
  display: flex;
  gap: 0;
  margin: 1rem auto 0.75rem;
  max-width: 300px;
  border-radius: 25px;
  overflow: hidden;
  border: 2px solid var(--menu-button-color);
}

.order-type-btn {
  flex: 1;
  padding: 10px 16px;
  border: none;
  background: var(--bg-white);
  color: var(--menu-button-color);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.order-type-btn.active {
  background: var(--menu-button-color);
  color: var(--text-white);
}

.order-type-btn:hover:not(.active) {
  background: rgba(194, 120, 0, 0.1);
}

/* ── Horizontal Category Tabs ────────────────────────────── */
.category-tabs {
  margin: 0.75rem 0;
  position: relative;
}

.category-tabs-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 4px 0;
}

.category-tabs-scroll::-webkit-scrollbar {
  display: none;
}

.category-tab {
  scroll-snap-align: start;
  flex-shrink: 0;
  padding: 8px 18px;
  border: 1.5px solid var(--menu-button-color);
  background: var(--bg-white);
  color: var(--menu-button-color);
  border-radius: 25px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.category-tab:hover,
.category-tab.active {
  background: var(--menu-button-color);
  color: var(--text-white);
}

/* ── Search ──────────────────────────────────────────────── */
.menu-search {
  margin: 0.75rem 0;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  font-size: 1rem;
  pointer-events: none;
  z-index: 1;
}

.search-input {
  width: 100%;
  padding: 10px 36px 10px 38px;
  border: 1.5px solid var(--border-color);
  border-radius: 25px;
  font-size: 0.9rem;
  background: var(--bg-white);
  transition: border-color 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: var(--menu-button-color);
}

.search-clear {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

.search-no-results {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ── Compact Menu Cards (override base menu.css) ─────────── */
.menu-grid {
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding-bottom: 16px;
}

.menu-card {
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.menu-card-image {
  width: 100%;
  overflow: hidden;
}

.menu-card-image .menu-item-image {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.menu-card:hover .menu-card-image .menu-item-image {
  transform: scale(1.05);
}

.menu-card-content {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.menu-card-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.menu-card-price-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
}

.menu-card-current-price {
  color: var(--success-color);
  font-size: 1rem;
  font-weight: 700;
}

.menu-card-original-price {
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-decoration: line-through;
}

/* ── Badges & Tags ───────────────────────────────────────── */
.badge-best-choice {
  display: inline-block;
  background: #fff3cd;
  color: #856404;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  white-space: nowrap;
}

.dietary-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.dietary-tag {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  white-space: nowrap;
}

.dietary-tag-spicy { background: #ffe0e0; color: #c62828; }
.dietary-tag-vegan { background: #e8f5e9; color: #2e7d32; }
.dietary-tag-vegetarian { background: #f1f8e9; color: #558b2f; }
.dietary-tag-gluten_free { background: #fff8e1; color: #f57f17; }
.dietary-tag-dairy_free { background: #e3f2fd; color: #1565c0; }
.dietary-tag-nut_free { background: #fce4ec; color: #ad1457; }

.portion-size {
  color: var(--text-secondary);
  font-size: 0.75rem;
}

/* ── Item Detail Modal ───────────────────────────────────── */
.item-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.item-modal.active {
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.item-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.2s ease;
}

.item-modal-content {
  position: relative;
  background: var(--bg-white);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  z-index: 1;
  animation: slideUp 0.3s ease;
}

.item-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.4);
  color: white;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.3rem;
  cursor: pointer;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.item-modal-image-wrap img {
  width: 100%;
  max-height: 250px;
  object-fit: cover;
  display: block;
}

.item-modal-body {
  padding: 16px 20px;
}

.item-modal-header {
  margin-bottom: 8px;
}

.item-modal-name {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 4px 0 8px;
  color: var(--text-primary);
}

.item-modal-price {
  margin-bottom: 12px;
}

.modal-current-price {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--success-color);
}

.modal-original-price {
  font-size: 1rem;
  color: var(--text-secondary);
  text-decoration: line-through;
  margin-left: 8px;
}

.modal-base-price {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-decoration: line-through;
  margin-left: 8px;
}

.item-modal-description {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 12px;
}

.item-modal-description:empty {
  display: none;
}

.item-modal-modifiers {
  margin-bottom: 12px;
}

.item-modal-modifiers:empty {
  display: none;
}

.item-modal-quantity {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.item-modal-footer {
  padding: 0 20px calc(20px + env(safe-area-inset-bottom, 0px));
  position: sticky;
  bottom: 0;
  background: var(--bg-white);
}

.item-modal-footer .order-btn {
  border-radius: 25px;
  font-size: 1.05rem;
  padding: 14px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* ── Sticky Cart Bar ─────────────────────────────────────── */
.sticky-cart-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 900;
  background: var(--menu-button-color);
  animation: slideUp 0.3s ease;
}

.sticky-cart-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom, 0px));
  background: var(--menu-button-color);
  color: var(--text-white);
  text-decoration: none;
  font-size: 1rem;
  font-weight: 600;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.15);
}

.sticky-cart-link:hover {
  filter: brightness(0.9);
}

.sticky-cart-total {
  font-size: 1.1rem;
  font-weight: 700;
}

/* Add padding to page bottom to prevent content from hiding behind sticky bar */
body.has-cart-bar main {
  padding-bottom: var(--sticky-cart-height, 60px);
}

/* ── Mobile responsive adjustments ───────────────────────── */
@media (max-width: 768px) {
  .restaurant-header-image {
    height: 180px;
  }

  .wifi-password-copy {
    padding: 6px 10px;
    font-size: 0.9rem;
  }

  .item-modal-content {
    max-height: 92vh;
  }
}

@media (max-width: 480px) {
  .restaurant-header-image {
    height: 150px;
  }
}

@media (max-width: 360px) {
  .menu-grid {
    grid-template-columns: 1fr;
  }

  .sticky-cart-link {
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
    font-size: 0.9rem;
  }

  .sticky-cart-total {
    font-size: 1rem;
  }

  .item-modal-image-wrap img {
    max-height: 180px;
  }

  .item-modal-name {
    font-size: 1.1rem;
  }

  .modal-current-price {
    font-size: 1.2rem;
  }

  .item-modal-body {
    padding: 12px 16px;
  }

  .item-modal-footer {
    padding: 0 16px calc(16px + env(safe-area-inset-bottom, 0px));
  }
}

/* Desktop modal - centered card instead of bottom sheet */
@media (min-width: 769px) {
  .item-modal.active {
    align-items: center;
  }

  .item-modal-content {
    border-radius: 16px;
    max-height: 85vh;
  }

  .item-modal-footer {
    padding: 0 20px 20px;
  }
}
