/* ============================================
   PDV Pro - Sistema de Caixa Profissional
   Tema escuro com botões coloridos
   ============================================ */

:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-tertiary: #252542;
  --bg-card: #1e1e36;
  --border: #2d2d4a;
  --text-primary: #e8e8f0;
  --text-secondary: #a0a0c0;
  --text-muted: #6b6b8a;
  --accent-blue: #4a9eff;
  --accent-green: #2ecc71;
  --accent-red: #e74c3c;
  --accent-orange: #f39c12;
  --accent-purple: #9b59b6;
  --accent-cyan: #00d4aa;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
  --radius: 12px;
  --radius-sm: 8px;
}

* {
  margin: 0; padding: 0; box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  font-size: 14px;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ========== TOPBAR ========== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.logo {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent-cyan);
  letter-spacing: 1px;
}

.topbar-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

.divider { color: var(--border); }

.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(46, 204, 113, 0.15);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block;
}

.status-dot.online { background: var(--accent-green); box-shadow: 0 0 6px var(--accent-green); }
.status-dot.offline { background: var(--accent-red); box-shadow: 0 0 6px var(--accent-red); }

.topbar-right {
  display: flex;
  gap: 8px;
}

.btn-topbar {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-topbar:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--accent-blue);
}

.btn-topbar.btn-danger {
  background: var(--accent-red);
  color: white;
  border-color: var(--accent-red);
}

.btn-topbar.btn-danger:hover {
  background: #c0392b;
}

/* ========== MAIN LAYOUT ========== */
.main {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 16px;
  padding: 16px;
  flex: 1;
  overflow: hidden;
}

/* ========== PANEL CART ========== */
.panel-cart {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(74, 158, 255, 0.15);
  color: var(--accent-blue);
}

.search-area {
  display: flex;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.search-area input {
  flex: 1;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.search-area input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.15);
}

.search-area input::placeholder {
  color: var(--text-muted);
}

.btn-search {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent-blue);
  color: white;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
  font-family: inherit;
  white-space: nowrap;
}

.btn-search:hover { opacity: 0.85; }

/* Quick Products */
.quick-products {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  max-height: 140px;
  overflow-y: auto;
}

.quick-btn {
  padding: 10px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.quick-btn:hover {
  background: var(--accent-blue);
  color: white;
  border-color: var(--accent-blue);
  transform: translateY(-1px);
}

.quick-btn .price {
  font-size: 11px;
  opacity: 0.7;
}

/* Cart Table */
.cart-table-header {
  display: grid;
  grid-template-columns: 1fr 80px 100px 100px 40px;
  padding: 10px 18px;
  background: var(--bg-tertiary);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cart-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 18px;
}

.empty-cart {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  gap: 8px;
}

.empty-icon { font-size: 48px; opacity: 0.5; }

.cart-item {
  display: grid;
  grid-template-columns: 1fr 80px 100px 100px 40px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s;
}

.cart-item:hover {
  background: rgba(255,255,255,0.02);
}

.cart-item-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.cart-item-name small {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 400;
}

.cart-item-qty {
  display: flex;
  align-items: center;
  gap: 6px;
}

.qty-btn {
  width: 26px; height: 26px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.qty-btn:hover {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
}

.cart-item-price, .cart-item-total {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  font-size: 14px;
  font-weight: 500;
  text-align: right;
}

.cart-item-total { color: var(--accent-cyan); }

.cart-item-del {
  opacity: 0;
  transition: opacity 0.2s;
  cursor: pointer;
  color: var(--accent-red);
  font-size: 18px;
  background: none;
  border: none;
  width: 28px; height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cart-item:hover .cart-item-del { opacity: 1; }
.cart-item-del:hover { background: rgba(231, 76, 60, 0.15); }

/* Cart Totals */
.cart-totals {
  padding: 16px 18px;
  border-top: 2px solid var(--border);
  background: var(--bg-tertiary);
}

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.total-row.grand-total {
  font-size: 26px;
  font-weight: 700;
  color: var(--accent-cyan);
  padding-top: 10px;
  margin-top: 6px;
  border-top: 1px solid var(--border);
}

.total-row span:last-child {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* ========== PANEL PAYMENT ========== */
.panel-payment {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pay-methods {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px 18px;
}

.pay-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 10px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  position: relative;
}

.pay-btn:hover {
  transform: translateY(-2px);
  border-color: var(--accent-blue);
}

.pay-btn.active {
  border-color: var(--accent-green);
  background: rgba(46, 204, 113, 0.1);
  color: var(--accent-green);
}

.pay-icon { font-size: 22px; }
.pay-label { font-size: 13px; font-weight: 600; }
.pay-key {
  position: absolute;
  top: 6px; right: 8px;
  font-size: 10px;
  padding: 2px 6px;
  background: var(--bg-card);
  border-radius: 4px;
  color: var(--text-muted);
}

/* Received Area */
.received-area {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.received-area label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.received-area input {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--bg-primary);
  color: var(--accent-green);
  font-size: 28px;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
  outline: none;
  font-family: inherit;
}

.troco-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 16px;
  color: var(--text-secondary);
}

.troco-valor {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-orange);
  font-variant-numeric: tabular-nums;
}

/* Numpad */
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}

.num-btn {
  padding: 18px 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.num-btn:hover {
  background: var(--bg-card);
  border-color: var(--accent-blue);
}

.num-btn:active {
  transform: scale(0.96);
}

.num-btn.btn-back {
  background: var(--accent-red);
  color: white;
  border-color: var(--accent-red);
}

.num-btn.btn-back:hover {
  background: #c0392b;
}

/* Action Buttons */
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}

.btn-action {
  padding: 14px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-action:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-action:active { transform: scale(0.98); }

.btn-cancel {
  background: var(--accent-red);
  color: white;
}

.btn-clear {
  background: var(--accent-orange);
  color: white;
}

.btn-finalize {
  background: var(--accent-green);
  color: white;
  font-size: 16px;
  padding: 16px;
}

/* Shortcuts */
.shortcuts {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-tertiary);
}

.shortcut-title {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 8px;
}

.shortcut-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.shortcut-list span {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

kbd {
  font-family: 'SF Mono', monospace;
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  font-size: 10px;
  color: var(--text-secondary);
}

/* ========== MODAL ========== */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.active { display: flex; }

.modal-content {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: var(--bg-tertiary);
  color: var(--accent-red);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

/* Relatório */
.relatorio-filters {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.relatorio-filters input {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-family: inherit;
}

.relatorio-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.rel-card {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 16px;
  border: 1px solid var(--border);
}

.rel-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.rel-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-cyan);
  font-variant-numeric: tabular-nums;
}

/* Config */
.config-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.config-item label:first-child {
  font-size: 14px;
  color: var(--text-secondary);
}

.config-item input[type="text"] {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-family: inherit;
  width: 200px;
}

.btn-primary {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent-blue);
  color: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  font-family: inherit;
}

.btn-primary:hover { opacity: 0.85; }

/* Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 50px; height: 26px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-card);
  border-radius: 26px;
  transition: 0.3s;
  border: 1px solid var(--border);
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px; width: 20px;
  left: 2px; bottom: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: 0.3s;
}

.switch input:checked + .slider {
  background: rgba(46, 204, 113, 0.3);
  border-color: var(--accent-green);
}

.switch input:checked + .slider:before {
  transform: translateX(24px);
  background: var(--accent-green);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  padding: 14px 24px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 14px;
  box-shadow: var(--shadow);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s;
  z-index: 2000;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success { border-left: 4px solid var(--accent-green); }
.toast.error { border-left: 4px solid var(--accent-red); }
.toast.warning { border-left: 4px solid var(--accent-orange); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Responsive */
@media (max-width: 1024px) {
  .main { grid-template-columns: 1fr; }
  .panel-payment { max-height: 500px; }
  .quick-products { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 768px) {
  .topbar { flex-direction: column; gap: 10px; }
  .topbar-right { flex-wrap: wrap; justify-content: center; }
  .quick-products { grid-template-columns: repeat(3, 1fr); }
  .relatorio-grid { grid-template-columns: repeat(2, 1fr); }
}