/*
 * KG Grill Kitchen – styles
 *
 * This stylesheet defines the look and feel for the KG Grill Kitchen ordering
 * site. The design favours a clean white background with green accents,
 * mirroring the fresh ingredients of a grill kitchen. All components are
 * responsive and work on both desktop and mobile sizes. You can tweak
 * variables in the :root block to adjust colours globally.
 */

:root {
  --primary-bg: #ffffff;
  --primary-fg: #2f2f2f;
  --accent: #2e8b57; /* sea green */
  --accent-hover: #46a96e;
  --light-bg: #f5f5f5;
  --border-radius: 8px;
  --max-width: 1200px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--primary-bg);
  color: var(--primary-fg);
  line-height: 1.5;
}

/* Header styles */
.header {
  background: var(--light-bg);
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #ddd;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap; /* allow wrapping on smaller screens */
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.site-logo {
  height: 48px;
  width: auto;
  border-radius: 8px;
  object-fit: contain;
}

/* For smaller phones, shrink the logo a bit */
@media (max-width: 480px) {
  .site-logo {
    height: 40px;
  }

  .site-title {
    font-size: 1.3rem;
  }
}

.site-title {
  margin: 0;
  font-size: 1.8rem;
  color: var(--accent);
  white-space: nowrap;
}

/* Order type selector */
.order-type {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.9rem;
}
.order-type-label {
  white-space: nowrap;
}
.order-type label {
  display: flex;
  align-items: center;
  cursor: pointer;
  gap: 0.25rem;
}
.order-type input[type="radio"] {
  margin: 0;
}

/* Cart button */
.view-cart-btn {
  background: var(--accent);
  color: var(--primary-bg);
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 1rem;
  white-space: nowrap;
}
.view-cart-btn:hover {
  background: var(--accent-hover);
}


/* Main content container */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Menu sections */
.menu-section h2 {
  margin: 0 0 1rem;
  font-size: 1.6rem;
  color: var(--accent);
}
.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.5rem;
}
.menu-item {
  background: var(--light-bg);
  border-radius: var(--border-radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.1s ease;
}
.menu-item:hover {
  transform: translateY(-4px);
}
.menu-item img {
  width: 100%;
  height: 260px;
  object-fit: cover;
}
.menu-content {
  padding: 0.8rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}
.menu-content h3 {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
  color: var(--primary-fg);
}
.menu-content p {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  color: #666;
  flex-grow: 1;
}
.menu-content .price {
  font-weight: bold;
  margin-bottom: 0.5rem;
  color: var(--accent);
}
.menu-content button {
  background: var(--accent);
  color: var(--primary-bg);
  border: none;
  padding: 0.5rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: background 0.2s ease;
}
.menu-content button:hover {
  background: var(--accent-hover);
}

/* Cart panel */
.cart-panel {
  position: fixed;
  right: 0;
  top: 0;
  width: 320px;
  height: 100%;
  background: var(--light-bg);
  box-shadow: -2px 0 8px rgba(0,0,0,0.5);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  z-index: 1000;
}
.cart-panel.open {
  transform: translateX(0);
}

.cart-header {
  padding: 1rem;
  background: var(--accent);
  color: var(--primary-bg);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.cart-header h2 {
  margin: 0;
  font-size: 1.4rem;
}
.cart-header button {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 1.4rem;
  cursor: pointer;
}

/* Continue shopping button inside cart header */
.continue-shopping-btn {
  background: var(--primary-bg);
  color: var(--accent);
  border: 1px solid var(--primary-bg);
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  font-size: 0.9rem;
  margin-left: 0.5rem;
  cursor: pointer;
}
.continue-shopping-btn:hover {
  background: var(--light-bg);
  border-color: var(--accent);
}

.cart-items {
  flex-grow: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.cart-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.cart-item img {
  width: 50px;
  height: 50px;
  border-radius: 4px;
  object-fit: cover;
}
.cart-item-details {
  flex-grow: 1;
}
.cart-item-details h4 {
  margin: 0;
  font-size: 1rem;
}
.cart-item-details .quantity {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}
.cart-item-details .quantity button {
  background: var(--accent);
  border: none;
  color: var(--primary-bg);
  padding: 0.2rem 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: 4px;
}
.cart-item-details .price {
  margin-top: 0.25rem;
  color: var(--accent);
  font-weight: bold;
}

.cart-footer {
  padding: 1rem;
  background: var(--light-bg);
  border-top: 1px solid #ddd;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.totals-row {
  font-size: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.grand-total {
  font-size: 1.2rem;
  font-weight: bold;
}
.checkout-btn {
  background: var(--accent);
  color: var(--primary-bg);
  border: none;
  padding: 0.7rem;
  border-radius: var(--border-radius);
  font-size: 1rem;
  cursor: pointer;
  margin-top: 0.5rem;
}
.checkout-btn:hover {
  background: var(--accent-hover);
}

/* Overlay for checkout */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1001;
}
.overlay.show {
  display: flex;
}
.checkout-form {
  background: var(--light-bg);
  padding: 2rem;
  border-radius: var(--border-radius);
  width: 90%;
  max-width: 500px;
  color: var(--primary-fg);
  position: relative;
}
.checkout-form h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  color: var(--accent);
  font-size: 1.4rem;
}
.checkout-form label {
  display: block;
  margin-top: 0.5rem;
}
.checkout-form input,
.checkout-form textarea {
  width: 100%;
  padding: 0.5rem;
  margin-top: 0.25rem;
  border-radius: 4px;
  border: 1px solid #ccc;
  font-size: 1rem;
}
.checkout-error {
  color: #a00;
  margin: 0 0 1rem;
  font-size: 0.9rem;
}

/* Delivery map and summary */
.delivery-map {
  height: 200px;
  margin-top: 0.5rem;
}
.distance-summary {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: #555;
}

/* Payment fieldset */
.payment-fieldset {
  margin-top: 1rem;
  border: none;
  padding: 0;
}
.payment-fieldset legend {
  margin-bottom: 0.5rem;
  font-weight: bold;
  color: var(--accent);
}
.card-element {
  background: #fff;
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  margin-top: 0.5rem;
  min-height: 40px;
}
.payment-message {
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

/* Limit overlay height and allow scrolling on mobile & desktop */
.cart-drawer,
.checkout-panel,
.checkout-form {
  max-height: 90vh;
  overflow-y: auto;
}

/* Keep header fixed inside the drawer if you have one */
.cart-header {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 2;
}

/* Give breathing room for the pay button to be fully visible */
.payment { padding-bottom: 16px; }


.place-order-btn {
  background: var(--accent);
  color: var(--primary-bg);
  border: none;
  padding: 0.7rem 1rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 1rem;
  margin-top: 1rem;
  width: 100%;
}
.place-order-btn:hover {
  background: var(--accent-hover);
}

/* Tip section styling */
.tip-section {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid #eee;
}
.tip-section h4 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  color: var(--accent);
}
.tip-note {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: #666;
}
.tip-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.tip-button {
  background: var(--light-bg);
  color: var(--primary-fg);
  border: 1px solid var(--accent);
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.tip-button:hover {
  background: var(--accent);
  color: var(--primary-bg);
}
.tip-button.selected {
  background: var(--accent);
  color: var(--primary-bg);
}
.custom-tip-container {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.custom-tip-container.hidden {
  display: none;
}
.custom-tip-container input {
  padding: 0.4rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.9rem;
}
.tip-summary {
  margin-top: 0.5rem;
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--primary-fg);
}

@media (max-width: 600px) {
  .cart-panel {
    width: 100%;
  }

  /* On small screens keep the header visible at the top when scrolling */
  .header {
    position: sticky;
    top: 0;
    z-index: 1002;
  }

  /* NEW: when user is in mobile checkout, hide header to free space */
  body.mobile-checkout-active .header {
    display: none;
  }



  /* Stack header content vertically so nothing hangs off-screen */
  .header-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .brand-block {
    justify-content: flex-start;
  }

  .order-type {
    justify-content: space-between;
    width: 100%;
  }

  .view-cart-btn {
    width: 100%;
    text-align: center;
  }
}


/* Hide the default Leaflet attribution to keep the map clean */
.leaflet-control-attribution {
  display: none !important;
}

/* Free side and sauce selectors styling inside the cart */
.cart-item-details .free-side-select,
.cart-item-details .sauce-select {
  margin-top: 0.4rem;
  font-size: 0.85rem;
}
.cart-item-details .free-side-select label,
.cart-item-details .sauce-select label {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.cart-item-details select {
  padding: 0.25rem;
  border-radius: 4px;
  border: 1px solid #ccc;
  background: #fff;
  font-size: 0.85rem;
}

@media (max-width: 768px) {
  #continueShoppingBtn {
    display: block;
    width: 100%;
    margin-bottom: 12px;
  }
}

/* When splash is visible, hide the app content and lock scroll */
body.show-splash .app-content {
  display: none;
}

.splash-screen {
  position: fixed;
  inset: 0;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.splash-screen.hidden {
  opacity: 0;
  visibility: hidden;
}

.splash-inner {
  text-align: center;
}

.splash-logo {
  width: 160px;
  max-width: 60vw;
  animation: splash-pulse 1.5s ease-in-out infinite;
}

.splash-text {
  margin-top: 12px;
  font-size: 0.95rem;
  color: #555;
}

/* Pulsing logo */
@keyframes splash-pulse {
  0%   { transform: scale(1);   opacity: 0.95; }
  50%  { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1);   opacity: 0.95; }
}

.apple-pay-btn {
  background: #000000;
  color: #ffffff;
  border-radius: 999px;
  width: 100%;
  padding: 10px 16px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 10px;
}

.apple-pay-btn:hover {
  filter: brightness(1.1);
}

.grill-points-badge {
  margin-left: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #222;
  color: #fff;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.cart-upsell {
  margin: 10px 0 0;
  padding: 10px;
  border-top: 1px dashed #ccc;
  font-size: 0.9rem;
}

.cart-upsell-text {
  margin: 0 0 6px;
}

.cart-upsell-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cart-upsell-btn {
  border: none;
  padding: 6px 10px;
  border-radius: 999px;
  background: #198754;
  color: #fff;
  font-size: 0.8rem;
  cursor: pointer;
}

.grill-points-toast {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.9);
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 9999;
}

.grill-points-toast.visible {
  opacity: 1;
}
