/* ===== AgenX App Shell ===== */
:root {
  --sidebar-w: 264px;
}

html, body { height: 100%; }
body { overflow-x: hidden; }

#app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, #ffffff 0%, #f9f7ff 100%);
  border-right: 1px solid #eeebfb;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  overflow-y: auto;
  z-index: 40;
  transition: transform 0.25s ease;
}
#sidebar .brand {
  height: 72px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-bottom: 1px solid #eeebfb;
  font-family: 'Sora', sans-serif;
  font-weight: 800;
  font-size: 1.15rem;
  color: #1e293b;
}
#sidebar nav { padding: 14px 12px 24px; }
#sidebar .nav-section-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #a68ce5;
  padding: 16px 12px 6px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: #475569;
  text-decoration: none;
  margin-bottom: 2px;
  transition: all 0.15s ease;
  cursor: pointer;
}
.nav-link i { width: 18px; text-align: center; color: #a68ce5; font-size: 14px; }
.nav-link:hover { background: #f7f6fd; color: #5d38a1; }
.nav-link.active { background: linear-gradient(90deg, #eeebfb, #e3f2ff); color: #5d38a1; box-shadow: inset 0 0 0 1px #dcd5f6; }
.nav-link.active i { color: #7247c4; }

/* ---- Main area ---- */
#main-area {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
#topbar {
  height: 72px;
  border-bottom: 1px solid #eeebfb;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
  gap: 16px;
}
#topbar .selector {
  font-size: 12.5px;
  font-weight: 700;
  border: 1px solid #dcd5f6;
  background: #fff;
  border-radius: 10px;
  padding: 7px 10px;
  color: #4c2f81;
  cursor: pointer;
}
#page-content { padding: 28px 28px 60px; max-width: 1400px; width: 100%; margin: 0 auto; }

/* mobile sidebar toggle */
#sidebar-toggle { display: none; }
@media (max-width: 900px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,0.25); }
  #main-area { margin-left: 0; }
  #sidebar-toggle { display: inline-flex; }
}

/* ---- Generic components ---- */
.vx-card {
  background: #fff;
  border: 1px solid #eeebfb;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 4px 20px -4px rgba(122,108,214,0.08);
}
.vx-page-title { font-family: 'Sora', sans-serif; font-weight: 800; font-size: 1.5rem; color: #1e293b; }
.vx-page-sub { color: #64748b; font-size: 13.5px; margin-top: 2px; }

.vx-tabs { display: flex; gap: 4px; border-bottom: 1px solid #eeebfb; margin-bottom: 20px; overflow-x: auto; }
.vx-tab {
  padding: 10px 16px; font-size: 13px; font-weight: 700; color: #94a3b8; cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.vx-tab.active { color: #7247c4; border-color: #7247c4; }
.vx-tab:hover { color: #5d38a1; }

.vx-btn {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px;
  padding: 9px 16px; border-radius: 10px; cursor: pointer; border: none; transition: all 0.15s;
}
.vx-btn-primary { background: linear-gradient(90deg,#3695f0,#7247c4); color: #fff; }
.vx-btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.vx-btn-secondary { background: #fff; color: #5d38a1; border: 1px solid #dcd5f6; }
.vx-btn-secondary:hover { border-color: #a68ce5; }
.vx-btn-danger { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.vx-btn-danger:hover { background: #fee2e2; }
.vx-btn-sm { padding: 5px 10px; font-size: 12px; }
.vx-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.vx-input, .vx-select, textarea.vx-input {
  width: 100%; padding: 9px 12px; border: 1px solid #e2e8f0; border-radius: 10px;
  font-size: 13.5px; color: #1e293b; background: #fff; outline: none; transition: border 0.15s;
}
.vx-input:focus, .vx-select:focus { border-color: #a68ce5; box-shadow: 0 0 0 3px rgba(166,140,229,0.15); }
.vx-label { font-size: 12px; font-weight: 700; color: #475569; margin-bottom: 4px; display: block; }
.vx-field { margin-bottom: 14px; }

.vx-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.vx-table th {
  text-align: left; font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em;
  color: #94a3b8; padding: 8px 12px; border-bottom: 2px solid #f1f5f9;
}
.vx-table td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; color: #334155; }
.vx-table tr:hover td { background: #fbfaff; }

.vx-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 800; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.02em; }
.vx-badge-green { background: #dcfce7; color: #16a34a; }
.vx-badge-amber { background: #fef3c7; color: #d97706; }
.vx-badge-red { background: #fee2e2; color: #dc2626; }
.vx-badge-gray { background: #f1f5f9; color: #64748b; }
.vx-badge-blue { background: #dbeafe; color: #2563eb; }
.vx-badge-purple { background: #eeebfb; color: #7247c4; }

/* Connectivity pill (KAN-57). Present in the topbar at all times: an indicator
   that only appears when things break is one nobody thinks to look for. Quiet
   when healthy, and loud enough to catch the eye across a counter when not. */
.vx-conn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 6px 11px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; user-select: none; }
.vx-conn-green { background: #f1f5f9; color: #64748b; border-color: #e2e8f0; }
.vx-conn-amber { background: #fef3c7; color: #b45309; border-color: #fcd34d; }
.vx-conn-red { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.vx-conn-age { font-variant-numeric: tabular-nums; opacity: 0.75; font-weight: 800; }
/* Degraded states pulse; the healthy one must not, or the movement becomes
   part of the furniture and stops meaning anything. */
.vx-conn-amber, .vx-conn-red { animation: vx-conn-pulse 2s ease-in-out infinite; }
@keyframes vx-conn-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.68; } }
@media (prefers-reduced-motion: reduce) { .vx-conn-amber, .vx-conn-red { animation: none; } }
/* On a narrow till the word is dropped and the icon plus timer carry it. */
@media (max-width: 640px) { .vx-conn span:not(.vx-conn-age) { display: none; } }

.vx-kpi { background: linear-gradient(135deg,#f7f6fd,#f2f9ff); border: 1px solid #eeebfb; border-radius: 14px; padding: 16px 18px; }
.vx-kpi .val { font-family: 'Sora', sans-serif; font-weight: 800; font-size: 1.6rem; color: #1e293b; }
.vx-kpi .lbl { font-size: 11.5px; font-weight: 700; color: #7247c4; text-transform: uppercase; letter-spacing: 0.03em; margin-top: 2px; }

.vx-empty { text-align: center; padding: 40px 20px; color: #94a3b8; font-size: 13.5px; }
.vx-empty i { font-size: 28px; color: #dcd5f6; margin-bottom: 10px; display: block; }

/* Toast */
#vx-toast-wrap { position: fixed; top: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.vx-toast {
  min-width: 260px; max-width: 360px; padding: 12px 16px; border-radius: 12px; font-size: 13px; font-weight: 600;
  box-shadow: 0 10px 30px -8px rgba(0,0,0,0.2); animation: vx-toast-in 0.2s ease;
  display: flex; align-items: flex-start; gap: 10px;
}
.vx-toast.success { background: #1e293b; color: #fff; }
.vx-toast.error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.vx-toast.info { background: #fff; color: #334155; border: 1px solid #e2e8f0; }
@keyframes vx-toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* Modal */
#vx-modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,0.5); z-index: 150;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.vx-modal {
  background: #fff; border-radius: 18px; max-width: 560px; width: 100%; max-height: 88vh; overflow-y: auto;
  padding: 24px; box-shadow: 0 30px 80px -20px rgba(0,0,0,0.35);
}
.vx-modal-title { font-family: 'Sora', sans-serif; font-weight: 800; font-size: 1.15rem; color: #1e293b; margin-bottom: 16px; }

/* POS Terminal */
.pos-grid { display: grid; grid-template-columns: 1fr 360px; gap: 20px; }
@media (max-width: 1100px) { .pos-grid { grid-template-columns: 1fr; } }
.menu-item-btn {
  border: 1px solid #eeebfb; border-radius: 14px; padding: 14px 10px; text-align: center; cursor: pointer;
  background: #fff; transition: all 0.15s;
}
.menu-item-btn:hover { border-color: #a68ce5; transform: translateY(-2px); box-shadow: 0 8px 20px -8px rgba(122,108,214,0.3); }
.kds-ticket { background: #fff; border: 1px solid #eeebfb; border-radius: 14px; padding: 14px; }
.kds-ticket.late { border-color: #fecaca; background: #fff7f7; }

.vx-alert { border-radius: 12px; padding: 12px 14px; font-size: 13px; font-weight: 600; margin-bottom: 14px; display: flex; gap: 10px; align-items: flex-start; }
.vx-alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.vx-alert-warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.vx-alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

.vx-chat-bubble { max-width: 80%; padding: 10px 14px; border-radius: 14px; font-size: 13.5px; line-height: 1.5; }
.vx-chat-bubble.user { background: linear-gradient(90deg,#3695f0,#7247c4); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.vx-chat-bubble.bot { background: #f7f6fd; color: #334155; align-self: flex-start; border-bottom-left-radius: 4px; }

/* ===== Printable documents =====
   A bill goes to an 80mm thermal roll far more often than to A4, so the
   document is sized for the roll and simply centres on a larger sheet.
   Everything else on the page is hidden at print time. */
.vx-doc {
  width: 80mm;
  margin: 0 auto;
  padding: 6mm 4mm;
  background: #fff;
  color: #000;
  font-family: 'Courier New', ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.45;
}
.vx-doc .doc-brand { text-align: center; margin-bottom: 8px; }
.vx-doc .doc-brand .name { font-weight: 700; font-size: 15px; letter-spacing: 0.02em; }
.vx-doc .doc-brand .meta { font-size: 11px; }
.vx-doc .doc-title {
  text-align: center; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; font-size: 11px; margin: 8px 0;
  border-top: 1px dashed #000; border-bottom: 1px dashed #000; padding: 4px 0;
}
.vx-doc .doc-row { display: flex; justify-content: space-between; gap: 8px; }
.vx-doc .doc-row.muted { font-size: 11px; }
.vx-doc .doc-items { margin: 8px 0; border-top: 1px dashed #000; padding-top: 6px; }
.vx-doc .doc-item { margin-bottom: 4px; }
.vx-doc .doc-item .qty { display: inline-block; min-width: 22px; }
.vx-doc .doc-totals { border-top: 1px dashed #000; margin-top: 6px; padding-top: 6px; }
.vx-doc .doc-totals .grand { font-weight: 700; font-size: 14px; border-top: 1px solid #000; margin-top: 4px; padding-top: 4px; }
.vx-doc .doc-foot { text-align: center; margin-top: 10px; font-size: 11px; border-top: 1px dashed #000; padding-top: 6px; }
.vx-doc .doc-note { text-align: center; font-size: 10px; margin-top: 8px; }

/* The kitchen reads across a room, so the docket is large and priceless. */
.vx-doc.ticket { font-size: 14px; }
.vx-doc.ticket .doc-item { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.vx-doc.ticket .station {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  border-bottom: 1px solid #000; margin: 10px 0 6px;
}

@media print {
  /* Only the document reaches the paper. */
  body * { visibility: hidden; }
  #vx-print-area, #vx-print-area * { visibility: visible; }
  #vx-print-area { position: absolute; inset: 0; margin: 0; }
  #vx-modal-backdrop, #sidebar, #topbar, #vx-toast-wrap { display: none !important; }
  .vx-doc { width: auto; max-width: 80mm; box-shadow: none; }
  @page { margin: 4mm; }
}
