/* =========================================================
   Mesa & Cia — POS Restaurante
   Tema: warm cream + deep slate + amber
   ========================================================= */

:root {
  /* Palette */
  --bg: #f5f2ec;
  --bg-soft: #efeae0;
  --surface: #ffffff;
  --surface-2: #fbf9f4;
  --ink: #14161b;
  --ink-soft: #2b2f38;
  --muted: #71757f;
  --line: #e7e2d6;
  --line-strong: #d8d2c2;

  --primary: #c2410c;       /* terracotta / burnt sienna */
  --primary-hover: #9a3208;
  --primary-soft: #fdebe0;

  --accent: #0f766e;        /* deep teal */
  --accent-soft: #d6f0ec;

  --danger: #b91c1c;
  --danger-soft: #fde2e2;

  --success: #15803d;
  --success-soft: #d8efe1;

  --warning: #b45309;
  --warning-soft: #fbe9c8;

  --shadow-sm: 0 1px 2px rgba(20, 22, 27, 0.04);
  --shadow-md: 0 4px 14px rgba(20, 22, 27, 0.06), 0 1px 3px rgba(20, 22, 27, 0.04);
  --shadow-lg: 0 20px 40px rgba(20, 22, 27, 0.10), 0 4px 12px rgba(20, 22, 27, 0.06);

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;

  --font: 'Plus Jakarta Sans', system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: 'Fraunces', Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }
h1, h2, h3, h4 { margin: 0; }

svg { width: 18px; height: 18px; flex-shrink: 0; }

/* =========================================================
   HEADER
   ========================================================= */
.app-header {
  height: 68px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 280px 1fr auto;
  align-items: center;
  padding: 0 24px;
  gap: 24px;
  position: relative;
  z-index: 5;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px; height: 40px;
  background: var(--ink);
  color: #f5f2ec;
  border-radius: 12px;
  display: grid; place-items: center;
  box-shadow: var(--shadow-md);
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-text h1 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand-text span { font-size: 12px; color: var(--muted); }

.header-nav {
  display: flex;
  gap: 4px;
  background: var(--bg-soft);
  border-radius: 12px;
  padding: 4px;
  width: fit-content;
  margin: 0 auto;
}
.nav-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  transition: 0.18s;
}
.nav-btn:hover { color: var(--ink); }
.nav-btn.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.clock {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.clock span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.clock strong { font-size: 18px; font-weight: 700; color: var(--ink); }

/* =========================================================
   POS LAYOUT
   ========================================================= */
.pos-grid {
  display: grid;
  grid-template-columns: 280px 1fr 380px;
  gap: 16px;
  padding: 16px;
  height: calc(100vh - 68px);
  overflow: hidden;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  gap: 12px;
}
.panel-header h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.panel-sub { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.btn-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: var(--ink);
  color: var(--surface);
  transition: 0.18s;
  box-shadow: var(--shadow-sm);
}
.btn-icon:hover { background: var(--primary); transform: translateY(-1px); }

/* =========================================================
   TABLES PANEL
   ========================================================= */
.table-filter {
  display: flex; gap: 6px;
  padding: 0 20px 14px;
}
.chip {
  flex: 1;
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg-soft);
  transition: 0.18s;
}
.chip:hover { color: var(--ink); }
.chip.active {
  background: var(--ink);
  color: var(--surface);
}

.tables-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 0 16px 16px;
  overflow-y: auto;
  flex: 1;
}

.table-card {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: 0.2s cubic-bezier(.2,.8,.2,1);
  overflow: hidden;
}
.table-card:hover {
  transform: translateY(-2px);
  border-color: var(--ink);
  box-shadow: var(--shadow-md);
}
.table-card .num {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.table-card .label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--muted);
}
.table-card .total {
  position: absolute;
  bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
  background: var(--surface);
  padding: 2px 8px;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}
.table-card.busy {
  background: var(--primary-soft);
  border-color: #f4ccaa;
}
.table-card.busy .num { color: var(--primary); }
.table-card.busy .label { color: var(--primary); }
.table-card.busy::after {
  content: "";
  position: absolute;
  top: 10px; right: 10px;
  width: 8px; height: 8px;
  background: var(--primary);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(194, 65, 12, 0.18);
  animation: pulse 1.6s infinite;
}
.table-card.active {
  border-color: var(--ink);
  background: var(--ink);
}
.table-card.active .num,
.table-card.active .label { color: var(--surface); }

.table-card .delete-btn {
  position: absolute;
  top: 6px; left: 6px;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(20,22,27,0.7);
  color: var(--surface);
}
.table-card:hover .delete-btn { display: flex; }
.table-card .delete-btn:hover { background: var(--danger); }
.table-card .delete-btn svg { width: 12px; height: 12px; }

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 24px 12px;
  color: var(--muted);
  font-size: 13px;
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(194, 65, 12, 0.45); }
  100% { box-shadow: 0 0 0 10px rgba(194, 65, 12, 0); }
}

/* =========================================================
   MENU PANEL
   ========================================================= */
.menu-header { gap: 16px; flex-wrap: wrap; }
.search-wrap {
  position: relative;
  min-width: 240px;
  flex: 1;
  max-width: 320px;
}
.search-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%; transform: translateY(-50%);
  color: var(--muted);
  width: 16px; height: 16px;
}
.search-wrap input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 10px 14px 10px 36px;
  border-radius: 12px;
  font-size: 13px;
  color: var(--ink);
  transition: 0.18s;
}
.search-wrap input:focus {
  outline: none;
  border-color: var(--ink);
  background: var(--surface);
}

.categories-row {
  display: flex;
  gap: 8px;
  padding: 0 20px 16px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.categories-row::-webkit-scrollbar { height: 4px; }
.categories-row::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

.cat-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
  transition: 0.18s;
}
.cat-chip:hover {
  border-color: var(--ink);
  color: var(--ink);
}
.cat-chip.active {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}
.cat-chip .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--primary);
}
.cat-chip.active .dot { background: var(--primary-soft); }

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  padding: 4px 20px 20px;
  overflow-y: auto;
  flex: 1;
  align-content: start;
}

.product-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex; flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: 0.18s cubic-bezier(.2,.8,.2,1);
  position: relative;
  min-height: 120px;
}
.product-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--ink);
}
.product-card:active { transform: translateY(0); }
.product-card .cat-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.product-card .name {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
  flex: 1;
}
.product-card .price {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--primary);
}

.product-card.disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

/* =========================================================
   ORDER PANEL
   ========================================================= */
.order-panel {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
}
.order-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--line);
}
.order-eyebrow {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.order-head h2 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  margin-top: 4px;
  letter-spacing: -0.02em;
}
.order-status {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--bg-soft);
  color: var(--muted);
}
.order-status.busy {
  background: var(--primary-soft);
  color: var(--primary);
}

.order-items {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex; flex-direction: column;
  gap: 8px;
}
.order-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  animation: slideIn 0.22s cubic-bezier(.2,.8,.2,1);
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: translateX(0); }
}
.order-item .info { min-width: 0; }
.order-item .info .n {
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.order-item .info .p {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.qty-wrap {
  display: flex; align-items: center;
  background: var(--bg-soft);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.qty-wrap button {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
  transition: 0.15s;
}
.qty-wrap button:hover { background: var(--primary); color: var(--surface); }
.qty-wrap span {
  min-width: 24px;
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
}

.order-empty {
  margin: auto;
  text-align: center;
  color: var(--muted);
  padding: 32px 16px;
}
.order-empty svg {
  width: 48px; height: 48px;
  margin-bottom: 12px;
  color: var(--line-strong);
}
.order-empty p { margin: 0; font-size: 13px; }

.order-totals {
  border-top: 1px solid var(--line);
  padding: 16px 22px 22px;
  background: var(--surface);
}
.total-row {
  display: flex; justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.total-row.total-grand {
  border-top: 1px dashed var(--line);
  margin-top: 8px;
  padding-top: 12px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
}

.order-actions {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  margin-top: 14px;
}
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--ink);
  color: var(--surface);
  padding: 14px 18px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  transition: 0.18s;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--primary); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:disabled {
  opacity: 0.5; cursor: not-allowed; transform: none;
}
.btn-primary.small { padding: 10px 14px; font-size: 13px; }

.btn-ghost {
  background: var(--bg-soft);
  color: var(--ink-soft);
  padding: 14px 16px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 13px;
  transition: 0.18s;
}
.btn-ghost:hover { background: var(--line); }

/* =========================================================
   ADMIN VIEW
   ========================================================= */
.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 16px;
  padding: 16px;
  height: calc(100vh - 68px);
  overflow: hidden;
}
.admin-panel { padding-bottom: 4px; }
.admin-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px 20px;
  display: flex; flex-direction: column;
  gap: 8px;
}
.admin-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: 0.15s;
}
.admin-row:hover { border-color: var(--line-strong); background: var(--surface); }
.admin-row .info { min-width: 0; flex: 1; }
.admin-row .info .title {
  font-weight: 600; font-size: 14px;
  color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.admin-row .info .sub {
  font-size: 12px; color: var(--muted); margin-top: 2px;
}
.admin-row .price-tag {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  margin-right: 8px;
}
.row-actions { display: flex; gap: 6px; }
.row-actions button {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  transition: 0.15s;
}
.row-actions button:hover {
  border-color: var(--ink);
  color: var(--ink);
}
.row-actions .delete:hover {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger);
}

/* =========================================================
   MODAL
   ========================================================= */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20, 22, 27, 0.5);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 0.18s;
}
.modal-backdrop.hidden { display: none; }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalUp 0.24s cubic-bezier(.2,.8,.2,1);
}
@keyframes modalUp {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}
.modal-header h3 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.modal-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--muted);
  transition: 0.15s;
}
.modal-close:hover { background: var(--bg-soft); color: var(--ink); }
.modal-body { padding: 22px 24px; }
.modal-body p { margin: 0 0 8px; color: var(--ink-soft); font-size: 14px; line-height: 1.55; }
.modal-body .hint { color: var(--muted); font-size: 12px; }

.field {
  display: flex; flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.field input, .field select {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 14px;
  color: var(--ink);
  transition: 0.15s;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--ink);
  background: var(--surface);
}

.modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 16px 24px 22px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.modal-footer .btn-primary { padding: 10px 18px; font-size: 13px; }
.modal-footer .btn-ghost { padding: 10px 18px; font-size: 13px; }
.modal-footer .btn-danger {
  display: flex; align-items: center; gap: 8px;
  background: var(--danger);
  color: white;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 13px;
  transition: 0.15s;
}
.modal-footer .btn-danger:hover { background: #8d1414; }

/* =========================================================
   TOAST
   ========================================================= */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  display: flex; flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: var(--ink);
  color: var(--surface);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toastIn 0.25s cubic-bezier(.2,.8,.2,1);
  min-width: 240px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warn { background: var(--warning); }
.toast svg { width: 18px; height: 18px; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.toast.leaving {
  animation: toastOut 0.2s forwards;
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(20px); }
}

/* =========================================================
   UTIL
   ========================================================= */
.hidden { display: none !important; }

/* Scrollbars */
*::-webkit-scrollbar { width: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
*::-webkit-scrollbar-thumb:hover { background: var(--line-strong); }

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 1280px) {
  .pos-grid { grid-template-columns: 240px 1fr 340px; }
}
@media (max-width: 1080px) {
  .pos-grid {
    grid-template-columns: 220px 1fr;
    grid-template-rows: 1fr auto;
  }
  .order-panel {
    grid-column: 1 / -1;
    max-height: 320px;
  }
}
@media (max-width: 760px) {
  .app-header { grid-template-columns: 1fr auto; padding: 0 12px; gap: 12px; }
  .header-meta { display: none; }
  .header-nav { order: 3; grid-column: 1 / -1; margin: 0; }
  .app-header { height: auto; padding: 10px 12px; }
  .pos-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
    height: auto;
    overflow: auto;
  }
  .tables-panel, .order-panel { max-height: none; }
  .admin-grid { grid-template-columns: 1fr; height: auto; overflow: auto; }
  body { overflow: auto; }
}
