/* Reusable components. Build new screens from these; add a new component here (and to
   docs/DESIGN.md) rather than styling one-offs in a page. Tokens only, no raw colours. */

.app-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: color-mix(in oklch, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.app-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  min-height: 3.75rem;
}
.brand {
  font-weight: 700;
  font-size: var(--fs-lg);
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--tap);
  padding: 0 var(--sp-4);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--primary);
  color: var(--on-primary);
  transition:
    background-color var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
}
.btn:hover {
  background: var(--primary-hover);
}
.btn:active {
  transform: translateY(1px);
}
.btn[disabled],
.btn[aria-busy="true"] {
  opacity: 0.6;
  cursor: not-allowed;
}
.btn--secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn--secondary:hover {
  background: var(--surface-2);
}
.btn--ghost {
  background: transparent;
  color: var(--text);
}
.btn--ghost:hover {
  background: var(--surface-2);
}
.btn--danger {
  background: var(--danger);
  color: var(--on-primary);
}
.btn--danger:hover {
  background: color-mix(in oklch, var(--danger) 85%, var(--text));
}
.btn--icon {
  width: var(--tap);
  padding: 0;
}
.btn--sm {
  min-height: var(--button-min-height);
  padding: 0 var(--sp-3);
  font-size: var(--fs-sm);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-1);
}
.card__title {
  margin: 0 0 var(--sp-2);
  font-size: var(--fs-lg);
}

.field {
  display: grid;
  gap: var(--sp-1);
}
.field > label {
  font-weight: 600;
  font-size: var(--fs-sm);
}
.input,
.select,
.textarea {
  width: 100%;
  min-height: var(--tap);
  padding: var(--sp-2) var(--sp-3);
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.textarea {
  min-height: 6rem;
  resize: vertical;
}
.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--text-muted);
}
.input[aria-invalid="true"] {
  border-color: var(--danger);
}
.field__error {
  color: var(--danger);
  font-size: var(--fs-sm);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 0.1rem var(--sp-2);
  border-radius: var(--radius-full);
  font-size: var(--fs-sm);
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge--success {
  color: var(--success);
}
.badge--warning {
  color: var(--warning);
}
.badge--danger {
  color: var(--danger);
}
.badge--accent {
  color: var(--brand-navy);
  background: var(--accent);
  border-color: transparent;
}
.dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: var(--radius-full);
  background: currentColor;
}

.pos-grid {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(18rem, 2fr);
  gap: var(--sp-5);
}
.cart-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--border);
}
.payment-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--button-min-height);
  padding: var(--sp-3);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
}
.payment-button--primary {
  background: var(--primary);
  color: var(--on-primary);
  border-color: transparent;
}
.split-tender-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(7rem, auto);
  gap: var(--sp-2);
  align-items: center;
}
.tip-presets {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.tip-presets .btn {
  flex: 1 1 5rem;
}
.receipt-preview {
  width: min(100%, var(--receipt-width));
  margin-inline: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: var(--sp-4);
}
.skeleton-cart {
  display: grid;
  gap: var(--sp-3);
}

.page-main {
  display: grid;
  align-content: start;
  gap: var(--sp-5);
  padding-block: var(--sp-5);
}
.page-main--centered {
  max-width: var(--content-narrow);
  margin-inline: auto;
}
.page-main--login {
  padding-block: var(--sp-7);
}
.login-card {
  width: 100%;
  max-width: var(--content-login);
  margin-inline: auto;
}
.products-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
}
.products-heading p {
  margin-bottom: 0;
}
.product-search {
  width: min(100%, var(--content-search));
}
.product-form-actions {
  display: flex;
  align-items: end;
}
.table-wrap {
  overflow-x: auto;
}
.product-table {
  width: 100%;
  min-width: var(--table-min-width);
  border-collapse: collapse;
}
.product-table th,
.product-table td {
  padding: var(--sp-2);
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.product-table .product-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.product-edit-card {
  width: 100%;
}
.fieldset {
  min-width: 0;
  margin: 0;
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.pos-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--pos-product-min-width)), 1fr));
  gap: var(--sp-3);
}
.pos-product-card {
  display: grid;
  justify-items: start;
  gap: var(--sp-2);
  min-height: var(--pos-card-min-height);
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.pos-product-card:hover {
  border-color: var(--primary);
  background: var(--surface-2);
}
.pos-product-card:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.quantity-input {
  width: var(--quantity-width);
}
.checkout-totals p {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-2);
}
.checkout-totals p:nth-child(2) {
  font-size: var(--fs-lg);
}
.checkout-totals small {
  display: block;
}
.receipt-dialog {
  width: min(100% - 2rem, var(--dialog-wide));
}
.receipt-totals {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--sp-2);
}
.receipt-totals dd {
  margin: 0;
  text-align: right;
}
.screen-only {
  margin-top: var(--sp-4);
}
.sales-filters,
.report-controls {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: var(--sp-3);
}
.sales-filters > *,
.report-controls > * {
  flex: 1 1 10rem;
}
.customer-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border);
}
.report-chart {
  width: 100%;
  min-height: var(--chart-min-height);
  overflow: visible;
}
.report-chart text {
  fill: var(--text-muted);
  font: var(--fs-sm) var(--font-sans);
}
.report-chart .bar {
  fill: var(--primary);
}
.report-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
  gap: var(--sp-3);
}
.report-summary > div {
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  padding: var(--sp-5);
  width: min(100% - 2rem, 28rem);
  box-shadow: var(--shadow-2);
}
.dialog::backdrop {
  background: var(--scrim);
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--sp-3);
}
.list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.list__item[data-status="done"] .list__title {
  text-decoration: line-through;
  color: var(--text-muted);
}
.empty {
  text-align: center;
  padding: var(--sp-7) var(--sp-4);
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-2),
    var(--surface),
    var(--surface-2)
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: var(--radius);
  min-height: 3rem;
}
@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

.toasts {
  position: fixed;
  inset: auto var(--sp-4) var(--sp-4) auto;
  z-index: var(--z-toast);
  display: grid;
  gap: var(--sp-2);
  max-width: min(100% - 2rem, 24rem);
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-4);
  box-shadow: var(--shadow-2);
}
.toast--error {
  border-left-color: var(--danger);
}
.toast--success {
  border-left-color: var(--success);
}

.banner {
  padding: var(--sp-2) var(--sp-4);
  text-align: center;
  background: var(--surface-2);
  color: var(--text);
  border-bottom: 3px solid var(--warning);
  font-weight: 600;
}

@media (max-width: 40rem) {
  .pos-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .toasts {
    inset: auto var(--sp-3) var(--sp-3) var(--sp-3);
    max-width: none;
  }
  .card {
    padding: var(--sp-4);
  }
  .customer-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media print {
  body * {
    visibility: hidden;
  }
  .receipt-preview,
  .receipt-preview * {
    visibility: visible;
  }
  .receipt-preview {
    position: absolute;
    inset: 0 auto auto 0;
    width: var(--receipt-width);
    border: 0;
  }
  .screen-only {
    display: none;
  }
}
