/* VendorPOS — minimal mobile-first styling for M2 */

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

body {
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1a202c;
  background: #f7fafc;
}

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem;
}

header h1 {
  margin: 0 0 1rem;
  font-size: 1.5rem;
  font-weight: 600;
}
header h1 small {
  font-weight: normal;
  color: #718096;
  font-size: 0.65em;
  margin-left: 0.5rem;
}

h2 {
  font-size: 1.1rem;
  margin: 0 0 0.75rem;
  color: #2d3748;
}

h3 {
  font-size: 0.95rem;
  margin: 1rem 0 0.5rem;
  color: #4a5568;
}

section {
  background: white;
  border-radius: 8px;
  padding: 1rem;
  margin: 0 0 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

label {
  display: block;
  margin: 0.75rem 0 0.25rem;
  font-weight: 500;
  font-size: 0.9rem;
  color: #4a5568;
}

input, select, button {
  font: inherit;
  padding: 0.6rem;
  border-radius: 6px;
  border: 1px solid #cbd5e0;
  width: 100%;
  background: white;
}

input:focus, select:focus {
  outline: none;
  border-color: #2c5282;
  box-shadow: 0 0 0 2px rgba(44, 82, 130, 0.2);
}

button {
  background: #2c5282;
  color: white;
  border: none;
  cursor: pointer;
  font-weight: 500;
  margin-top: 0.5rem;
}
button:hover  { background: #2a4365; }
button:active { background: #1a365d; }
button:disabled { background: #a0aec0; cursor: not-allowed; }

button.secondary { background: #718096; }
button.secondary:hover { background: #4a5568; }

.status {
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
}
.status.ok      { background: #c6f6d5; color: #22543d; }
.status.error   { background: #fed7d7; color: #742a2a; }
.status.pending { background: #fefcbf; color: #744210; }
.status.muted   { background: #edf2f7; color: #4a5568; }

pre {
  background: #1a202c;
  color: #e2e8f0;
  padding: 0.75rem;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.78rem;
  max-height: 360px;
  margin: 0.5rem 0 0;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  line-height: 1.4;
}

.muted {
  color: #718096;
  font-size: 0.9rem;
}

.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 1rem;
  font-size: 0.9rem;
  margin: 0.5rem 0;
}
.kv dt { color: #718096; }
.kv dd { margin: 0; color: #2d3748; font-weight: 500; }

/* ---------- Header / nav / pip ---------- */

header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
header h1 { margin: 0; flex: 1 1 auto; font-size: 1.4rem; }

.view-tabs { display: flex; gap: 0.25rem; }
.view-tabs button {
  width: auto; padding: 0.4rem 0.9rem; margin: 0;
  background: white; color: #2c5282;
  border: 1px solid #cbd5e0; font-size: 0.9rem; font-weight: 500;
}
.view-tabs button.active { background: #2c5282; color: white; border-color: #2c5282; }

.status-pip {
  font-size: 0.8rem; padding: 0.3rem 0.7rem; border-radius: 999px;
  background: #edf2f7; color: #4a5568; white-space: nowrap;
}
.status-pip.ok      { background: #c6f6d5; color: #22543d; }
.status-pip.pending { background: #fefcbf; color: #744210; }
.status-pip.error   { background: #fed7d7; color: #742a2a; }

/* ---------- Sale view ---------- */

.sale-banner {
  background: #ebf8ff;
  color: #2c5282;
  padding: 0.6rem 0.9rem;
  border-radius: 6px;
  margin: 0 0 1rem;
  font-size: 0.9rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.sale-banner .event-info { flex: 1 1 auto; }
.sale-banner .event-running {
  background: white;
  padding: 0.3rem 0.65rem;
  border-radius: 4px;
  font-size: 0.85rem;
  color: #2d3748;
  white-space: nowrap;
}
.sale-banner .event-running strong { color: #2c5282; }

.test-event-banner {
  background: #fefcbf;
  color: #744210;
  padding: 0.7rem 1rem;
  border: 2px solid #d69e2e;
  border-radius: 6px;
  margin: 0 0 0.75rem;
  font-weight: 600;
  text-align: center;
  font-size: 0.95rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.sale-banner.test-mode {
  background: #fffbea;
  border: 1px solid #d69e2e;
}

.search-results {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  max-height: 320px;
  overflow-y: auto;
  background: white;
}
.result-item {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #edf2f7;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}
.result-item:hover { background: #f7fafc; }
.result-item:last-child { border-bottom: none; }
.result-name { flex: 1; }
.result-price { color: #2c5282; font-weight: 500; margin-left: 1rem; }

.cart-items {
  list-style: none;
  padding: 0;
  margin: 0;
}
.cart-items li {
  padding: 0.7rem 0;
  border-bottom: 1px solid #edf2f7;
}
.cart-items li:last-child { border-bottom: none; }
.line-name { font-weight: 500; margin-bottom: 0.4rem; }
.line-controls {
  display: flex; align-items: center; gap: 0.5rem;
}
.qty-btn {
  width: 32px; height: 32px; padding: 0; margin: 0;
  font-size: 1.2rem; line-height: 1; font-weight: 600;
  background: #edf2f7; color: #2d3748;
  border: 1px solid #cbd5e0;
}
.qty-btn:hover { background: #e2e8f0; }
.qty {
  min-width: 28px; text-align: center; font-weight: 500;
}
.line-price { font-size: 0.85rem; }
.line-total {
  margin-left: auto; margin-right: 0.4rem;
  color: #2c5282; font-weight: 500; min-width: 60px; text-align: right;
}
.remove-btn {
  width: 32px; height: 32px; padding: 0; margin: 0;
  background: #fed7d7; color: #742a2a; font-size: 1.1rem; line-height: 1;
  border: 1px solid #fc8181;
}
.remove-btn:hover { background: #feb2b2; }

.badge {
  font-size: 0.7em;
  background: #fefcbf; color: #744210;
  padding: 2px 6px; border-radius: 999px; vertical-align: middle;
  margin-left: 0.3rem;
}
.badge.low { background: #fed7d7; color: #742a2a; }

.totals {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 2px solid #edf2f7;
}
.totals .row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.35rem 0; font-size: 0.95rem;
}
.totals .total-row {
  font-size: 1.4rem; font-weight: 700;
  margin-top: 0.5rem; padding-top: 0.7rem;
  border-top: 1px solid #cbd5e0;
}
.discount-row label { margin: 0; }
.discount-input {
  width: 80px; padding: 0.3rem;
  text-align: right; display: inline-block; margin-left: 0.2rem;
}

/* ---------- Payment ---------- */

.payment-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
}
.payment-btn {
  padding: 1rem 0; margin: 0;
  font-size: 1rem; font-weight: 600;
  background: white; color: #2c5282;
  border: 2px solid #cbd5e0;
}
.payment-btn:hover { border-color: #2c5282; background: #ebf8ff; }
.payment-btn.selected {
  background: #2c5282; color: white; border-color: #2c5282;
}
#complete-sale {
  margin-top: 1rem;
  padding: 1rem; font-size: 1.1rem; font-weight: 700;
}
#complete-sale:disabled { background: #a0aec0; }
#complete-status:empty { display: none; }
#complete-status { margin-top: 0.5rem; }

/* ---------- Category tabs + item grids ---------- */

.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0 0 0.75rem;
}
.category-tab {
  width: auto; padding: 0.45rem 0.85rem; margin: 0;
  background: white; color: #2c5282;
  border: 1px solid #cbd5e0;
  font-size: 0.9rem; font-weight: 500;
  border-radius: 6px;
}
.category-tab:hover { background: #ebf8ff; border-color: #2c5282; }
.category-tab.active {
  background: #2c5282; color: white; border-color: #2c5282;
}

.grid.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
  margin: 0.4rem 0 1rem;
  max-height: 360px;
  overflow-y: auto;
  padding: 0.2rem;
  background: #f7fafc;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}

.quickpick-grid {
  background: #fffbea;
  border-color: #fde68a;
}

.item-btn {
  width: 100%; height: 80px;
  padding: 0.5rem;
  margin: 0;
  background: white;
  color: #1a202c;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: stretch;
  text-align: left;
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  transition: transform 60ms ease, background 60ms ease;
}
.item-btn:hover {
  border-color: #2c5282;
  background: #ebf8ff;
}
.item-btn:active {
  transform: scale(0.97);
}
.item-btn.flash {
  background: #c6f6d5;
  border-color: #48bb78;
}
.item-name {
  font-size: 0.85rem;
  font-weight: 500;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  word-break: break-word;
}
.item-price {
  font-size: 0.95rem;
  color: #2c5282;
  font-weight: 700;
  align-self: flex-end;
}

.quickpick-grid .item-btn {
  background: #fffbea;
  border-color: #fde68a;
}
.quickpick-grid .item-btn:hover {
  background: #fef5c7;
  border-color: #d97706;
}

.item-btn .badge.low {
  font-size: 0.65em;
  margin-left: 0.3rem;
  vertical-align: top;
}

/* ---------- Scan button + modal ---------- */

.scan-btn {
  margin: 0 0 0.5rem;
  background: #2c5282;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.7rem;
}

.scan-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.scan-modal-inner {
  background: #1a202c;
  color: white;
  width: 100%; max-width: 600px;
  border-radius: 10px;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.scan-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.75rem 1rem;
  background: #2d3748;
  font-weight: 500;
}
.scan-close {
  width: auto; padding: 0.4rem 0.8rem; margin: 0;
  background: #e53e3e; color: white; border: none;
  font-weight: 600;
}
.scan-close:hover { background: #c53030; }

.scan-viewport {
  position: relative;
  width: 100%;
  background: black;
  aspect-ratio: 16 / 9;
  overflow: hidden;
}
.scan-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.scan-crosshair {
  position: absolute;
  top: 30%; left: 20%;
  width: 60%; height: 40%;
  border: 3px solid rgba(255,255,255,0.7);
  border-radius: 8px;
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.25);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.scan-crosshair.hit {
  border-color: #48bb78;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.1), 0 0 20px rgba(72,187,120,0.6);
}

.scan-status {
  padding: 0.7rem 1rem;
  background: #2d3748;
  font-size: 0.95rem;
  border-top: 1px solid #4a5568;
}
.scan-status.ok    { background: #22543d; color: #c6f6d5; }
.scan-status.error { background: #742a2a; color: #fed7d7; }

.scan-recent {
  max-height: 120px; overflow-y: auto;
  padding: 0.5rem 1rem;
  background: #1a202c;
  font-size: 0.85rem;
}
.scan-recent-item {
  padding: 0.25rem 0;
  font-family: "SF Mono", Menlo, Consolas, monospace;
}
.scan-recent-item.ok    { color: #9ae6b4; }
.scan-recent-item.error { color: #fc8181; }

.scan-no-camera {
  padding: 2rem 1rem;
  text-align: center;
  background: #2d3748;
  color: #e2e8f0;
}
.scan-no-camera .muted { color: #a0aec0; margin-top: 0.5rem; font-size: 0.85rem; }
.scan-no-camera .small { font-size: 0.85rem; }

.scan-manual {
  padding: 0.7rem 1rem;
  background: #2d3748;
  border-top: 1px solid #4a5568;
  display: flex; gap: 0.5rem; align-items: flex-end;
}
.scan-manual label {
  flex: 1;
  color: #cbd5e0;
  margin: 0;
  font-size: 0.85rem;
  font-weight: 400;
}
.scan-manual input {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem;
  background: #1a202c;
  color: white;
  border: 1px solid #4a5568;
  border-radius: 4px;
}
.scan-manual input:focus {
  outline: none;
  border-color: #3182ce;
}
.scan-manual button {
  width: auto;
  padding: 0.55rem 1.2rem;
  margin: 0;
  background: #3182ce;
  color: white;
  border: none;
  flex-shrink: 0;
  font-weight: 600;
}
.scan-manual button:hover { background: #2c5282; }

/* ---------- Test barcode generator ---------- */

.barcode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}
.barcode-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.6rem;
  text-align: center;
}
.barcode-name {
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  min-height: 2.5em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.barcode-svg { display: block; margin: 0 auto; max-width: 100%; }
.barcode-meta {
  display: flex; justify-content: space-between;
  font-size: 0.8rem; color: #718096; margin-top: 0.4rem;
}

/* ---------- Recent view ---------- */

.recent-banner {
  background: #ebf8ff;
  color: #2c5282;
  padding: 0.6rem 0.9rem;
  border-radius: 6px;
  margin: 0 0 1rem;
  font-size: 0.95rem;
}

.totals-strip {
  background: white;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin: 0 0 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.totals-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  text-align: center;
}
.totals-grid > div {
  padding: 0.4rem 0.3rem;
  border-radius: 6px;
  background: #f7fafc;
}
.totals-grid > div.grand {
  background: #2c5282;
  color: white;
}
.totals-grid > div.grand .muted { color: rgba(255,255,255,0.75); }
.totals-grid > div .muted {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.2rem;
}
.totals-grid > div strong { font-size: 1.1rem; font-weight: 700; }
.totals-grid > div.grand strong { font-size: 1.3rem; }

.recent-controls {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.filter-btn {
  width: auto;
  padding: 0.4rem 0.85rem;
  margin: 0;
  background: white;
  color: #2c5282;
  border: 1px solid #cbd5e0;
  font-size: 0.85rem;
  font-weight: 500;
}
.filter-btn:hover { background: #ebf8ff; }
.filter-btn.active {
  background: #2c5282;
  color: white;
  border-color: #2c5282;
}

.sales-list {
  list-style: none;
  margin: 0; padding: 0;
}
.sale-row {
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  background: white;
}
.sale-row.voided { opacity: 0.55; }

.sale-summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  cursor: pointer;
}
.sale-summary:hover { background: #f7fafc; }
.sale-row.expanded .sale-summary { border-bottom: 1px solid #edf2f7; }
.sale-time {
  font-size: 0.85rem;
  color: #718096;
  min-width: 100px;
}
.sale-total {
  font-weight: 700;
  color: #2c5282;
  min-width: 70px;
}
.sale-payment {
  font-size: 0.75rem;
  background: #edf2f7;
  color: #4a5568;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.sale-items {
  font-size: 0.85rem;
  color: #718096;
  flex: 1;
}
.expand-arrow {
  color: #a0aec0;
  font-size: 1rem;
}
.voided-badge {
  background: #fed7d7 !important;
  color: #742a2a !important;
}

.sale-details {
  padding: 0.75rem 0.85rem;
  background: #f7fafc;
  font-size: 0.9rem;
}
.line-items-table {
  width: 100%;
  border-collapse: collapse;
}
.line-items-table td {
  padding: 0.25rem 0.4rem;
  vertical-align: top;
}
.line-items-table tbody tr {
  border-bottom: 1px solid #edf2f7;
}
.line-items-table .li-name { width: 60%; }
.line-items-table .li-qty,
.line-items-table .li-price,
.line-items-table .li-total { text-align: right; white-space: nowrap; }
.line-items-table tfoot td { padding-top: 0.4rem; text-align: right; }
.line-items-table tfoot td:last-child { text-align: right; }
.line-items-table tfoot tr.grand-row td {
  border-top: 1px solid #cbd5e0;
  padding-top: 0.5rem;
  font-size: 1rem;
}
.sale-actions {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.sale-actions .void-btn {
  width: auto;
  padding: 0.4rem 0.9rem;
  margin: 0;
  background: #e53e3e;
  color: white;
  border: none;
}
.sale-actions .void-btn:hover { background: #c53030; }
.sale-actions .small { font-size: 0.8rem; }

/* ---------- Post Event section (Recent view) ---------- */

.post-event-section {
  margin-top: 1.5rem;
  padding: 1rem 1.1rem;
  background: #fffaf0;
  border: 1px solid #f6ad55;
  border-radius: 8px;
}
.post-event-section.test {
  background: #fefcbf;
  border-color: #d69e2e;
}
.post-event-section.done {
  background: #f0fff4;
  border-color: #9ae6b4;
}
.post-event-section h3 {
  margin: 0 0 0.5rem;
  color: #744210;
  font-size: 1rem;
}
.post-event-section.done h3 { color: #22543d; }
.post-event-summary {
  margin-bottom: 0.75rem;
  color: #2d3748;
  font-size: 0.95rem;
}
.post-event-btn {
  width: 100%;
  padding: 0.85rem;
  background: #c05621;
  color: white;
  border: none;
  font-size: 1rem;
  font-weight: 600;
}
.post-event-btn:hover { background: #9c4221; }
.post-event-btn:disabled { background: #a0aec0; cursor: not-allowed; }
.post-event-note { margin-top: 0.5rem; font-size: 0.8rem; }
#post-event-status:empty { display: none; }
#post-event-status { margin-top: 0.6rem; }

/* ---------- Waitlist QR modal ---------- */

.qr-modal {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.qr-modal-inner {
  background: white;
  border-radius: 12px;
  padding: 2rem 2rem 1.5rem;
  max-width: 90vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.qr-modal-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #1a202c;
}
.qr-img {
  max-width: 80vmin;
  max-height: 80vmin;
  width: auto;
  height: auto;
  border: 1px solid #e2e8f0;
  background: white;
}
.qr-modal-url {
  font-size: 0.85rem;
  color: #4a5568;
  word-break: break-all;
  text-align: center;
  max-width: 480px;
}
.qr-close {
  width: auto;
  padding: 0.6rem 1.5rem;
  background: #2c5282;
  color: white;
  border: none;
  font-weight: 600;
}
.qr-close:hover { background: #2a4365; }
