/* ═══════════════════════════════════════════════════════════════
   SURIAPP – POS / Sistema de Ventas (pos.css)
   ═══════════════════════════════════════════════════════════════ */

/* ─── POS LAYOUT ─── */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  height: calc(100vh - var(--topbar-h) - 80px);
  min-height: 500px;
}
@media (max-width: 1100px) {
  .pos-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
}

/* ─── PRODUCT SCANNER PANEL ─── */
.pos-scanner-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.pos-scanner-input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}
.pos-scanner-icon {
  position: absolute;
  left: 12px;
  color: var(--text3);
  font-size: 1rem;
  pointer-events: none;
  transition: color .18s;
}
.pos-scanner-input {
  width: 100%;
  background: var(--dark3);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 11px 14px 11px 40px;
  color: var(--text1);
  font-size: .9rem;
  font-family: 'DM Sans', sans-serif;
  transition: all .18s;
  outline: none;
}
.pos-scanner-input:focus {
  border-color: rgba(123,63,228,.5);
  box-shadow: 0 0 0 3px rgba(123,63,228,.1);
  background: var(--dark4);
}
.pos-scanner-input:focus ~ .pos-scanner-icon,
.pos-scanner-input-wrap:focus-within .pos-scanner-icon {
  color: var(--violet2);
}
.pos-scan-pulse {
  animation: scanPulse .8s ease-in-out infinite;
}
@keyframes scanPulse {
  0%,100% { opacity: 1; }
  50% { opacity: .4; }
}

/* ─── PRODUCT SEARCH RESULTS ─── */
.pos-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--dark2);
  border: 1px solid var(--border2);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,.4);
  z-index: 100;
  max-height: 260px;
  overflow-y: auto;
}
.pos-search-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background .12s;
  border-bottom: 1px solid var(--border);
}
.pos-search-item:last-child { border-bottom: none; }
.pos-search-item:hover { background: var(--dark3); }
.pos-search-item-img {
  width: 36px; height: 36px;
  border-radius: 6px;
  background: var(--dark4);
  object-fit: cover;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text3);
  font-size: .9rem;
}
.pos-search-item-name { font-size: .85rem; font-weight: 600; color: var(--text1); }
.pos-search-item-sku  { font-size: .72rem; color: var(--text3); }
.pos-search-item-price { font-size: .88rem; font-weight: 800; color: var(--sky); margin-left: auto; white-space: nowrap; }
.pos-search-item-stock-ok  { font-size: .7rem; color: var(--green); }
.pos-search-item-stock-low { font-size: .7rem; color: var(--gold); }
.pos-search-item-stock-out { font-size: .7rem; color: var(--red); }

/* ─── PRODUCT GRID ─── */
.pos-products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  overflow-y: auto;
  max-height: calc(100% - 130px);
  padding-right: 4px;
}
@media (max-width: 768px) {
  .pos-products-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
}
.pos-product-card {
  background: var(--dark3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 8px;
  cursor: pointer;
  transition: all .18s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  user-select: none;
}
.pos-product-card:hover {
  background: var(--dark4);
  border-color: rgba(123,63,228,.4);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
.pos-product-card:active { transform: translateY(0); }
.pos-product-card.out-of-stock { opacity: .45; cursor: not-allowed; }
.pos-product-card.out-of-stock:hover { transform: none; }
.pos-product-img {
  width: 52px; height: 52px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--dark4);
  display: flex; align-items: center; justify-content: center;
  color: var(--text3);
  font-size: 1.3rem;
}
.pos-product-name {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text1);
  line-height: 1.2;
  max-height: 2.4em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.pos-product-price {
  font-size: .78rem;
  font-weight: 800;
  color: var(--sky);
  font-family: 'Syne', sans-serif;
}
.pos-product-stock {
  font-size: .62rem;
  color: var(--text3);
}

/* ─── CART PANEL ─── */
.pos-cart-panel {
  background: var(--dark2);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
.pos-cart-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.pos-cart-title {
  font-family: 'Syne', sans-serif;
  font-size: .95rem;
  font-weight: 800;
  color: var(--text1);
  display: flex; align-items: center; gap: 8px;
}
.pos-cart-badge {
  background: var(--violet);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.pos-cart-clear-btn {
  border: none;
  background: rgba(239,68,68,.12);
  color: #f87171;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: .72rem;
  cursor: pointer;
  transition: all .15s;
}
.pos-cart-clear-btn:hover { background: rgba(239,68,68,.22); }

/* Cart items list */
.pos-cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}
.pos-cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 10px;
  color: var(--text3);
  font-size: .85rem;
}
.pos-cart-empty i { font-size: 2.5rem; opacity: .3; }

.pos-cart-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  background: var(--dark3);
  border: 1px solid var(--border);
  margin-bottom: 8px;
  transition: background .12s;
}
.pos-cart-item:hover { background: var(--dark4); }
.pos-cart-item-img {
  width: 38px; height: 38px;
  border-radius: 6px;
  background: var(--dark4);
  object-fit: cover;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text3); font-size: .9rem;
}
.pos-cart-item-info { flex: 1; min-width: 0; }
.pos-cart-item-name {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pos-cart-item-price-each { font-size: .7rem; color: var(--text3); }
.pos-cart-item-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.pos-qty-btn {
  width: 26px; height: 26px;
  border-radius: 6px;
  border: 1px solid var(--border2);
  background: var(--dark4);
  color: var(--text1);
  font-size: .85rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .12s;
  font-weight: 700;
}
.pos-qty-btn:hover { background: var(--violet); border-color: var(--violet); }
.pos-qty-display {
  min-width: 28px;
  text-align: center;
  font-size: .85rem;
  font-weight: 700;
  color: var(--text1);
}
.pos-cart-item-subtotal {
  font-size: .82rem;
  font-weight: 800;
  color: var(--sky);
  font-family: 'Syne', sans-serif;
  min-width: 60px;
  text-align: right;
  flex-shrink: 0;
}
.pos-cart-remove-btn {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(239,68,68,.12);
  color: #f87171;
  font-size: .7rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s;
  flex-shrink: 0;
}
.pos-cart-remove-btn:hover { background: rgba(239,68,68,.25); }

/* ─── CART FOOTER / TOTALS ─── */
.pos-cart-footer {
  border-top: 1px solid var(--border);
  padding: 14px 16px;
}
.pos-totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .82rem;
  color: var(--text2);
  margin-bottom: 5px;
}
.pos-totals-row.total-final {
  font-size: 1.1rem;
  font-weight: 800;
  font-family: 'Syne', sans-serif;
  color: var(--text1);
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 4px;
}
.pos-totals-row.total-final span:last-child { color: var(--sky); }

.pos-discount-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
}
.pos-discount-input {
  width: 70px;
  background: var(--dark3);
  border: 1px solid var(--border2);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: .78rem;
  color: var(--text1);
  outline: none;
  font-family: 'DM Sans', sans-serif;
}
.pos-discount-input:focus { border-color: rgba(123,63,228,.5); }

/* Payment method selector */
.pos-payment-methods {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 10px 0;
}
.pos-pay-btn {
  padding: 8px 4px;
  border-radius: 8px;
  border: 1px solid var(--border2);
  background: var(--dark3);
  color: var(--text2);
  font-size: .72rem;
  font-weight: 600;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  transition: all .15s;
}
.pos-pay-btn i { font-size: .9rem; }
.pos-pay-btn:hover { background: var(--dark4); color: var(--text1); }
.pos-pay-btn.selected {
  border-color: var(--violet);
  background: rgba(123,63,228,.15);
  color: var(--violet2);
}

.pos-confirm-btn {
  width: 100%;
  padding: 13px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, var(--violet), var(--sky));
  color: #fff;
  font-size: .92rem;
  font-weight: 700;
  font-family: 'Syne', sans-serif;
  cursor: pointer;
  margin-top: 10px;
  transition: all .2s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.pos-confirm-btn:hover { opacity: .9; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(123,63,228,.3); }
.pos-confirm-btn:active { transform: none; }
.pos-confirm-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ─── POS TABS ─── */
.pos-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background: var(--dark3);
  border-radius: 10px;
  padding: 4px;
}
.pos-tab {
  flex: 1;
  padding: 8px 12px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--text2);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s;
  display: flex; align-items: center; justify-content: center; gap: 5px;
}
.pos-tab.active {
  background: var(--dark1);
  color: var(--text1);
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

/* ─── TICKET MODAL ─── */
.ticket-box {
  background: #fff;
  color: #111;
  border-radius: 8px;
  padding: 20px;
  font-family: 'Courier New', monospace;
  font-size: .82rem;
}
.ticket-header { text-align: center; margin-bottom: 12px; }
.ticket-company { font-size: 1.1rem; font-weight: 900; }
.ticket-divider { border: none; border-top: 1px dashed #ccc; margin: 8px 0; }
.ticket-item-row { display: flex; justify-content: space-between; margin: 3px 0; }
.ticket-total-row { display: flex; justify-content: space-between; font-weight: 900; font-size: .95rem; }

/* ─── CATEGORY FILTER CHIPS ─── */
.pos-cat-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.pos-cat-chip {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border2);
  background: var(--dark3);
  color: var(--text2);
  font-size: .72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.pos-cat-chip:hover { background: var(--dark4); color: var(--text1); }
.pos-cat-chip.active {
  background: rgba(123,63,228,.18);
  border-color: rgba(123,63,228,.5);
  color: var(--violet2);
}

/* ─── SALE HISTORY TABLE enhancements ─── */
.sale-method-badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: .65rem;
  font-weight: 700;
}
.sale-method-efectivo    { background: rgba(34,197,94,.12); color: #4ade80; }
.sale-method-tarjeta     { background: rgba(41,182,246,.12); color: var(--sky); }
.sale-method-transferencia{ background: rgba(123,63,228,.12); color: var(--violet2); }

/* ─── LOW STOCK ALERT ─── */
.pos-low-stock-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(255,143,0,.1);
  border: 1px solid rgba(255,143,0,.25);
  border-radius: 8px;
  font-size: .78rem;
  color: #fbbf24;
  margin-bottom: 10px;
}