:root {
  --bg-dark: #0a0e17;
  --bg-card: #111827;
  --bg-card-hover: #1e293b;
  --border-color: rgba(56, 189, 248, 0.2);
  --border-glow: rgba(6, 182, 212, 0.4);
  --cyan-glow: #00f0ff;
  --pink-glow: #ff007f;
  --purple-glow: #a855f7;
  --gold-glow: #fbbf24;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --danger: #ef4444;
  --success: #10b981;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Prompt', 'Kanit', system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(6, 182, 212, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(236, 72, 153, 0.08) 0%, transparent 40%);
  color: var(--text-main);
  min-height: 100vh;
  padding-bottom: 100px; /* Space for mobile sticky bottom bar */
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
}

/* Glass Card */
.glass-panel {
  background: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  transition: all 0.2s ease;
}

.glass-panel:hover {
  border-color: var(--border-glow);
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 18px;
  margin-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  font-size: 1.8rem;
  filter: drop-shadow(0 0 10px rgba(0, 240, 255, 0.6));
}

.brand-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #00f0ff, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  user-select: none;
  touch-action: manipulation;
}

.btn-cyan {
  background: linear-gradient(135deg, #06b6d4, #0284c7);
  color: #fff;
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.35);
}

.btn-cyan:hover, .btn-cyan:active {
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.6);
  transform: translateY(-1px);
}

.btn-pink {
  background: linear-gradient(135deg, #ec4899, #db2777);
  color: #fff;
  box-shadow: 0 0 15px rgba(236, 72, 153, 0.35);
}

.btn-pink:hover, .btn-pink:active {
  box-shadow: 0 0 20px rgba(236, 72, 153, 0.6);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-outline:hover, .btn-outline:active {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--cyan-glow);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.btn-danger:hover, .btn-danger:active {
  background: #ef4444;
  color: white;
}

/* VIP Toggle */
.vip-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.88rem;
  border: 2px solid #475569;
  background: #1e293b;
  color: #94a3b8;
  transition: all 0.25s ease;
  user-select: none;
}

.vip-toggle-btn.active {
  border-color: #fbbf24;
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.25), rgba(217, 119, 6, 0.35));
  color: #fef08a;
  box-shadow: 0 0 15px rgba(251, 191, 36, 0.4);
}

/* Settings Bar */
.settings-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  padding: 14px 18px;
  margin-bottom: 16px;
}

.setting-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.setting-item label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.setting-input {
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--cyan-glow);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

.setting-input:focus {
  border-color: var(--cyan-glow);
}

/* Collapsible Settings Wrapper for Mobile */
.settings-toggle-btn {
  display: none;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: #111827;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--cyan-glow);
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 12px;
  cursor: pointer;
}

/* Promotions Bar */
.promo-banner {
  padding: 12px 16px;
  margin-bottom: 16px;
  border-left: 4px solid var(--pink-glow);
}

.promo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.promo-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-btn {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  background: #1e293b;
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
  user-select: none;
}

.chip-btn:hover {
  border-color: var(--pink-glow);
  color: var(--text-main);
}

.chip-btn.active {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.25), rgba(168, 85, 247, 0.25));
  border-color: var(--pink-glow);
  color: #fbcfe8;
  box-shadow: 0 0 10px rgba(236, 72, 153, 0.3);
}

/* Main Grid Layout */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 16px;
}

/* Order Section */
.orders-card {
  padding: 16px;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.action-row .btn {
  padding: 10px 8px;
  font-size: 0.88rem;
  text-align: center;
  justify-content: center;
}

/* Table */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

th {
  background: #0f172a;
  padding: 10px 12px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.tag-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
}

.tag-start {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.tag-extend {
  background: rgba(6, 182, 212, 0.2);
  color: #38bdf8;
  border: 1px solid rgba(6, 182, 212, 0.4);
}

.tag-item {
  background: rgba(168, 85, 247, 0.2);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.4);
}

/* Bill Summary Box */
.bill-card {
  padding: 18px;
  height: fit-content;
  position: sticky;
  top: 16px;
}

.bill-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.bill-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.bill-row.highlight {
  color: var(--text-main);
  font-weight: 600;
}

.bill-row.discount {
  color: #f472b6;
}

.bill-total-box {
  margin-top: 14px;
  padding: 14px;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.15), rgba(236, 72, 153, 0.15));
  border: 1px solid rgba(6, 182, 212, 0.4);
  border-radius: 12px;
  text-align: center;
}

.bill-total-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--cyan-glow);
}

.bill-total-amount {
  font-size: 2.1rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 15px rgba(0, 240, 255, 0.6);
  margin: 4px 0;
}

.time-countdown {
  margin-top: 10px;
  padding: 8px 12px;
  background: #0f172a;
  border-radius: 8px;
  font-size: 0.82rem;
  text-align: center;
  color: #38bdf8;
  font-weight: 600;
}

/* Mobile Sticky Bottom Floating Bar */
.mobile-sticky-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(10, 14, 23, 0.94);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-glow);
  padding: 10px 14px;
  z-index: 900;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: space-between;
}

.mobile-sticky-info {
  display: flex;
  flex-direction: column;
}

.mobile-sticky-total {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--cyan-glow);
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
  line-height: 1.1;
}

.mobile-sticky-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.mobile-sticky-actions {
  display: flex;
  gap: 8px;
}

/* Target & Price Matrix Card */
.matrix-card {
  margin-top: 20px;
  padding: 16px;
}

.matrix-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 12px;
}

.calc-box {
  background: #0f172a;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.calc-box-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--cyan-glow);
  margin-bottom: 8px;
}

/* Modals */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  z-index: 999;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background: #111827;
  border: 1px solid var(--border-glow);
  border-radius: 16px;
  width: 100%;
  max-width: 650px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.7);
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Menu Grid Selector */
.menu-search-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  background: #0f172a;
  border: 1px solid var(--border-color);
  color: #fff;
  font-size: 0.92rem;
  margin-bottom: 10px;
  outline: none;
}

.menu-category-pills {
  display: flex;
  overflow-x: auto;
  gap: 6px;
  padding-bottom: 8px;
  margin-bottom: 10px;
  -webkit-overflow-scrolling: touch;
}

.menu-items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.menu-card {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.menu-card:hover, .menu-card:active {
  border-color: var(--cyan-glow);
  background: #334155;
  transform: translateY(-2px);
}

.menu-card-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: #f1f5f9;
  margin-bottom: 4px;
  line-height: 1.25;
}

.menu-card-price {
  font-weight: 700;
  color: var(--cyan-glow);
  font-size: 0.95rem;
}

/* Numpad for Drunk/Quick Input */
.numpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.numpad-btn {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 1.2rem;
  font-weight: 700;
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
  touch-action: manipulation;
}

.numpad-btn:hover, .numpad-btn:active {
  background: #334155;
}

.mobile-only {
  display: none !important;
}

.desktop-only {
  display: revert;
}

/* =========================================================
   MOBILE RESPONSIVE OVERHAUL (max-width: 768px)
   ========================================================= */
@media (max-width: 768px) {
  .desktop-only {
    display: none !important;
  }

  .mobile-only {
    display: flex !important;
  }

  body {
    padding-bottom: 90px;
  }

  .container {
    padding: 10px 8px;
  }

  .app-header {
    padding: 12px 14px;
    margin-bottom: 12px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .brand {
    justify-content: center;
  }

  .header-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    width: 100%;
  }

  .header-actions .vip-toggle-btn {
    grid-column: span 2;
    justify-content: center;
  }

  .header-actions .btn {
    font-size: 0.82rem;
    padding: 8px 6px;
    justify-content: center;
  }

  /* Settings Bar on Mobile */
  .settings-toggle-btn {
    display: flex;
  }

  .settings-bar {
    display: none; /* Collapsed by default on mobile to save space */
    grid-template-columns: 1fr 1fr;
    padding: 12px 14px;
    gap: 10px;
  }

  .settings-bar.show {
    display: grid;
  }

  .settings-bar .setting-item:first-child {
    grid-column: span 2;
  }

  /* Action Buttons Grid on Mobile */
  .action-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .action-row .btn {
    width: 100%;
    padding: 12px;
    font-size: 0.95rem;
  }

  /* Main Grid Stack */
  .main-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .orders-card {
    padding: 12px;
  }

  /* Transform Wide Table into Responsive Mobile Order Cards */
  #ordersTable thead {
    display: none; /* Hide header row on mobile */
  }

  #ordersTable, #ordersTable tbody, #ordersTable tr, #ordersTable td {
    display: block;
    width: 100%;
  }

  #ordersTableBody tr {
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  #ordersTableBody td {
    padding: 2px 0;
    border: none;
  }

  /* Custom card styling inside table rows */
  .mobile-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 6px;
  }

  .mobile-card-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #f1f5f9;
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .mobile-card-price {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--cyan-glow);
  }

  .mobile-card-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 4px;
    font-size: 0.85rem;
  }

  .mobile-card-meta {
    color: var(--text-muted);
    font-size: 0.78rem;
  }

  /* Sticky Bottom Bar on Mobile */
  .mobile-sticky-bar {
    display: flex;
  }

  /* Matrix Grid Stack on Mobile */
  .matrix-grid {
    grid-template-columns: 1fr;
  }

  /* Modal on Mobile */
  .modal-box {
    max-height: 94vh;
    border-radius: 14px;
  }

  .modal-body {
    padding: 12px;
  }

  .menu-items-grid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .menu-card {
    padding: 8px;
  }

  .menu-card-name {
    font-size: 0.8rem;
  }
}
