:root {
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #e0f2fe;
  --accent: #f59e0b;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --dark: #0f172a;
  --slate: #334155;
  --muted: #64748b;
  --border: #e2e8f0;
  --card-bg: #ffffff;
  --bg: #f8fafc;
  --radius: 14px;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.07);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg);
  color: var(--dark);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
}

/* Mobile Container for Customer */
.customer-container {
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: #ffffff;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
  position: relative;
  padding-bottom: calc(90px + var(--safe-bottom));
}

/* Header */
.resto-header {
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 40;
  border-bottom: 1px solid var(--border);
  padding: max(14px, var(--safe-top)) 16px 14px;
}

.table-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-light);
  color: var(--primary);
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.resto-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--dark);
}

.resto-sub {
  font-size: 0.8rem;
  color: var(--muted);
}

/* Categories Bar */
.category-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-padding: 0 16px;
  padding: 12px 16px;
  scrollbar-width: none;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

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

.category-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  background: #f1f5f9;
  border: 1px solid transparent;
  color: var(--slate);
  padding: 10px 16px;
  min-height: 40px;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.2s ease;
  user-select: none;
}

.category-btn.active {
  background: var(--dark);
  color: #fff;
}

/* Menu List */
.menu-section {
  padding: 16px;
}

.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.menu-card {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
  position: relative;
  transition: transform 0.15s ease;
}

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

.menu-img {
  width: 90px;
  height: 90px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
  background: #f1f5f9;
}

.menu-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.menu-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 4px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.menu-desc {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.menu-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.menu-price {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--primary);
}

.add-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 8px 16px;
  min-height: 38px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}

.add-btn:active {
  transform: scale(0.96);
}

.sold-out-badge {
  background: #fee2e2;
  color: #ef4444;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 800;
}

/* Floating Bottom Cart Bar */
.cart-floating-bar {
  position: fixed;
  bottom: max(16px, calc(var(--safe-bottom) + 12px));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 24px);
  max-width: 508px;
  background: var(--dark);
  color: #fff;
  border-radius: 16px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
  z-index: 50;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

.cart-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cart-qty-badge {
  background: var(--primary);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.95rem;
}

.cart-price-info {
  display: flex;
  flex-direction: column;
}

.cart-price-label {
  font-size: 0.72rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cart-total-price {
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
}

.cart-bar-btn {
  background: #fff;
  color: var(--dark);
  border: none;
  font-weight: 800;
  padding: 10px 18px;
  min-height: 42px;
  border-radius: 10px;
  font-size: 0.88rem;
  cursor: pointer;
  touch-action: manipulation;
}

/* Modal and Drawers */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.drawer-backdrop.active {
  display: block;
  opacity: 1;
}

.drawer-content {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translate(-50%, 100%);
  width: 100%;
  max-width: 540px;
  max-height: min(88dvh, calc(100% - 30px));
  background: #ffffff;
  border-radius: 24px 24px 0 0;
  z-index: 101;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  overscroll-behavior: contain;
  padding-bottom: max(14px, var(--safe-bottom));
}

.drawer-content.active {
  transform: translate(-50%, 0);
}

.drawer-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.drawer-title {
  font-size: 1.1rem;
  font-weight: 800;
}

.drawer-close {
  background: #f1f5f9;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  touch-action: manipulation;
  font-size: 1.1rem;
  color: var(--slate);
  display: flex;
  align-items: center;
  justify-content: center;
}

.drawer-body {
  padding: 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

.drawer-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: #fff;
  flex-shrink: 0;
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--slate);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 16px; /* Prevents auto-zoom on mobile */
  outline: none;
  transition: border-color 0.2s;
  background: #fff;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 14px;
  min-height: 48px;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
  transition: all 0.2s;
}

.btn-primary:active {
  transform: scale(0.98);
}

.drawer-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.drawer-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: #fff;
}

/* Inputs & Form Elements */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--slate);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: var(--primary);
}

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 14px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

/* Payment Selector Cards */
.payment-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.payment-card {
  border: 2px solid var(--border);
  padding: 14px 12px;
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.payment-card.active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.payment-card .p-icon {
  font-size: 1.6rem;
  margin-bottom: 4px;
}

.payment-card .p-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--dark);
}

.payment-card .p-sub {
  font-size: 0.72rem;
  color: var(--muted);
}

/* Live Order Tracker Modal */
.order-status-card {
  text-align: center;
  padding: 20px;
}

.status-steps {
  display: flex;
  justify-content: space-between;
  position: relative;
  margin: 30px 10px 20px;
}

.status-steps::before {
  content: "";
  position: absolute;
  top: 18px;
  left: 20px;
  right: 20px;
  height: 3px;
  background: var(--border);
  z-index: 1;
}

.step-item {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 60px;
}

.step-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f1f5f9;
  border: 3px solid #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  margin-bottom: 8px;
  transition: all 0.3s ease;
}

.step-item.active .step-dot {
  background: var(--primary);
  border-color: var(--primary-light);
  color: #fff;
  transform: scale(1.1);
}

.step-item.completed .step-dot {
  background: var(--success);
  border-color: var(--success-light);
  color: #fff;
}

.step-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}

.step-item.active .step-label {
  color: var(--dark);
}

/* POS Dashboard Layout */
.pos-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.pos-navbar {
  background: var(--dark);
  color: #fff;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pos-nav-title {
  font-size: 1.2rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
}

.pos-links {
  display: flex;
  gap: 12px;
}

.pos-link {
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.88rem;
  padding: 6px 14px;
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.2s;
}

.pos-link:hover, .pos-link.active {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.pos-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.order-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.pos-order-card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.pos-order-header {
  padding: 14px 16px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pos-table-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--dark);
}

.badge {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-paid {
  background: var(--success-light);
  color: var(--success);
}

.badge-pending {
  background: var(--warning-light);
  color: #b45309;
}

.pos-order-body {
  padding: 16px;
  flex: 1;
}

.pos-item-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px dashed #f1f5f9;
}

.pos-item-name {
  font-weight: 600;
  color: var(--dark);
}

.pos-item-notes {
  font-size: 0.78rem;
  color: #d97706;
  font-style: italic;
  margin-top: 2px;
}

.pos-order-footer {
  padding: 14px 16px;
  background: #fff;
  border-top: 1px solid var(--border);
}

.action-btn-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.btn-action {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.btn-cooking {
  background: #fef3c7;
  color: #b45309;
  border-color: #fde68a;
}

.btn-ready {
  background: #e0f2fe;
  color: #0369a1;
  border-color: #bae6fd;
}

.btn-complete {
  background: #d1fae5;
  color: #047857;
  border-color: #a7f3d0;
}

.btn-print {
  background: #f1f5f9;
  color: #334155;
  border-color: #cbd5e1;
}

/* Mobile & Tablet Responsive Media Queries */
@media (max-width: 768px) {
  .pos-navbar {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 16px;
    gap: 10px;
  }

  .pos-nav-title {
    font-size: 1.05rem;
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .pos-links {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    scrollbar-width: none;
  }

  .pos-links::-webkit-scrollbar {
    display: none;
  }

  .pos-link {
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 0.82rem;
  }

  .pos-content {
    padding: 14px;
  }

  .order-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .customer-container {
    padding-bottom: calc(96px + var(--safe-bottom));
  }
}

/* Struk Thermal Print Styling */
@media print {
  body * {
    visibility: hidden;
  }
  #thermal-receipt-area, #thermal-receipt-area * {
    visibility: visible;
  }
  #thermal-receipt-area {
    position: absolute;
    left: 0;
    top: 0;
    width: 58mm; /* Standard thermal receipt */
    font-family: monospace;
    font-size: 11px;
    line-height: 1.3;
    color: #000;
  }
}
