/* =========================================================
   ESTRUCTURA PRINCIPAL DEL PUNTO DE VENTA (POS)
   ========================================================= */
.pos-view {
  display: grid;
  grid-template-columns: 1fr 390px;
  gap: 0.85rem;
  height: 100%;
  padding: 0.75rem;
  overflow: hidden;
  position: relative;
}

@media (min-width: 1500px) {
  .pos-view {
    grid-template-columns: 1fr 430px;
    gap: 1rem;
    padding: 1rem;
  }
}

@media (max-width: 1080px) {
  .pos-view {
    grid-template-columns: 1fr 340px;
    gap: 0.65rem;
    padding: 0.5rem;
  }
}

@media (max-width: 820px) {
  .pos-view {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    overflow-y: auto;
  }
}

/* =========================================================
   COLUMNA IZQUIERDA: CATÁLOGO, BÚSQUEDA Y PRODUCTOS
   ========================================================= */
.pos-catalog-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* Barra de Búsqueda Rápida */
.pos-search-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-surface);
  padding: 0.65rem 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-xs);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.pos-search-bar:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
}

.pos-search-bar span {
  font-size: 1.1rem;
  opacity: 0.7;
}

.pos-search-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: var(--font-family);
  font-weight: 600;
  outline: none;
}

.pos-search-input::placeholder {
  color: var(--text-muted);
  font-weight: 500;
}

/* =========================================================
   BOTONES GRANDES Y REDONDEADOS DE CATEGORÍAS (Pills)
   ========================================================= */
.pos-categories-wrapper {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.35rem;
  scrollbar-width: thin;
  flex-shrink: 0;
}

.pos-cat-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 1.25rem;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-xs);
  user-select: none;
}

.pos-cat-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.pos-cat-btn.active {
  background: var(--primary-gradient);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(0, 123, 255, 0.4);
  transform: translateY(-1px);
}

.pos-cat-btn span {
  font-size: 1.15rem;
}

/* =========================================================
   GRID DE PRODUCTOS TÁCTIL Y RESPONSIVO
   ========================================================= */
.pos-products-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 0.75rem;
  overflow-y: auto;
  padding-right: 0.25rem;
  align-content: start;
}

@media (max-width: 600px) {
  .pos-products-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5rem;
  }
}

.pos-product-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.95rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 135px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-xs);
}

.pos-product-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  background: var(--bg-card-hover);
}

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

.pos-product-card.out-of-stock {
  opacity: 0.5;
  filter: grayscale(0.8);
  pointer-events: none;
}

.pos-product-card.out-of-stock::after {
  content: "🔴 AGOTADO";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-12deg);
  background: var(--danger);
  color: #ffffff;
  padding: 0.35rem 0.85rem;
  font-weight: 900;
  font-size: 0.85rem;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-lg);
  z-index: 5;
  letter-spacing: 0.04em;
}

.pos-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.pos-card-title {
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-primary);
  word-break: break-word;
}

.pos-badge-type {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
  flex-shrink: 0;
}

.pos-card-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.35rem;
}

.pos-card-price {
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--success);
  letter-spacing: -0.02em;
}

.pos-card-stock {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.pos-card-stock.stew-avail {
  color: var(--warning);
}

/* =========================================================
   COLUMNA DERECHA: CARRITO DE VENTA Y COBRO RÁPIDO
   ========================================================= */
.pos-cart-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.pos-cart-header {
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface-elevated);
  flex-shrink: 0;
}

.pos-cart-header h3 {
  font-size: 1.05rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

/* Selector de Tipo de Pedido */
.pos-order-type-selector {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.35rem;
  padding: 0.55rem 0.85rem;
  background: var(--bg-main);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.order-type-btn {
  padding: 0.45rem 0.2rem;
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.order-type-btn.active {
  background: var(--primary-gradient);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

/* Lista de Items en Carrito */
.pos-cart-items {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.pos-cart-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 0.65rem;
  padding: 2rem 1rem;
  text-align: center;
}

.pos-cart-empty svg {
  width: 52px;
  height: 52px;
  opacity: 0.35;
}

.cart-item-row {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  transition: border-color 0.2s;
}

.cart-item-row:hover {
  border-color: var(--primary);
}

.cart-item-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.cart-item-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.cart-item-remove-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  border-radius: var(--radius-xs);
  transition: all 0.15s;
  font-size: 0.95rem;
}

.cart-item-remove-btn:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

.cart-item-mods {
  font-size: 0.74rem;
  color: #d97706;
  font-weight: 600;
  padding-left: 0.4rem;
  border-left: 2px solid #d97706;
  line-height: 1.3;
}

.cart-item-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.2rem;
}

.cart-qty-stepper {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  padding: 0.15rem 0.3rem;
}

.stepper-btn {
  width: 26px;
  height: 26px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  color: var(--text-primary);
  font-weight: 800;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.stepper-btn:hover {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.stepper-value {
  font-weight: 800;
  font-size: 0.92rem;
  min-width: 24px;
  text-align: center;
}

.cart-item-price {
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--success);
}

/* Footer del Carrito y Botón de Cobro */
.pos-cart-footer {
  padding: 0.85rem 1.15rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-surface-elevated);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  flex-shrink: 0;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  font-size: 0.86rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.summary-total {
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
  padding-top: 0.35rem;
  border-top: 1px dashed var(--border-color);
}

.btn-checkout {
  padding: 0.9rem;
  font-size: 1.15rem;
  font-weight: 900;
  background: var(--primary-gradient);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 15px rgba(0, 123, 255, 0.4);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  letter-spacing: -0.01em;
}

.btn-checkout:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 123, 255, 0.5);
  filter: brightness(1.08);
}

.btn-checkout:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

/* =========================================================
   MODAL DE COBRO RÁPIDO & TECLADO DE BILLETES
   ========================================================= */
.quick-cash-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
  margin: 1rem 0;
}

.quick-cash-btn {
  padding: 0.8rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-primary);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.quick-cash-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.change-display-box {
  background: var(--bg-input);
  border: 2px solid var(--success);
  border-radius: var(--radius-lg);
  padding: 0.85rem 1.15rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 1rem 0;
}

.change-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.change-value {
  font-size: 1.75rem;
  font-weight: 900;
  color: var(--success);
}

/* Ticket de Venta Térmico */
.ticket-preview-box {
  background: #ffffff;
  color: #1e293b;
  font-family: var(--font-mono);
  padding: 1.25rem;
  border-radius: var(--radius-sm);
  max-width: 320px;
  margin: 0 auto;
  font-size: 0.82rem;
  box-shadow: var(--shadow-lg);
  line-height: 1.4;
}

.ticket-preview-box .text-center { text-align: center; }
.ticket-preview-box .text-right { text-align: right; }
.ticket-divider { border-top: 1px dashed #64748b; margin: 0.5rem 0; }

/* ================================================
   @media print — Solo el ticket, fondo blanco
   Compatible con impresora térmica 80mm
   ================================================ */
@media print {
  /* Ocultar todo excepto el contenido del ticket */
  body > *:not(#pos-modal-ticket) { display: none !important; }

  #pos-modal-ticket {
    display: block !important;
    position: static !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
  }

  .modal-box {
    box-shadow: none !important;
    border: none !important;
    max-width: 100% !important;
    padding: 0 !important;
  }

  .modal-header,
  .modal-footer { display: none !important; }

  .modal-body {
    background: #fff !important;
    padding: 0 !important;
  }

  .ticket-preview-box {
    box-shadow: none !important;
    max-width: 80mm !important;
    width: 80mm !important;
    font-size: 10pt !important;
    color: #000 !important;
    background: #fff !important;
    padding: 4mm !important;
    margin: 0 auto !important;
  }

  .ticket-preview-box img {
    max-width: 50mm !important;
    max-height: 25mm !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  @page {
    size: 80mm auto;
    margin: 4mm;
  }
}
