
:root {
  color-scheme: dark;
  --bg: #111318;
  --panel: #191c23;
  --panel-light: #20242d;
  --border: #303541;
  --text: #f4f5f7;
  --muted: #a0a6b3;
  --orange: #ff8a00;
  --orange-light: #ffb347;
  --green: #48d597;
  --red: #ff6565;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 28px;
  background: #171920;
  border-bottom: 1px solid var(--border);
}

.brand {
  font-size: 25px;
  font-weight: 900;
  letter-spacing: 1.5px;
}

.brand span {
  color: var(--orange);
}

.topbar small,
.heading p,
.receipt-heading p {
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 14px;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.status span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  max-width: 1600px;
  margin: 0 auto;
  padding: 26px;
}

.catalog,
.receipt {
  min-width: 0;
}

.heading,
.receipt-heading,
.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: 27px;
}

h2 {
  margin-bottom: 4px;
  font-size: 21px;
}

h3 {
  font-size: 15px;
}

.heading p,
.receipt-heading p {
  margin-bottom: 0;
  font-size: 14px;
}

.primary,
.secondary,
.danger-button,
.icon-button,
.text-button {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 11px 14px;
  font-weight: 700;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}

.primary {
  color: #161616;
  background: var(--orange);
}

.primary:hover {
  background: var(--orange-light);
  transform: translateY(-1px);
}

.secondary {
  color: var(--text);
  background: var(--panel-light);
  border-color: var(--border);
}

.secondary:hover {
  border-color: var(--orange);
}

.danger-button {
  color: #fff;
  background: #4b2429;
  border-color: #693139;
}

.danger-button:hover {
  background: #6a2b33;
}

.icon-button {
  padding: 8px 11px;
  color: var(--muted);
  background: transparent;
  border-color: var(--border);
}

.icon-button:hover {
  color: var(--text);
  border-color: var(--orange);
}

.text-button {
  padding: 7px 0;
  color: var(--muted);
  background: transparent;
}

.text-button:hover {
  color: var(--orange-light);
}

.search,
input,
select {
  width: 100%;
  min-width: 0;
  padding: 12px;
  color: var(--text);
  background: #15171d;
  border: 1px solid var(--border);
  border-radius: 9px;
}

.search {
  margin: 22px 0 16px;
}

.categories {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-bottom: 20px;
}

.categories button {
  padding: 9px 14px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 30px;
}

.categories button.active {
  color: #171717;
  background: var(--orange);
  border-color: var(--orange);
  font-weight: 800;
}

.products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 14px;
}

.product {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 12px;
  overflow: hidden;
  text-align: left;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 13px;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.product:hover {
  border-color: var(--orange);
  transform: translateY(-2px);
}

.product:active {
  transform: scale(0.97);
}

.product.product-added {
  animation: productAdded 450ms ease;
}

@keyframes productAdded {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 #ff8a0000;
  }
  45% {
    transform: scale(0.96);
    border-color: var(--orange);
    box-shadow: 0 0 0 3px #ff8a0066;
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 #ff8a0000;
  }
}

.product-image,
.product-image-placeholder {
  display: flex;
  width: 100%;
  height: 125px;
  align-items: center;
  justify-content: center;
  object-fit: cover;
  color: var(--orange);
  background: #252933;
  border-radius: 8px;
}

.product-image-placeholder {
  font-size: 35px;
}

.product-name {
  font-weight: 750;
  overflow-wrap: anywhere;
}

.product-prices {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.product-price {
  color: var(--orange-light);
  font-weight: 850;
}

.old-price {
  color: var(--muted);
  font-size: 12px;
  text-decoration: line-through;
}

.promo-badge {
  padding: 3px 6px;
  color: #1b1205;
  background: var(--orange);
  border-radius: 5px;
  font-size: 10px;
  font-weight: 900;
}

.receipt {
  position: sticky;
  top: 18px;
  align-self: start;
  padding: 19px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 15px;
}

.receipt-heading {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.cart {
  display: flex;
  max-height: 330px;
  flex-direction: column;
  gap: 13px;
  padding: 15px 0;
  overflow-y: auto;
}

.cart-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--border);
}

.cart-item > div:first-child {
  min-width: 0;
}

.cart-name {
  margin-bottom: 4px;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.cart-price,
.field-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.quantity {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.quantity button {
  width: 29px;
  height: 29px;
  color: var(--text);
  background: var(--panel-light);
  border: 1px solid var(--border);
  border-radius: 7px;
}

.quantity button:hover {
  border-color: var(--orange);
}

.line-total {
  flex-shrink: 0;
  font-weight: 800;
}

.empty {
  padding: 22px 10px;
  color: var(--muted);
  text-align: center;
  line-height: 1.8;
}

.discount-panel {
  padding: 15px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.discount-panel h3 {
  margin-bottom: 12px;
}

.discount-controls {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 8px;
}

.discount-controls select,
.discount-controls input {
  padding: 10px 8px;
  font-size: 13px;
}

.discount-button {
  width: 100%;
  margin-top: 9px;
}

.discount-feedback {
  min-height: 15px;
  margin: 4px 0 0;
  color: var(--orange-light);
  font-size: 12px;
}

.totals {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 0;
}

.totals > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.discount-total-row {
  color: var(--green);
  font-size: 13px;
}

.grand-total {
  margin-top: 4px;
  padding-top: 15px;
  border-top: 1px dashed #555b68;
  font-size: 18px;
}

.grand-total strong {
  color: var(--orange-light);
  font-size: 24px;
}

.pay-button {
  width: 100%;
  padding: 15px;
  font-size: 16px;
}

.notice {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

dialog {
  width: min(680px, calc(100% - 28px));
  max-height: 88vh;
  padding: 24px;
  overflow-y: auto;
  color: var(--text);
  background: #191c23;
  border: 1px solid #383d49;
  border-radius: 16px;
  box-shadow: 0 25px 100px #0009;
}

dialog::backdrop {
  background: #000a;
  backdrop-filter: blur(4px);
}

.dialog-heading {
  position: sticky;
  top: -24px;
  z-index: 2;
  margin: -2px 0 20px;
  padding: 2px 0 14px;
  background: #191c23;
  border-bottom: 1px solid var(--border);
}

.dialog-heading h2 {
  margin: 0;
}

#productForm {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 28px;
}

#productForm label,
.history-tools label {
  margin-top: 7px;
  font-size: 13px;
  font-weight: 750;
}

#productForm input {
  margin-bottom: 2px;
}

.field-help {
  display: block;
  margin: 0 0 5px;
}

.image-preview {
  width: min(220px, 100%);
  max-height: 180px;
  object-fit: contain;
  background: #111318;
  border-radius: 8px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.admin-settings {
  margin-bottom: 25px;
  padding: 16px;
  background: #14161c;
  border: 1px solid var(--border);
  border-radius: 11px;
}

.admin-settings h3 {
  margin-bottom: 8px;
}

.admin-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.admin-thumb {
  width: 54px;
  height: 54px;
  flex-shrink: 0;
  object-fit: cover;
  border-radius: 8px;
}

.admin-info {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.admin-info strong {
  display: block;
  margin-bottom: 4px;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.admin-actions button {
  padding: 8px 10px;
  font-size: 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.stat-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 9px;
  padding: 14px;
  background: #14161c;
  border: 1px solid var(--border);
  border-radius: 11px;
}

.stat-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.stat-card strong {
  color: var(--orange-light);
  font-size: 19px;
  overflow-wrap: anywhere;
}

.history-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.history-tools label {
  width: 100%;
}

.history-tools input {
  flex: 1 1 150px;
  width: auto;
}

.history-tools button {
  padding: 10px;
}

.sale-card {
  margin-bottom: 10px;
  background: #14161c;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.sale-card summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  cursor: pointer;
}

.sale-card summary strong {
  flex-shrink: 0;
  color: var(--orange-light);
}

.sale-card-heading {
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.sale-details {
  padding: 0 14px 12px;
  border-top: 1px solid var(--border);
}

.sale-details p {
  margin: 10px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.sale-details .sale-final {
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
}

.cart-notice {
  position: fixed;
  right: 20px;
  bottom: 22px;
  z-index: 9999;
  max-width: calc(100% - 40px);
  padding: 13px 18px;
  color: #171717;
  background: var(--orange);
  border-radius: 10px;
  box-shadow: 0 8px 28px #0008;
  font-weight: 800;
  pointer-events: none;
  opacity: 0;
}

.cart-notice.notice-visible {
  animation: noticeAppear 1.8s ease forwards;
}

@keyframes noticeAppear {
  0% {
    opacity: 0;
    transform: translateY(12px);
  }
  15%, 78% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-5px);
  }
}

[hidden] {
  display: none !important;
}

@media (max-width: 950px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 16px;
    padding: 18px;
  }

  .topbar {
    padding: 16px 18px;
  }

  .products {
    grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .layout {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .receipt {
    position: static;
  }

  .cart {
    max-height: none;
  }

  .heading {
    align-items: flex-start;
  }

  .heading button {
    max-width: 48%;
    padding: 10px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stat-card {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .stat-card strong {
    text-align: right;
  }

  dialog {
    padding: 18px;
  }

  .dialog-heading {
    top: -18px;
  }

  .admin-row {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .admin-info {
    flex-basis: calc(100% - 75px);
  }

  .admin-actions {
    width: 100%;
    padding-left: 66px;
  }

  .sale-card summary {
    flex-direction: column;
    gap: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== PAIEMENT — STYLE CAISSE PRO ===== */

.payment-panel {
  margin-top: 18px;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  animation: paymentAppear 180ms ease-out;
}

.payment-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.payment-heading h3 {
  margin: 0 0 5px;
  font-size: 17px;
}

.payment-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.payment-total {
  margin-bottom: 18px;
  padding: 15px;
  background: var(--panel-light);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.payment-total span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
}

.payment-total strong {
  color: var(--orange-light);
  font-size: 27px;
  font-weight: 900;
}

.payment-methods {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.payment-method {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 8px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 9px;
  font-weight: 750;
  transition: background 150ms ease, border-color 150ms ease;
}

.payment-method:hover {
  border-color: var(--orange);
}

.payment-method.active {
  color: var(--orange-light);
  background: #302315;
  border-color: var(--orange);
  box-shadow: inset 0 0 0 1px var(--orange);
}

.payment-icon {
  font-size: 20px;
}

.payment-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.payment-fields label {
  font-size: 13px;
  font-weight: 750;
}

.payment-fields input {
  min-height: 44px;
}

.change-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  background: var(--panel-light);
  border: 1px solid var(--border);
  border-radius: 9px;
}

.change-row span {
  color: var(--muted);
  font-size: 13px;
}

.change-row strong {
  color: var(--green);
  font-size: 18px;
}

.payment-message {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.payment-message.success {
  color: var(--green);
}

.payment-message.error {
  color: var(--red);
}

.card-instructions {
  padding: 13px;
  color: var(--muted);
  background: var(--panel-light);
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 12px;
  line-height: 1.6;
}

.card-confirmation {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  background: var(--panel-light);
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 13px;
  line-height: 1.5;
}

.card-confirmation input {
  width: 17px;
  min-width: 17px;
  height: 17px;
  margin-top: 2px;
  accent-color: var(--orange);
}

.card-confirmation label {
  cursor: pointer;
}

.payment-actions {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 16px;
}

.payment-actions button {
  width: 100%;
  min-height: 44px;
}

#confirmPayment:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

#cancelPayment {
  background: transparent;
}

@keyframes paymentAppear {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 720px) {
  .payment-panel {
    padding: 13px;
  }

  .payment-total strong {
    font-size: 24px;
  }

  .payment-method {
    flex-direction: column;
    gap: 6px;
  }
}
