/* ==========================================================================
   PANG MU (ปังมู) - Premium Cafe & Lucky Minimal Theme (Responsive Fixed)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600&family=Playfair+Display:ital,wght@0,600;1,400&display=swap');

:root {
  --bg-primary: #F9F6F0;
  --bg-dark: #1C2D27;
  --bg-card: #FFFFFF;
  --text-dark: #2B2623;
  --text-light: #F9F6F0;
  --text-muted: #7A726C;
  --toast-brown: #9E613B;
  --gold-accent: #D4AF37;
  --gold-glow: rgba(212, 175, 55, 0.25);
  --shadow-soft: 0 12px 32px rgba(28, 45, 39, 0.08);
  --shadow-hover: 0 20px 40px rgba(28, 45, 39, 0.15);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 8px;
  --transition-fast: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* แก้ไข height ให้ใช้ 100dvh รองรับ iPad Safari */
html, body {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: 'Kanit', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-dark);
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* Base Layout Container */
.app-container {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* Header & Brand Nav - แก้ไข Responsive ให้ยืดหยุ่นตาม iPad */
.header-nav {
  min-height: 70px;
  height: auto;
  padding: 12px 24px;
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(249, 246, 240, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 100;
  border-bottom: 1px solid rgba(212, 175, 55, 0.2);
  flex-wrap: wrap;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  flex-shrink: 0;
}

.brand-icon {
  width: 42px;
  height: 42px;
  background-color: var(--bg-dark);
  border: 1.5px solid var(--gold-accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold-accent);
  box-shadow: 0 0 12px var(--gold-glow);
}

.brand-title {
  display: flex;
  flex-direction: column;
}

.brand-title .th {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--bg-dark);
  letter-spacing: 0.5px;
  line-height: 1.1;
}

.brand-title .en {
  font-family: 'Playfair Display', serif;
  font-size: 0.75rem;
  letter-spacing: 2px;
  color: var(--toast-brown);
}

/* Category Navigation Bar - สกรอลล์ซ้ายขวาอัตโนมัติเมื่อจอแคบ */
.nav-categories {
  display: flex;
  gap: 8px;
  background: rgba(28, 45, 39, 0.05);
  padding: 6px;
  border-radius: 50px;
  overflow-x: auto;
  white-space: nowrap;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

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

.nav-btn {
  border: none;
  background: transparent;
  padding: 8px 18px;
  border-radius: 40px;
  font-family: 'Kanit', sans-serif;
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text-dark);
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.nav-btn.active {
  background: var(--bg-dark);
  color: var(--gold-accent);
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(28, 45, 39, 0.2);
}

/* Main View Wrapper */
.main-view {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* ==========================================================================
   1. DIGITAL MENU DISPLAY (HOME AUTO SLIDER)
   ========================================================================== */
.slider-view {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  opacity: 1;
  visibility: visible;
  transition: opacity var(--transition-smooth), visibility var(--transition-smooth);
  background: #15241F;
}

.slider-view.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.slider-track {
  width: 100%;
  height: 100%;
  display: flex;
  transition: transform 0.65s cubic-bezier(0.25, 1, 0.5, 1);
  will-change: transform;
}

.slide-item {
  min-width: 100%;
  height: 100%;
  display: flex;
  position: relative;
  overflow: hidden;
}

.slide-bg-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.65) contrast(1.05);
  transform: scale(1.03);
  transition: transform 6s ease-out;
}

.slide-item.active .slide-bg-img {
  transform: scale(1);
}

.slide-content-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 40px 5% calc(30px + env(safe-area-inset-bottom)) 5%;
  background: linear-gradient(to top, rgba(20, 32, 27, 0.95) 0%, rgba(20, 32, 27, 0.6) 50%, transparent 100%);
  color: var(--text-light);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
}

.slide-text {
  max-width: 60%;
}

.slide-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(212, 175, 55, 0.2);
  border: 1px solid var(--gold-accent);
  color: var(--gold-accent);
  padding: 6px 16px;
  border-radius: 30px;
  font-size: 0.9rem;
  margin-bottom: 12px;
  backdrop-filter: blur(8px);
}

.slide-title-th {
  font-size: clamp(2rem, 4vw, 3.2rem);
  font-weight: 600;
  line-height: 1.15;
  color: #FFFFFF;
  text-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.slide-title-en {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.1rem, 2.5vw, 1.6rem);
  font-style: italic;
  color: var(--gold-accent);
  margin-bottom: 8px;
}

.slide-desc {
  font-size: clamp(0.95rem, 1.5vw, 1.15rem);
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.5;
  font-weight: 300;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.slide-price-tag {
  text-align: right;
  flex-shrink: 0;
}

.price-num {
  font-size: clamp(2.8rem, 5vw, 3.8rem);
  font-weight: 600;
  color: var(--gold-accent);
  line-height: 1;
}

.price-currency {
  font-size: clamp(1rem, 2vw, 1.4rem);
  margin-left: 4px;
  color: #FFFFFF;
}

/* Slider Pagination Dots */
.slider-pagination {
  position: absolute;
  top: 24px;
  right: 5%;
  display: flex;
  gap: 8px;
  z-index: 20;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  transition: var(--transition-fast);
  cursor: pointer;
}

.dot.active {
  background: var(--gold-accent);
  width: 28px;
  border-radius: 20px;
  box-shadow: 0 0 10px var(--gold-glow);
}

/* ==========================================================================
   2. CATEGORY GRID MENU DISPLAY
   ========================================================================== */
.grid-view {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  overflow-y: auto;
  padding: 24px 5% calc(40px + env(safe-area-inset-bottom)) 5%;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-smooth), visibility var(--transition-smooth);
}

.grid-view.active {
  opacity: 1;
  visibility: visible;
}

.grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

.menu-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  cursor: pointer;
  border: 1px solid rgba(212, 175, 55, 0.12);
  position: relative;
}

.menu-card:active, .menu-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

.card-img-wrapper {
  width: 100%;
  height: 220px;
  position: relative;
  overflow: hidden;
  background-color: #EAE5DC;
}

.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s ease;
}

.menu-card:hover .card-img {
  transform: scale(1.06);
}

.card-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  background: rgba(28, 45, 39, 0.85);
  color: var(--gold-accent);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  backdrop-filter: blur(6px);
  border: 1px solid rgba(212, 175, 55, 0.4);
}

.card-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6px;
}

.card-title-th {
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text-dark);
}

.card-title-en {
  font-family: 'Playfair Display', serif;
  font-size: 0.9rem;
  color: var(--toast-brown);
  margin-bottom: 8px;
}

.card-price {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--toast-brown);
  white-space: nowrap;
}

.card-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
  font-weight: 300;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ==========================================================================
   3. PRODUCT DETAIL MODAL
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 25, 21, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-fast), visibility var(--transition-fast);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: var(--bg-card);
  width: 100%;
  max-width: 850px;
  max-height: 90vh;
  border-radius: var(--radius-lg);
  overflow-y: auto;
  display: flex;
  box-shadow: 0 25px 50px rgba(0,0,0,0.3);
  transform: scale(0.95);
  transition: transform var(--transition-smooth);
  border: 1px solid rgba(212, 175, 55, 0.3);
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

.modal-img-col {
  width: 50%;
  min-height: 350px;
  position: relative;
  background-color: #EAE5DC;
}

.modal-img-col img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-info-col {
  width: 50%;
  padding: 32px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.modal-badge {
  display: inline-block;
  background: var(--bg-dark);
  color: var(--gold-accent);
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.modal-title-th {
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--text-dark);
  line-height: 1.2;
}

.modal-title-en {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  color: var(--toast-brown);
  font-style: italic;
  margin-bottom: 12px;
}

.modal-price {
  font-size: 2rem;
  font-weight: 600;
  color: var(--toast-brown);
  margin-bottom: 16px;
}

.modal-desc {
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 20px;
  font-weight: 300;
}

.btn-close-modal {
  width: 100%;
  padding: 14px;
  background: var(--bg-dark);
  color: var(--gold-accent);
  border: 1px solid var(--gold-accent);
  border-radius: var(--radius-md);
  font-family: 'Kanit', sans-serif;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-close-modal:active {
  transform: scale(0.98);
  background: #111D19;
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS FOR IPAD & MOBILE
   ========================================================================== */

/* Tablet & iPad Portrait (≤ 1024px) */
@media (max-width: 1024px) {
  .header-nav {
    flex-wrap: nowrap;
  }
  
  .slide-text {
    max-width: 65%;
  }

  .modal-card {
    flex-direction: column;
  }
  
  .modal-img-col, .modal-info-col {
    width: 100%;
  }
  
  .modal-img-col {
    height: 260px;
    min-height: auto;
  }
}

/* Mobile Devices (≤ 640px) */
@media (max-width: 640px) {
  .header-nav {
    padding: 10px 16px;
  }
  
  .brand-title .th { font-size: 1.1rem; }
  .brand-title .en { font-size: 0.65rem; }

  .slide-content-overlay {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .slide-text {
    max-width: 100%;
  }

  .slide-price-tag {
    text-align: left;
  }

  .grid-container {
    grid-template-columns: 1fr;
  }
}
