:root {
  --brand: #d32f2f;
  --brand-dark: #b71c1c;
  --sidebar-w: 230px;
  --topbar-h: 56px;
}

[x-cloak] { display: none !important; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }

/* ---------- layout ---------- */
.app-shell { min-height: 100vh; }
.app-topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  display: flex; align-items: center; gap: 8px; padding: 0 12px; z-index: 50;
}
.app-topbar .brand {
  font-weight: 700; font-size: 1.1rem; cursor: pointer; display: flex; align-items: center; gap: 8px;
  flex: 1;
}
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 4px rgba(255,255,255,.3); }
.topbar-right { display: flex; align-items: center; gap: 6px; }
.status-tag { font-size: .7rem; }
.user-chip { cursor: pointer; padding: 4px 10px; border-radius: 20px; background: rgba(255,255,255,.2); font-size: .85rem; }
.cart-badge {
  position: absolute; top: 2px; right: 0; background: #fff; color: var(--brand);
  border-radius: 50%; font-size: .65rem; font-weight: 700; padding: 0 5px; line-height: 1.4;
}
.burger { font-size: 1.3rem; }

.app-body { padding-top: var(--topbar-h); }
.app-sidebar {
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: var(--sidebar-w);
  background: #fff; border-right: 1px solid #e0e0e0; overflow-y: auto; z-index: 40;
  display: flex; flex-direction: column; transition: transform .25s ease;
}
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 13px 18px; cursor: pointer;
  color: #333; text-decoration: none; border-left: 4px solid transparent; font-size: .95rem;
}
.nav-link:hover { background: #f5f5f5; }
.nav-link.active { background: #fdecea; border-left-color: var(--brand); color: var(--brand); font-weight: 600; }
.nav-ico { width: 20px; display: inline-flex; align-items: center; justify-content: center; }
.nav-ico svg { width: 18px; height: 18px; }
.cart-btn { position: relative; display: inline-flex; align-items: center; }
.sidebar-foot { margin-top: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

.app-main { margin-left: var(--sidebar-w); min-height: calc(100vh - var(--topbar-h)); }

@media (max-width: 900px) {
  .app-sidebar { transform: translateX(-100%); box-shadow: 4px 0 16px rgba(0,0,0,.2); }
  .app-sidebar.open { transform: translateX(0); }
  .app-main { margin-left: 0; }
}

/* ---------- hero / menu ---------- */
.hero { padding: 34px 20px; color: #fff; }
.hero h1 { margin: 0; font-size: 1.9rem; }
.hero p { margin: 6px 0 0; opacity: .9; }
.cat-title { border-left: 5px solid var(--brand); padding-left: 10px; }
.menu-card {
  overflow: hidden; transition: transform .15s, box-shadow .15s; height: 100%;
  display: flex; flex-direction: column;
}
.menu-card:hover { transform: translateY(-3px); box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.menu-body { display: flex; flex-direction: column; flex: 1 1 auto; }
/* Reserve a fixed number of lines so every card computes the same height,
   regardless of how long the actual title or description is. */
.menu-name {
  font-size: 1.05rem; line-height: 1.35; min-height: 2.8em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.menu-desc {
  line-height: 1.4; min-height: 2.9em; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.menu-price { margin-top: auto; }
.menu-thumb {
  height: 130px; background: #ffe0e0 center/cover no-repeat; display: flex;
  align-items: center; justify-content: center; flex: 0 0 auto;
}
.thumb-emoji { opacity: .45; display: inline-flex; }
.thumb-emoji svg { width: 52px; height: 52px; }
.muted { color: #777; }
.small { font-size: .85rem; }

/* ---------- menu live search ---------- */
.menu-search { padding: 12px 6px; margin-bottom: 14px; }
.search-wrap { position: relative; }
.search-ico { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: #999; display: inline-flex; pointer-events: none; }
.search-ico svg { width: 18px; height: 18px; }
.search-input { padding-left: 38px; padding-right: 34px; }
.search-input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.search-clear { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); font-size: 1.2rem; line-height: 1; padding: 2px 8px; color: #888; }
.search-filter { height: 42px; }
.search-hint { margin: 8px 8px 0; }
@media (max-width: 600px) { .search-filter { margin-top: 8px; } }

/* ---------- cart ---------- */
.sticky { position: sticky; top: calc(var(--topbar-h) + 12px); }
.cart-panel { overflow: hidden; }
.cart-line { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px dashed #eee; }
.qty-ctrl { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.qty-ctrl.big button { font-size: 1.1rem; }
.total { border-top: 2px solid #eee; margin-top: 6px; padding-top: 6px; font-size: 1.05rem; }
@media (max-width: 900px) { .sticky { position: static; } }

/* ---------- status steps ---------- */
.status-steps { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
.step { display: flex; align-items: center; gap: 6px; font-size: .85rem; color: #999; }
.step .dot { width: 12px; height: 12px; border-radius: 50%; background: #ddd; }
.step.done { color: #2e7d32; font-weight: 600; }
.step.done .dot { background: #2e7d32; }
.step.cancelled { color: #c62828; }

/* ---------- kanban ---------- */
.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 12px; }
.kanban-col { background: #f0f0f0; border-radius: 8px; padding: 8px; min-height: 200px; }
.kanban-col header { color: #fff; padding: 8px 10px; border-radius: 6px; font-weight: 600; margin-bottom: 8px; }
.kanban-card { border-radius: 8px; padding: 10px; margin-bottom: 8px; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.order-items { margin: 6px 0; padding-left: 18px; font-size: .9rem; }
@media (max-width: 900px) { .kanban { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .kanban { grid-template-columns: 1fr; } }

/* ---------- tables / stats ---------- */
.table-card { border-top: 5px solid #ccc; }
.tbl-free { border-top-color: #43a047; }
.tbl-occupied { border-top-color: #e53935; }
.tbl-reserved { border-top-color: #fb8c00; }
/* ---------- images manager ---------- */
.images-table { border-collapse: collapse; width: 100%; }
.images-table th, .images-table td { border: 1px solid #999; padding: 8px; vertical-align: middle; }
.images-table th { background: #f2f2f2; text-align: left; }
.images-table img { display: block; max-width: 100%; border-radius: 6px; }
.img-url { word-break: break-all; font-size: .85rem; }
.copy-btn { padding: 6px; line-height: 0; }
.copy-btn svg { width: 18px; height: 18px; }

/* ---------- menu manager: drag & drop ordering ---------- */
.drag-handle {
  cursor: grab; color: #9e9e9e; display: inline-flex; align-items: center;
  padding: 2px 6px 2px 0; line-height: 0; flex: 0 0 auto; touch-action: none;
}
.drag-handle:active { cursor: grabbing; }
.drag-handle svg { width: 16px; height: 16px; }
.drag-handle-static { color: #9e9e9e; display: inline-flex; vertical-align: middle; }
.drag-handle-static svg { width: 14px; height: 14px; }
.cat-head { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid #e0e0e0; }
.cat-head .cat-name { flex: 1 1 auto; }
.cat-head .cat-actions { flex: 0 0 auto; }
.admin-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 4px;
  border-bottom: 1px solid #eee; background: #fff;
}
.admin-item:last-child { border-bottom: 0; }
.admin-item .item-name { flex: 1 1 auto; min-width: 0; }
.admin-item .item-price { flex: 0 0 90px; }
.admin-item .item-status { flex: 0 0 90px; }
.admin-item .item-actions { flex: 0 0 auto; text-align: right; white-space: nowrap; }
.admin-item.dragging, .cat-head.dragging { opacity: .4; }
.admin-item.drag-target { box-shadow: inset 0 2px 0 var(--brand); }
.cat-head.drag-target { box-shadow: inset 0 3px 0 var(--brand); }
@media (max-width: 600px) {
  .admin-item { flex-wrap: wrap; gap: 4px 10px; }
  .admin-item .item-name { flex: 1 1 100%; }
  .admin-item .item-actions { flex: 1 1 100%; text-align: left; }
}

.settings-heading { margin: 20px 0 8px; padding-bottom: 6px; border-bottom: 2px solid #eee; color: var(--brand); }
.settings-heading:first-child { margin-top: 0; }
.stat { text-align: center; padding: 18px; }
.stat-val { font-size: 1.5rem; font-weight: 700; color: var(--brand); }

/* ---------- modals / options ---------- */
.option-chip {
  border: 1px solid #ddd; border-radius: 20px; padding: 6px 12px; margin: 4px 6px 4px 0;
  cursor: pointer; font-size: .9rem; display: inline-flex; align-items: center; gap: 6px;
}
.option-chip.sel { background: #fdecea; border-color: var(--brand); color: var(--brand); font-weight: 600; }
/* Overlay controlled purely by Alpine x-show. Do NOT set display here so
   x-show can show/hide it reliably (x-show removes inline display when shown). */
.app-modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, .5); overflow: auto; padding: 32px 12px;
}
.app-modal .w3-modal-content { margin: 0 auto; }

/* ---------- table QR ---------- */
.qr-box {
  display: inline-block; background: #fff; padding: 12px; margin: 0 auto;
  border: 1px solid #eee; border-radius: 12px; max-width: 320px;
}
.qr-box svg { width: 100%; height: auto; display: block; }

/* ---------- auth ---------- */
.auth-wrap { display: flex; justify-content: center; padding-top: 4vh; }
.auth-card { width: 100%; max-width: 420px; overflow: hidden; }
.auth-head h3 { margin: 0; }
.demo-creds { margin-top: 14px; line-height: 1.5; }

/* ---------- install (PWA) suggestion ---------- */
.install-banner {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 210;
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: #fff; border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.28);
  max-width: 520px; margin: 0 auto;
}
.install-ico {
  flex: 0 0 auto; width: 42px; height: 42px; border-radius: 10px;
  background: #fdecea; color: var(--brand); display: flex; align-items: center; justify-content: center;
}
.install-ico svg { width: 22px; height: 22px; }
.install-text { flex: 1 1 auto; min-width: 0; }
.install-text strong { display: block; font-size: .95rem; }
.install-text p { margin: 2px 0 0; font-size: .82rem; color: #555; line-height: 1.35; }
.install-share { font-size: 1rem; }
.install-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; }
.install-actions .w3-button { padding: 6px 14px; font-size: .85rem; }
@media (max-width: 480px) {
  .install-banner { flex-wrap: wrap; }
  .install-actions { flex: 1 1 100%; justify-content: flex-end; }
}

/* ---------- toast ---------- */
.toast {
  position: fixed; top: calc(var(--topbar-h) + 12px); left: 50%; transform: translateX(-50%);
  color: #fff; padding: 10px 20px; border-radius: 24px; z-index: 200;
  box-shadow: 0 4px 16px rgba(0,0,0,.25); font-size: .9rem;
}

.my-relative {
  position: relative;
}

.right-money {
  width: fit-content;
  position: absolute;
  right: 10px;
  bottom: 2px;
}
