@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@300;400;500;600;700;800&display=swap');

:root {
  --primary: #FF6B35;
  --primary-dark: #E55A2B;
  --primary-light: #FF8C5A;
  --accent: #FFB347;
  --bg-warm: #FFF8F0;
  --bg-dark: #1A1A2E;
  --bg-card-dark: #16213E;
  --surface-dark: #0F3460;
  --text-dark: #2D3436;
  --text-secondary: #636E72;
  --text-light: #FFFFFF;
  --text-muted: #A0AEC0;
  --success: #48BB78;
  --danger: #FC8181;
  --warning: #F6E05E;
  --border: #E2E8F0;
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Be Vietnam Pro', sans-serif;
  background: var(--bg-warm);
  color: var(--text-dark);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ============ UTILITIES ============ */
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.text-center { text-align: center; }
.w-full { width: 100%; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 24px; border-radius: var(--radius-sm); font-weight: 600;
  font-size: 14px; border: none; cursor: pointer; transition: var(--transition);
  font-family: inherit; text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 15px rgba(255,107,53,0.4); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #38A169; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #E53E3E; }
.btn-outline { background: transparent; border: 2px solid var(--border); color: var(--text-dark); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn:disabled:hover { border-color: var(--border); color: inherit; transform: none; box-shadow: none; }

.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
  font-size: 12px; font-weight: 700; background: var(--primary); color: #fff;
}

/* ============ CUSTOMER PAGE ============ */
.customer-page { background: var(--bg-warm); min-height: 100vh; padding-bottom: 100px; }

.customer-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; padding: 20px 16px; text-align: center;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 4px 20px rgba(255,107,53,0.3);
}
.customer-header h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.customer-header .table-badge {
  display: inline-block; background: rgba(255,255,255,0.2); backdrop-filter: blur(10px);
  padding: 4px 16px; border-radius: 20px; font-size: 14px; margin-top: 6px; font-weight: 500;
}

/* Tabs */
.menu-tabs {
  display: flex; gap: 8px; padding: 16px; overflow-x: auto;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.menu-tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  flex-shrink: 0; padding: 10px 20px; border-radius: 25px;
  border: 2px solid var(--border); background: #fff; color: var(--text-secondary);
  font-weight: 600; font-size: 14px; cursor: pointer; transition: var(--transition);
  font-family: inherit; white-space: nowrap;
}
.tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Menu Grid */
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 0 16px; }
@media (min-width: 768px) { .menu-grid { grid-template-columns: repeat(3, 1fr); } }

.menu-item {
  background: #fff; border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); transition: var(--transition); position: relative;
}
.menu-item:active { transform: scale(0.97); }
.menu-item-img {
  width: 100%; height: 120px; object-fit: cover; background: #f0e6d9;
  display: flex; align-items: center; justify-content: center;
  font-size: 40px; color: var(--primary-light);
}
.menu-item-img img { width: 100%; height: 100%; object-fit: cover; }
.menu-item-info { padding: 12px; }
.menu-item-name { font-weight: 600; font-size: 14px; line-height: 1.3; margin-bottom: 4px; }
.menu-item-price { color: var(--primary); font-weight: 700; font-size: 15px; }
.menu-item-popular {
  position: absolute; top: 8px; left: 8px; background: var(--danger);
  color: #fff; font-size: 10px; font-weight: 700; padding: 3px 8px;
  border-radius: 10px; text-transform: uppercase;
}
.menu-item-controls {
  display: flex; align-items: center; justify-content: space-between; padding: 0 12px 12px;
}
.qty-control { display: flex; align-items: center; gap: 12px; }
.qty-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--primary);
  background: transparent; color: var(--primary); font-size: 18px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: var(--transition); font-family: inherit;
}
.qty-btn:hover { background: var(--primary); color: #fff; }
.qty-btn.minus { border-color: var(--danger); color: var(--danger); }
.qty-btn.minus:hover { background: var(--danger); color: #fff; }
.qty-value { font-weight: 700; font-size: 16px; min-width: 20px; text-align: center; }

/* Floating Cart */
.floating-cart {
  position: fixed; bottom: 20px; left: 16px; right: 16px; z-index: 200;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; border-radius: var(--radius); padding: 16px 20px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 8px 30px rgba(255,107,53,0.4); cursor: pointer;
  transition: var(--transition); max-width: 500px; margin: 0 auto;
}
.floating-cart:hover { transform: translateY(-2px); box-shadow: 0 12px 40px rgba(255,107,53,0.5); }
.cart-info { display: flex; align-items: center; gap: 12px; }
.cart-count { background: rgba(255,255,255,0.25); width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px; }
.cart-total { font-size: 18px; font-weight: 800; }

/* Cart Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 300;
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; visibility: hidden; transition: var(--transition);
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal-content {
  background: #fff; border-radius: var(--radius) var(--radius) 0 0; width: 100%;
  max-width: 500px; max-height: 80vh; overflow-y: auto; padding: 24px;
  transform: translateY(100%); transition: var(--transition);
}
.modal-overlay.open .modal-content { transform: translateY(0); }
.modal-overlay.admin-modal { align-items: center; padding: 24px; }
.modal-overlay.admin-modal .modal-content {
  border-radius: var(--radius); transform: translateY(24px) scale(0.98);
}
.modal-overlay.admin-modal.open .modal-content { transform: translateY(0) scale(1); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h2 { font-size: 20px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 28px; cursor: pointer; color: var(--text-secondary); }
.cart-item { display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--border); }
.cart-item-name { font-weight: 500; }
.cart-item-detail { color: var(--text-secondary); font-size: 13px; }
.cart-item-price { font-weight: 700; color: var(--primary); white-space: nowrap; }
.cart-total-section { padding: 16px 0; border-top: 2px solid var(--text-dark); margin-top: 8px;
  display: flex; justify-content: space-between; font-size: 18px; font-weight: 800; }
.cart-total-section span:last-child { color: var(--primary); }

/* Order History */
.order-history { padding: 16px; margin-top: 8px; }
.order-history h3 { font-size: 16px; font-weight: 700; margin-bottom: 12px; color: var(--text-secondary); }
.order-history-item {
  background: #fff; border-radius: var(--radius-sm); padding: 12px; margin-bottom: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05); border-left: 4px solid var(--success);
}
.order-history-item.pending { border-left-color: var(--warning); }
.order-history-item.preparing { border-left-color: var(--primary); }
.order-time { font-size: 12px; color: var(--text-secondary); }
.order-status-badge {
  display: inline-block; padding: 2px 10px; border-radius: 12px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
}
.order-status-badge.pending { background: #FEFCBF; color: #975A16; }
.order-status-badge.preparing { background: #FFF5EB; color: var(--primary-dark); }
.order-status-badge.completed { background: #E6FFFA; color: #276749; }

/* ============ KITCHEN PAGE ============ */
.kitchen-page { background: var(--bg-dark); min-height: 100vh; color: var(--text-light); }

.kitchen-header {
  background: var(--bg-card-dark); padding: 16px 24px;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.kitchen-header h1 { font-size: 22px; font-weight: 800; }
.kitchen-header h1 span { color: var(--primary); }
.kitchen-stats { display: flex; gap: 16px; }
.kitchen-stat { text-align: center; }
.kitchen-stat .num { font-size: 28px; font-weight: 800; color: var(--primary); }
.kitchen-stat .label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; }

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

.kitchen-order-card {
  background: var(--bg-card-dark); border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.08); overflow: hidden;
  animation: slideIn 0.4s ease;
}
@keyframes slideIn { from { opacity:0; transform:translateY(20px); } to { opacity:1; transform:translateY(0); } }
.kitchen-order-header {
  background: var(--surface-dark); padding: 14px 18px;
  display: flex; justify-content: space-between; align-items: center;
}
.kitchen-table-num { font-size: 20px; font-weight: 800; color: var(--accent); }
.kitchen-order-time { font-size: 12px; color: var(--text-muted); }
.kitchen-order-items { padding: 14px 18px; }
.kitchen-order-item {
  display: flex; justify-content: space-between; padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.kitchen-order-item:last-child { border: none; }
.kitchen-item-name { font-weight: 500; }
.kitchen-item-qty { color: var(--accent); font-weight: 700; }
.kitchen-order-footer { padding: 14px 18px; }
.kitchen-order-footer .btn { width: 100%; }

.kitchen-empty {
  text-align: center; padding: 80px 20px; color: var(--text-muted);
}
.kitchen-empty .icon { font-size: 64px; margin-bottom: 16px; }

/* New order notification pulse */
.kitchen-order-card.new { border: 2px solid var(--primary); }
.kitchen-order-card.new .kitchen-order-header { background: var(--primary); }
.kitchen-order-card.new .kitchen-order-time { color: rgba(255,255,255,0.85); font-weight: 600; }
.kitchen-order-card.new .kitchen-table-num { color: #fff; }

/* ============ ADMIN PAGE ============ */
.admin-page { background: #F5F6FA; min-height: 100vh; }

.admin-header {
  background: #fff; padding: 16px 24px; box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  display: flex; justify-content: space-between; align-items: center;
}
.admin-header h1 { font-size: 22px; font-weight: 800; }
.admin-header h1 span { color: var(--primary); }

.admin-tabs {
  display: flex; background: #fff; border-bottom: 2px solid var(--border);
  padding: 0 24px; overflow-x: auto;
}
.admin-tab {
  padding: 14px 24px; font-weight: 600; font-size: 14px; color: var(--text-secondary);
  cursor: pointer; border-bottom: 3px solid transparent; transition: var(--transition);
  white-space: nowrap; background: none; border-top: none; border-left: none; border-right: none;
  font-family: inherit;
}
.admin-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.admin-tab:hover { color: var(--primary); }

.admin-content { padding: 24px; }
.admin-card { background: #fff; border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow); margin-bottom: 20px; }
.admin-card h3 { font-size: 18px; font-weight: 700; margin-bottom: 16px; }

/* Table Grid */
.table-grid-header { display: flex; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.table-grid-stat {
  padding: 12px 20px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px;
}
.table-grid-stat.occupied { background: #FFF5EB; color: var(--primary-dark); }
.table-grid-stat.empty { background: #E6FFFA; color: #276749; }

.table-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}
.table-cell {
  aspect-ratio: 1; border-radius: var(--radius); display: flex; flex-direction: column;
  align-items: center; justify-content: center; cursor: pointer; transition: var(--transition);
  border: 2px solid var(--border); background: #fff; position: relative;
}
.table-cell:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.table-cell.active { background: linear-gradient(135deg, #FFF5EB, #FFEDD5);
  border-color: var(--primary); }
.table-cell .table-num { font-size: 28px; font-weight: 800; color: var(--text-dark); }
.table-cell.active .table-num { color: var(--primary); }
.table-cell .table-total {
  font-size: 12px; font-weight: 600; color: var(--primary); margin-top: 4px;
}
.table-cell .table-label {
  font-size: 10px; color: var(--text-secondary); text-transform: uppercase; font-weight: 600;
}
.table-cell.active .table-label { color: var(--primary-dark); }

/* Admin Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--text-secondary); }
.form-control {
  width: 100%; padding: 10px 14px; border: 2px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; transition: var(--transition); background: #fff;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(255,107,53,0.15); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%23636E72' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }

/* Menu List in Admin */
.menu-list-item {
  display: flex; align-items: center; gap: 14px; padding: 12px;
  border-radius: var(--radius-sm); border: 1px solid var(--border); margin-bottom: 8px;
  transition: var(--transition);
}
.menu-list-item:hover { background: #FAFAFA; }
.menu-list-item.draggable { cursor: grab; }
.menu-list-item.dragging { opacity: 0.55; border-color: var(--primary); background: #FFF5EB; }
.menu-drag-handle {
  width: 28px; height: 44px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); font-weight: 800; flex-shrink: 0;
}
.admin-menu-tabs { padding: 0 0 16px; }
.menu-list-thumb {
  width: 50px; height: 50px; border-radius: 10px; background: #f0e6d9;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  font-size: 22px; overflow: hidden;
}
.menu-list-thumb img { width: 100%; height: 100%; object-fit: cover; }
.menu-list-info { flex: 1; }
.menu-list-name { font-weight: 600; font-size: 14px; }
.menu-list-cat { font-size: 12px; color: var(--text-secondary); }
.menu-list-price { font-weight: 700; color: var(--primary); white-space: nowrap; }
.menu-list-actions { display: flex; gap: 6px; }

/* Reports */
.report-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.report-card {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; padding: 20px; border-radius: var(--radius); text-align: center;
}
.report-card.alt { background: linear-gradient(135deg, var(--success), #38A169); }
.report-card .num { font-size: 32px; font-weight: 800; }
.report-card .label { font-size: 13px; opacity: 0.85; margin-top: 4px; }
.top-items-list { list-style: none; }
.top-items-list li { display: flex; justify-content: space-between; padding: 10px 0;
  border-bottom: 1px solid var(--border); }
.top-items-list li:last-child { border: none; }

/* Bill Modal */
.bill-content { font-family: monospace; max-width: 350px; margin: 0 auto; padding: 20px;
  background: #fff; border: 1px dashed #ccc; }
.bill-content h2 { text-align: center; font-family: 'Be Vietnam Pro', sans-serif; }
.bill-line { display: flex; justify-content: space-between; padding: 4px 0; }
.bill-divider { border-top: 1px dashed #ccc; margin: 8px 0; }
.bill-total { font-weight: 700; font-size: 16px; }

/* ============ LOGIN OVERLAY ============ */
.login-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 500;
  display: flex; align-items: center; justify-content: center;
}
.login-box {
  background: #fff; border-radius: var(--radius); padding: 32px; width: 90%; max-width: 360px;
  text-align: center; box-shadow: var(--shadow-lg);
}
.login-box h2 { margin-bottom: 8px; font-size: 24px; }
.login-box p { color: var(--text-secondary); margin-bottom: 20px; font-size: 14px; }
.login-box input { margin-bottom: 16px; }
.login-error { color: var(--danger); font-size: 13px; margin-bottom: 12px; }

/* Toast notification */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 999; }
.toast {
  background: var(--success); color: #fff; padding: 14px 20px; border-radius: var(--radius-sm);
  margin-bottom: 8px; font-weight: 500; box-shadow: var(--shadow-lg);
  animation: toastIn 0.4s ease, toastOut 0.4s ease 2.6s forwards;
}
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); color: var(--text-dark); }
@keyframes toastIn { from { opacity:0; transform:translateX(100px); } }
@keyframes toastOut { to { opacity:0; transform:translateX(100px); } }

/* ============ PRINT STYLES ============ */
@media print {
  body * { visibility: hidden; }
  .bill-print, .bill-print * { visibility: visible; }
  .bill-print { position: absolute; left: 0; top: 0; width: 80mm; }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 480px) {
  .menu-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .menu-item-img { height: 100px; }
}
