/* ================================================
   PDV — Master PDV & Delivery
   ================================================ */

/* ESTILOS DE IMPRESSÃO (CUPOM TÉRMICO) */
@media print {
    @page { margin: 0; size: auto; }
    body * { visibility: hidden; }
    #modal-receipt, #modal-receipt * { visibility: visible; }
    #modal-receipt { position: absolute; left: 0; top: 0; width: 100%; margin: 0; padding: 0; background: white; }
    .receipt-box { width: 100% !important; max-width: 100% !important; border: none !important; padding: 0.3125rem !important; }
    #receipt-content { font-family: monospace !important; font-size: 0.8125rem !important; line-height: 1.1 !important; white-space: pre-wrap !important; width: 100%; color: #000 !important; }
    .no-print { display: none !important; }
}

:root,
[data-theme="light"] {
  --pdv-bg: #f3f4f6;
  --pdv-surface: #ffffff;
  --pdv-surface2: #f8fafc;
  --pdv-surface-hover: #eef2ff;
  --pdv-border: #d1d5db;
  --pdv-text: #111827;
  --pdv-text2: #4b5563;
  --pdv-accent: #dc2626;
  --pdv-accent-soft: rgba(220, 38, 38, 0.12);
  --pdv-green: #059669;
  --pdv-red: #dc2626;
  --pdv-blue: #2563eb;
  --pdv-radius: 0.625rem;
}

[data-theme="dark"] {
  --pdv-bg: #0f1117;
  --pdv-surface: #1a1d27;
  --pdv-surface2: #22263a;
  --pdv-surface-hover: #2a2f47;
  --pdv-border: #2e3248;
  --pdv-text: #f1f2f6;
  --pdv-text2: #a0aec0;
  --pdv-accent: #fbbf24;
  --pdv-accent-soft: rgba(251, 191, 36, 0.14);
  --pdv-green: #34d399;
  --pdv-red: #f87171;
  --pdv-blue: #60a5fa;
}

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

/* ✅ ACESSIBILIDADE: Foco visível em todo o sistema */
:focus-visible {
  outline: none;
  box-shadow: 0 0 0 0.125rem var(--pdv-bg), 0 0 0 0.25rem var(--pdv-accent);
  transition: box-shadow 0.2s ease;
}

.pdv-body {
  font-family: 'Inter', sans-serif;
  background: var(--pdv-bg);
  color: var(--pdv-text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 1rem; /* 16px base */
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ── HEADER ─────────────────────────────────── */
.pdv-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: env(safe-area-inset-top) calc(1.25rem + env(safe-area-inset-right)) 0 calc(1.25rem + env(safe-area-inset-left));
  height: 3.5rem;
  background: var(--pdv-surface);
  border-bottom: 0.0625rem solid var(--pdv-border);
  flex-shrink: 0;
}
.pdv-brand { display: flex; align-items: center; gap: 0.625rem; }
.pdv-logo { font-size: 1.375rem; }
.pdv-title { font-size: 1rem; font-weight: 700; color: var(--pdv-text); }
.pdv-label {
  background: var(--pdv-accent);
  color: #fff;
  font-size: 0.625rem;
  font-weight: 800;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  margin-left: 0.25rem;
  letter-spacing: 0.0625rem;
  vertical-align: middle;
}
.pdv-cash-status {
  flex: 1;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--pdv-text2);
}
.cash-open-tag { color: var(--pdv-green); font-weight: 600; }
.cash-closed-tag { color: var(--pdv-red); font-weight: 600; }
.pdv-header-actions { display: flex; gap: 0.375rem; }

/* ✅ ACESSIBILIDADE: Alvo de toque 44px (2.75rem) */
.btn-icon {
  background: var(--pdv-surface2);
  border: 0.0625rem solid var(--pdv-border);
  color: var(--pdv-text);
  width: 2.75rem; height: 2.75rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 1.125rem;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { background: var(--pdv-border); }

/* ── MAIN LAYOUT ───────────────────── */
.pdv-main {
  display: grid;
  grid-template-columns: 21.25rem 1fr 18.75rem;
  gap: 0;
  flex: 1;
  overflow: hidden;
}

/* ── COLUNA ESQUERDA ─────────────────────────── */
.pdv-search-panel {
  border-right: 0.0625rem solid var(--pdv-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--pdv-surface);
}
.search-box { padding: 0.75rem; border-bottom: 0.0625rem solid var(--pdv-border); }
.search-input {
  width: 100%;
  background: var(--pdv-bg);
  border: 0.0625rem solid var(--pdv-border);
  border-radius: 0.5rem;
  color: var(--pdv-text);
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--pdv-accent); }
.search-hint { display: block; font-size: 0.6875rem; color: var(--pdv-text2); margin-top: 0.375rem; }

.search-results {
  overflow-y: auto;
  max-height: 12.5rem;
  border-bottom: 0.0625rem solid var(--pdv-border);
}
.search-result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.625rem 0.875rem;
  cursor: pointer;
  border-bottom: 0.0625rem solid var(--pdv-border);
  transition: background 0.1s;
}
.search-result-item:hover { background: var(--pdv-surface2); }
.sri-name { font-size: 0.8125rem; font-weight: 500; }
.sri-meta { font-size: 0.6875rem; color: var(--pdv-text2); margin-top: 0.125rem; }
.sri-price { font-size: 0.875rem; font-weight: 700; color: var(--pdv-accent); white-space: nowrap; }
.sri-stock-low { color: var(--pdv-red) !important; }

.quick-products { flex: 1; overflow-y: auto; padding: 0.75rem; }
.quick-title { font-size: 0.6875rem; font-weight: 600; color: var(--pdv-text2); text-transform: uppercase; letter-spacing: 0.0625rem; margin-bottom: 0.5rem; }
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.375rem; }
.quick-item {
  background: var(--pdv-surface2);
  border: 0.0625rem solid var(--pdv-border);
  border-radius: 0.5rem;
  padding: 0.5rem 0.625rem;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.15s;
  text-align: left;
  color: var(--pdv-text);
  min-height: 3rem;
}
.quick-item:hover { border-color: var(--pdv-accent); background: var(--pdv-surface-hover); }
.quick-item-name { font-weight: 600; display: block; margin-bottom: 0.125rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quick-item-price { color: var(--pdv-accent); font-weight: 700; }

/* ── COLUNA CENTRO: CARRINHO ─────────────────── */
.pdv-cart-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.cart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.875rem 1.25rem;
  border-bottom: 0.0625rem solid var(--pdv-border);
}
.cart-header h3 { font-size: 0.9375rem; font-weight: 600; }
.btn-clear {
  background: none;
  border: 0.0625rem solid var(--pdv-red);
  color: var(--pdv-red);
  border-radius: 0.375rem;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-clear:hover { background: var(--pdv-red); color: #fff; }

.cart-items { flex: 1; overflow-y: auto; padding: 0.5rem 0; }
.cart-empty { text-align: center; color: var(--pdv-text2); padding: 3.75rem 1.25rem; font-size: 0.875rem; line-height: 1.6; }

.cart-item {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.625rem 1.25rem;
  border-bottom: 0.0625rem solid var(--pdv-border);
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(-0.25rem); } to { opacity: 1; } }
.ci-name { font-size: 0.8125rem; font-weight: 500; }
.ci-unit { font-size: 0.6875rem; color: var(--pdv-text2); margin-top: 0.125rem; }
.ci-qty { display: flex; align-items: center; gap: 0.375rem; }

/* ✅ ACESSIBILIDADE: Botões de quantidade maiores para toque */
.ci-qty-btn {
  background: var(--pdv-surface2);
  border: 0.0625rem solid var(--pdv-border);
  color: var(--pdv-text);
  width: 2.5rem; height: 2.5rem;
  border-radius: 0.375rem;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.1s;
}
.ci-qty-btn:hover { background: var(--pdv-accent); color: #000; }
.ci-qty-input {
  width: 3rem;
  height: 2.5rem;
  text-align: center;
  background: var(--pdv-surface2);
  border: 0.0625rem solid var(--pdv-border);
  color: var(--pdv-text);
  border-radius: 0.375rem;
  padding: 0.25rem;
  font-size: 0.8125rem;
}
.ci-disc { width: 3.75rem; }
.ci-disc-input {
  width: 100%;
  height: 2.5rem;
  background: var(--pdv-surface2);
  border: 0.0625rem solid var(--pdv-border);
  color: var(--pdv-text2);
  border-radius: 0.375rem;
  padding: 0.25rem 0.375rem;
  font-size: 0.75rem;
  text-align: center;
}
.ci-total { font-size: 0.875rem; font-weight: 700; color: var(--pdv-accent); min-width: 4.5rem; text-align: right; }
.ci-remove {
  background: none;
  border: none;
  color: var(--pdv-text2);
  cursor: pointer;
  width: 2.5rem; height: 2.5rem;
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.1s;
}
.ci-remove:hover { color: var(--pdv-red); }

.cart-footer { border-top: 0.0625rem solid var(--pdv-border); padding: 0.875rem 1.25rem; }
.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3125rem 0;
  font-size: 0.875rem;
  color: var(--pdv-text2);
}
.total-final { font-size: 1.5rem; font-weight: 800; color: var(--pdv-text); border-top: 0.0625rem solid var(--pdv-border); margin-top: 0.375rem; padding-top: 0.5rem; }
.discount-row { gap: 0.75rem; }
.discount-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--pdv-surface2);
  border: 0.0625rem solid var(--pdv-border);
  border-radius: 0.375rem;
  padding: 0.125rem 0.5rem;
  font-size: 0.8125rem;
}
#discount-amount {
  background: none;
  border: none;
  color: var(--pdv-text);
  width: 4.375rem;
  height: 2rem;
  font-size: 0.8125rem;
  outline: none;
}

/* ── COLUNA DIREITA: PAGAMENTO ───────────────── */
.pdv-payment-panel {
  border-left: 0.0625rem solid var(--pdv-border);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  background: var(--pdv-surface);
}
.pdv-payment-panel h3 { font-size: 0.9375rem; font-weight: 600; }

.payment-methods { display: grid; grid-template-columns: 1fr 1fr; gap: 0.375rem; }
.pay-btn {
  background: var(--pdv-surface2);
  border: 0.125rem solid var(--pdv-border);
  color: var(--pdv-text);
  border-radius: 0.5rem;
  padding: 0.625rem 0.375rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  min-height: 3rem;
}
.pay-btn.active { border-color: var(--pdv-accent); background: var(--pdv-accent-soft); color: var(--pdv-accent); }

.form-group { display: flex; flex-direction: column; gap: 0.375rem; }
.form-group label { font-size: 0.75rem; color: var(--pdv-text2); font-weight: 500; }
.form-group input {
  background: var(--pdv-surface2);
  border: 0.0625rem solid var(--pdv-border);
  border-radius: 0.5rem;
  color: var(--pdv-text);
  padding: 0.625rem 0.75rem;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
  height: 2.75rem;
}
.form-group input:focus { border-color: var(--pdv-accent); }
.amount-input { font-size: 1.25rem !important; font-weight: 700; text-align: center; }

.change-display {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--pdv-surface2);
  border: 0.0625rem solid var(--pdv-border);
  border-radius: 0.5rem;
  padding: 0.625rem 0.875rem;
  font-size: 0.8125rem;
  color: var(--pdv-text2);
}
.change-value { font-size: 1.25rem; font-weight: 800; color: var(--pdv-green); }

.payment-actions { display: flex; flex-direction: column; gap: 0.5rem; margin-top: auto; }
.btn { border: none; border-radius: 0.5rem; padding: 0.75rem 1rem; font-size: 0.875rem; font-weight: 600; cursor: pointer; transition: all 0.15s; min-height: 3rem; }
.btn-lg { padding: 0.875rem; font-size: 0.9375rem; width: 100%; }
.btn-primary { background: var(--pdv-blue); color: #fff; }
.btn-success { background: var(--pdv-green); color: #fff; }
.btn-danger { background: var(--pdv-red); color: #fff; }
.btn-secondary { background: var(--pdv-surface2); border: 0.0625rem solid var(--pdv-border); color: var(--pdv-text); }

.session-info { font-size: 0.6875rem; color: var(--pdv-text2); text-align: center; border-top: 0.0625rem solid var(--pdv-border); padding-top: 0.625rem; }

/* ── RESPONSIVIDADE ── */
@media (max-width: 1200px) {
  .pdv-main { grid-template-columns: 17.5rem 1fr 17.5rem; }
}

@media (max-width: 1024px) {
  .pdv-main { grid-template-columns: 1fr 18.75rem; }
  .pdv-search-panel { position: fixed; left: -100%; top: 3.5rem; bottom: 0; width: 18.75rem; z-index: 100; transition: left 0.3s; }
  .pdv-search-panel.active { left: 0; }
}

@media (max-width: 768px) {
  .pdv-main { grid-template-columns: 1fr; }
  .pdv-payment-panel { position: fixed; right: -100%; top: 3.5rem; bottom: 0; width: 20rem; z-index: 101; transition: right 0.3s; }
  .pdv-payment-panel.active { right: 0; }
}

/* ── MODAIS ──────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.75); display: none; align-items: center; justify-content: center; z-index: 1000;
}
.modal-overlay.active { display: flex; }
.modal-box {
  background: var(--pdv-surface);
  border: 0.0625rem solid var(--pdv-border);
  border-radius: 0.875rem;
  padding: 1.75rem;
  width: 100%;
  max-width: 26.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 1.25rem 3.75rem rgba(0,0,0,0.5);
  max-height: 90vh;
  overflow-y: auto;
}

.spinner {
  width: 1.25rem; height: 1.25rem;
  border: 0.1875rem solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-loading { pointer-events: none; opacity: 0.7; display: flex; align-items: center; justify-content: center; gap: 0.625rem; }

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