@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600;700;900&display=swap');

:root {
    --brand-orange: #f97316;
    --grab-green: #00b14f;
    --bg-slate: #f8fafc; /* เปลี่ยนเป็นเทาอุ่น สบายสายตา */
    --text-dark: #1e293b;
}

body {
    font-family: 'Kanit', sans-serif;
    font-weight: 400;
    background-color: var(--bg-slate);
    color: var(--text-dark);
    -webkit-font-smoothing: antialiased;
}

.font-black { font-weight: 700 !important; }
.font-bold { font-weight: 600 !important; }
.font-semibold { font-weight: 500 !important; }

/* คลาสช่วยสำหรับการโฟกัสสายตา */
.active-tab { 
    background-color: var(--brand-orange) !important; 
    color: white !important; 
    font-weight: 600 !important;
    box-shadow: 0 10px 15px -3px rgba(249, 115, 22, 0.3); 
}

.category-tab {
    touch-action: pan-x;
    -ms-overflow-style: none;
    scrollbar-width: none;
    cursor: grab;
}
.category-tab::-webkit-scrollbar { display: none; }

/* ปรับปรุง Drawer UX สไลด์นุ่มนวลขึ้น */
.drawer-container {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: white; border-radius: 32px 32px 0 0; /* มนขึ้นเพื่อความพรีเมียม */
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1); z-index: 50; max-height: 85vh;
    display: flex; flex-direction: column;
    transform: translateY(100%);
}
.drawer-container.active { transform: translateY(0); }

.drawer-overlay {
    position: fixed; inset: 0; background: rgba(15, 23, 42, 0.6); /* เข้มขึ้นช่วยขับ Drawer ให้เด่น */
    display: none; z-index: 40; backdrop-filter: blur(4px);
}
.drawer-overlay.active { display: block; }

.scrollable-content { overflow-y: auto; padding: 24px; flex-grow: 1; }
.fixed-footer { padding: 24px; border-top: 1px solid #e2e8f0; background: white; }

/* Confirmation Modals (Always render above any active Drawer) */
#billConfirmOverlay,
#callStaffConfirmOverlay {
    z-index: 70 !important;
    background: rgba(15, 23, 42, 0.75) !important;
}

#billConfirmDrawer,
#callStaffConfirmDrawer {
    z-index: 75 !important;
    box-shadow: 0 -20px 60px rgba(0,0,0,0.3) !important;
}

.feature-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: #f8fafc;
    color: #334155;
    font-weight: 500;
}

.feature-toggle input {
    width: 20px;
    height: 20px;
    accent-color: var(--brand-orange);
}
button.w-full.bg-emerald-600.text-white.py-4\.5.rounded-xl.font-black.text-base.hover\:bg-emerald-700.transition-all.shadow-lg.mb-2 {
    height: 80px;
    border-radius: 100px;
}

/* --- Order Page Layout --- */
.order-main-container {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh; /* Android Chrome dynamic viewport */
    /* pad bottom = floating cart (~80px) + Android nav bar + extra breathing room */
    padding-bottom: calc(140px + env(safe-area-inset-bottom, 16px));
}

.order-header-sticky {
    background-color: white;
    padding: 16px 16px 8px 16px;
    position: sticky;
    top: 0;
    z-index: 30;
    border-bottom: 1px solid #f1f5f9;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05);
    border-radius: 0 0 24px 24px;
}

.search-container {
    position: relative;
    margin-bottom: 12px;
}

.search-input {
    width: 100%;
    background-color: #f1f5f9;
    border: none;
    border-radius: 12px;
    padding: 12px 16px 12px 48px;
    font-weight: 600;
    outline: none;
}

.search-input:focus {
    box-shadow: 0 0 0 2px var(--brand-orange);
}

/* ── Progress Bar & Anti-Double-Click Loading CSS ── */
#foodpos-progress-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  z-index: 100000;
  pointer-events: none;
  background: transparent;
  opacity: 0;
  transition: opacity 0.25s ease-out;
}

#foodpos-progress-container.active {
  opacity: 1;
}

#foodpos-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f97316 0%, #fbbf24 50%, #16a34a 100%);
  box-shadow: 0 0 12px rgba(249, 115, 22, 0.8), 0 0 4px rgba(22, 163, 74, 0.8);
  transition: width 0.2s cubic-bezier(0.1, 0.8, 0.3, 1);
}

#foodpos-progress-badge {
  position: fixed;
  top: 10px;
  right: 14px;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 20px;
  z-index: 100001;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-8px);
  transition: all 0.25s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  gap: 5px;
}

#foodpos-progress-badge.active {
  opacity: 1;
  transform: translateY(0);
}

[data-busy="true"],
button.is-loading {
  pointer-events: none !important;
  opacity: 0.78 !important;
  cursor: not-allowed !important;
}

.btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btnSpin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

@keyframes btnSpin {
  to { transform: rotate(360deg); }
}

/* --- Category Tabs --- */
.category-tabs-container {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 8px 0;
    scroll-behavior: smooth;
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.category-btn {
    white-space: nowrap;
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    transition: all 0.2s;
    background: white;
    color: #475569;
    border: 1px solid #f1f5f9;
}

.category-btn.active-cat {
    background-color: var(--brand-orange);
    color: white;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.2);
    border-color: var(--brand-orange);
}

/* --- 2-Column Menu Card Design --- */
.menu-grid-2col {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
    padding: 0.75rem;
}

.menu-card-2col {
    background: white;
    padding: 0.55rem;
    border-radius: 1.15rem;
    border: 1px solid #f1f5f9;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    position: relative;
    cursor: pointer;
}

.menu-card-2col:active {
    transform: scale(0.97);
}

.menu-card-2col .menu-img-wrapper-2col {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 0.85rem;
    overflow: hidden;
    background: #f8fafc;
    margin-bottom: 0.4rem;
    position: relative;
}

.menu-card-2col .menu-img-wrapper-2col img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* --- Legacy Menu Item Card (Fallback) --- */
.menu-item-card {
    background: white;
    padding: 12px;
    border-radius: 20px;
    border: 1px solid #f1f5f9;
    display: flex;
    gap: 16px;
    align-items: center;
    transition: all 0.2s;
}

.menu-item-card:active {
    transform: scale(0.98);
}

.menu-img-wrapper {
    width: 80px;
    height: 80px;
    border-radius: 14px;
    overflow: hidden;
    flex-shrink: 0;
    background: #f8fafc;
}

/* --- Cart & Buttons --- */
.floating-cart-wrapper {
    position: fixed;
    /* bottom = 24px above the Android system nav bar */
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    left: 16px;
    right: 16px;
    z-index: 40;
}

/* --- Order Page Specific Styles --- */
.order-main-container {
    max-width: 28rem;
    margin-left: auto;
    margin-right: auto;
    min-height: 100vh;
    min-height: 100dvh;
    padding-bottom: calc(7rem + env(safe-area-inset-bottom, 16px));
}

.order-header-sticky {
    background-color: white;
    padding: 1rem 1rem 0.5rem 1rem;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom-width: 1px;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    border-bottom-left-radius: 24px;
    border-bottom-right-radius: 24px;
}

.shop-name-label {
    font-size: 0.825rem;
    font-weight: 800;
    color: var(--brand-orange);
    line-height: 1.2;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.table-number-title {
    font-size: 1.5rem;
    font-weight: 900;
    color: #0f172a; /* slate-900 */
    letter-spacing: -0.025em;
}

.floating-cart-wrapper {
    position: fixed;
    bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
    left: 0;
    right: 0;
    padding-left: 1rem;
    padding-right: 1rem;
    z-index: 30;
}

/* Utility classes */
.hidden { display: none; }