/* ================================
   Minimal base
================================ */
a { text-decoration: none !important; }

/* Page itself doesn't scroll; inner panes do */
html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

/* Optional brand helpers (remove if you theme elsewhere) */
.backColor { background: #2B3E65 !important; color: #fff !important; border: 0 !important; }
.textColor { color: #0d6efd !important; }
.bg-red { background:#dc3545 !important; color:#fff !important; }
.text-orange { color:#fd7e14 !important; }

/* ================================
   Cart panel (full viewport height with inner scroll)
   Optimized for 1024x768 kiosk displays
================================ */

/* If any old styles tried to cap width, override to full width */
.cart-panel { width: 100% !important; max-width: none !important; }

/* Card fills viewport; inner child becomes the scroller */
.cart-card{
  height: 100vh !important;      /* fits the whole screen */
  min-height: 0 !important;       /* critical for flex children to shrink */
  display: flex !important;
  flex-direction: column !important;
}

/* Header stays visible - COMPACT */
.cart-card > .card-header{
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 0.5rem 0.75rem !important; /* Reduced padding */
}

.cart-card > .card-header h6 {
  font-size: 0.9rem;
  margin: 0;
}

/* The ONLY scrolling region for list + table */
.cart-scroll{
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: 1rem; /* Add padding at bottom so last item is fully visible */
}

/* Footer (totals + methods) stays visible - COMPACT */
.cart-footer{
  flex-shrink: 0; /* Don't shrink, always visible */
  background: #fff;
  border-top: 1px solid #e9ecef;
  padding: 0.5rem !important; /* Reduced padding */
  margin-top: auto; /* Push to bottom in flexbox */
}

/* Optimize panel body for 1024x768 */
.kiosk-panel-body {
  padding: 0.5rem !important; /* Reduced from p-3 */
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.kiosk-panel-body #panelRoot {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.kiosk-panel-body .cart-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-bottom: 0 !important;
}

.kiosk-panel-body .cart-card {
  height: 100%;
  max-height: calc(100vh - 5rem); /* Account for header */
}

/* Optimize catalog body for 1024x768 */
.kiosk-catalog-body {
  padding: 0.5rem !important; /* Reduced from p-3 */
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.kiosk-catalog-body .container-fluid {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* Search bar compact for 1024x768 */
.kiosk-catalog-body #catalogSearchForm {
  flex-shrink: 0;
  margin-bottom: 0.75rem !important;
}

.kiosk-catalog-body #catalogSearchForm .card-body {
  padding: 0.5rem !important;
}

.kiosk-catalog-body #catalogSearchForm .input-group-lg .form-control {
  font-size: 1rem !important;
  padding: 0.5rem 0.75rem !important;
}

.kiosk-catalog-body #catalogSearchForm .input-group-lg .btn {
  font-size: 1rem !important;
  padding: 0.5rem 1rem !important;
}

/* Ensure products have proper bottom padding */
.kiosk-catalog-body .catalog-right .row {
  padding-bottom: 2rem; /* Extra space at bottom to see last row */
}

/* Topbar inside the list - COMPACT */
.cart-topbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:.5rem;
  padding:.4rem .75rem; /* Reduced padding */
  font-size: 0.9rem;
}

.cart-topbar strong {
  font-size: 1rem;
}

.cart-topbar .btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.9rem;
}

/* Make "Buscar Productos" button more prominent */
.cart-topbar .btn-primary {
  padding: 0.5rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(13, 110, 253, 0.3);
}

/* Make table head sticky while rows scroll in .cart-scroll */
.cart-table thead th{
  position: sticky;
  top: 0;            /* sticks to the top of .cart-scroll */
  background: #fff;
  z-index: 2;
}

/* Compact, readable table cells - OPTIMIZED FOR 1024x768 */
.cart-table th,
.cart-table td{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  padding: 0.35rem 0.5rem; /* Reduced padding for compact view */
  font-size: 0.85rem; /* Slightly smaller */
}

.cart-table thead th {
  font-size: 0.8rem;
  padding: 0.4rem 0.5rem;
}

/* Column widths - adjusted for bigger images and buttons */
.cart-col-product{ width:36%; }
.cart-col-qty    { width:32%; text-align:center; padding-left: 1rem; }
.cart-col-price  { width:18%; text-align:center; padding-left: 0.5rem; }
.cart-col-actions{ width:14%; text-align:center; }

/* Totals section - bigger font */
.cart-totals-list .list-group-item {
  font-size: 1rem !important;
  padding: 0.5rem 0.75rem !important;
}
.cart-totals-list .list-group-item span {
  font-weight: 500;
}

/* Row content - COMPACT */
.cart-prod{ display:flex; gap:10px; align-items:flex-start; }
.cart-item-thumb{ width:50px; height:50px; object-fit:contain; flex:0 0 50px; border-radius:6px; background:#fff; border:1px solid #eee; padding:2px; }
.cart-prod-info{ min-width:0; flex:1 1 auto; }
.cart-prod-title{ display:block; font-size:.9rem; line-height:1.2; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.cart-prod-info h6 { font-size: 0.9rem; margin-bottom: 0.15rem; line-height: 1.3; font-weight: 400; }
.cart-prod-info small { font-size: 0.8rem; line-height: 1.3; color: #666; }

/* Qty control - Touch-friendly */
.qty-input-group{ display:flex; flex-wrap:nowrap; width:120px; margin:0 auto; }
.qty-btn{
  padding:0 !important;
  width:40px !important;
  height:40px !important;
  display:flex;
  align-items:center;
  font-size: 1.25rem !important;
  justify-content:center;
  font-size:0.9rem !important; /* Smaller icon */
  line-height:1;
  cursor:pointer;
  user-select:none;
}
.qty-btn i{ pointer-events:none; }

/* >>> Ensure quantity number is visible <<< */
.qty-input-group .form-control,
input.showQuantity{
  height:40px !important;
  line-height:1.2 !important;
  padding:.2rem .4rem !important;
  font-size:1rem !important;
  text-align:center !important;
  color:#212529 !important;
  background:#fff !important;
  border:1px solid #ced4da !important;
}

/* Hide number spinners for a cleaner kiosk look */
input.showQuantity::-webkit-outer-spin-button,
input.showQuantity::-webkit-inner-spin-button{
  -webkit-appearance: none;
  margin: 0;
}
input.showQuantity{
  -moz-appearance: textfield;
}

/* Action button in last column */
.cart-col-actions .cart-action-btn{
  margin:0;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:32px;
  height:32px;
  padding:0;
}

/* If markup still has an inner .cart-table-scroll, neutralize nested scroll */
.cart-table-scroll{ max-height:none !important; overflow:visible !important; }

/* Ensure table doesn't have conflicting margins/padding */
.cart-scroll .cart-table {
  margin-bottom: 0 !important;
}

.cart-scroll .cart-table tbody tr:last-child td {
  padding-bottom: 0.5rem; /* Extra padding on last row */
}

/* ================================
   Catalog (categories + products) - responsive flexbox layout for 1024x768
================================ */
.kiosk-catalog-body .catalog-row {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  min-height: 0;
  overflow: hidden;
  margin: 0 !important;
}

.kiosk-catalog-body .catalog-left {
  flex: 0 0 auto;
  width: 25%;
  max-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 0.5rem;
}

.kiosk-catalog-body .catalog-right {
  flex: 1;
  min-width: 0;
  max-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-left: 0.5rem;
}

@media (max-width: 991px) {
  .kiosk-catalog-body .catalog-left,
  .kiosk-catalog-body .catalog-right {
    width: 100%;
    max-height: 50vh;
  }
}

/* ================================
   PORTRAIT MODE (768x1024 or similar vertical screens)
   Horizontal scrolling categories + full-height products
================================ */
@media (max-width: 850px) and (min-height: 900px),
       (orientation: portrait) and (min-height: 900px) {
  
  /* Container adjustments */
  .kiosk-catalog-body {
    padding: 0.25rem !important;
  }
  
  .kiosk-catalog-body .container-fluid {
    padding: 0 0.5rem;
  }
  
  /* Search bar more compact */
  .kiosk-catalog-body #catalogSearchForm {
    margin-top: 0.5rem !important;
    margin-bottom: 0.5rem !important;
  }
  
  .kiosk-catalog-body #catalogSearchForm .card {
    margin: 0 auto;
    max-width: 100%;
  }
  
  /* Catalog row - vertical stack */
  .kiosk-catalog-body .catalog-row {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  /* Categories: horizontal scrolling bar */
  .kiosk-catalog-body .catalog-left {
    width: 100%;
    max-height: none;
    overflow: visible;
    padding: 0;
    flex-shrink: 0;
  }
  
  .kiosk-catalog-body .catalog-left .cat-card {
    border-radius: 0.5rem;
  }
  
  .kiosk-catalog-body .catalog-left .cat-card .card-header {
    display: none; /* Hide "Categorías" header in portrait */
  }
  
  .kiosk-catalog-body .catalog-left .list-group {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 0.5rem;
    padding: 0.5rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    background: #f8f9fa;
    border-radius: 0.5rem;
  }
  
  .kiosk-catalog-body .catalog-left .list-group::-webkit-scrollbar {
    display: none;
  }
  
  .kiosk-catalog-body .catalog-left .list-group-item {
    flex: 0 0 auto !important;
    width: auto !important;
    max-width: none !important;
    display: inline-flex !important;
    align-items: center;
    white-space: nowrap;
    border-radius: 2rem !important;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    border: 1px solid #dee2e6 !important;
    margin: 0;
    background: white;
  }
  
  .kiosk-catalog-body .catalog-left .list-group-item.active {
    background-color: var(--bs-primary, #0d6efd);
    border-color: var(--bs-primary, #0d6efd) !important;
    color: white;
  }
  
  .kiosk-catalog-body .catalog-left .list-group-item img {
    width: 18px !important;
    height: 18px !important;
    margin-right: 4px !important;
  }
  
  /* Products: take remaining space with proper scroll */
  .kiosk-catalog-body .catalog-right {
    width: 100%;
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    padding: 0 0.25rem;
    padding-bottom: 1rem; /* Extra padding at bottom */
  }
  
  /* Product grid: 2 columns for portrait */
  .kiosk-catalog-body .catalog-right .row {
    padding-bottom: 4rem !important; /* Ensure last row is fully visible */
  }
  
  /* Product cards in portrait - bigger images */
  .kiosk-catalog-body .prod-card .card-body {
    padding: 0.5rem !important;
  }
  
  .kiosk-catalog-body .prod-card .card-body > .mb-2:first-child {
    height: 130px;
  }
  
  .kiosk-catalog-body .prod-card .prod-thumb {
    max-height: 120px;
  }
  
  .kiosk-catalog-body .prod-card .fw-semibold {
    font-size: 0.8rem;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  
  .kiosk-catalog-body .prod-card .price-small {
    font-size: 0.8rem !important;
  }
  
  .kiosk-catalog-body .prod-card .btn {
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
  }
  
  /* Products header more compact */
  .kiosk-catalog-body .catalog-right > .d-flex.align-items-center {
    margin-bottom: 0.5rem !important;
  }
  
  .kiosk-catalog-body .catalog-right h5 {
    font-size: 1rem;
  }
  
  /* Cart panel - bigger in portrait */
  .cart-item-thumb {
    width: 70px !important;
    height: 70px !important;
    flex: 0 0 70px !important;
  }
  
  .cart-prod {
    gap: 12px;
  }
  
  .cart-prod-info h6 {
    font-size: 0.95rem !important;
    font-weight: 400 !important;
  }
  
  .cart-prod-info small {
    font-size: 0.85rem !important;
  }
  
  .cart-prod-title {
    font-size: 0.95rem !important;
  }
  
  /* Bigger search button in portrait */
  .cart-topbar .btn-primary {
    padding: 0.6rem 1.25rem !important;
    font-size: 1.1rem !important;
  }
  
  /* Bigger quantity buttons in portrait */
  .qty-input-group {
    width: 140px !important;
  }
  
  .qty-btn {
    width: 48px !important;
    height: 48px !important;
    font-size: 1.5rem !important;
  }
  
  .qty-input-group .form-control,
  input.showQuantity {
    height: 48px !important;
    font-size: 1.1rem !important;
  }
}


/* Product cards - Compact size (similar to 80% zoom at 1024x768) */
.prod-card{ 
  box-shadow: 0 2px 12px rgba(0,0,0,.05); 
  border-radius:.5rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  font-size: 0.85rem; /* Reduce base font size by ~15% */
}
.prod-card:hover{
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,.1);
}

/* Reduce card body padding for more compact cards */
.prod-card .card-body {
  padding: 0.6rem !important;  /* Reduced from 0.75rem (~20% smaller) */
}

/* Image container with consistent height (first .mb-2 in card-body is the image wrapper) */
.prod-card .card-body > .mb-2:first-child {
  height: 110px;  /* Reduced from 140px (~22% smaller) */
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Product image sizing */
.prod-card .prod-thumb {
  max-height: 100px;
  max-width: 100%;
  object-fit: contain;
}

/* Product title - smaller font */
.prod-card .fw-semibold {
  font-size: 0.9rem;
  line-height: 1.3;
}

/* Price section - smaller */
.prod-card .price-small {
  font-size: 0.85rem !important;
}

/* Discount badge - smaller */
.prod-card .badge {
  font-size: 0.7rem;
  padding: 0.2rem 0.4rem;
}

/* Add to cart button - more compact */
.prod-card .btn {
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
}

/* Show the whole image without cropping */
.prod-thumb{
  width:100%;
  max-height:100px;  /* Reduced from 140px to match new compact card size */
  object-fit: contain;          /* shows full image without cropping */
  background:#fff;              /* neutral backdrop */
  border:1px solid #eee;        /* light frame so transparent PNGs look OK */
  border-radius:.5rem;
  padding:5px;                  /* breathing room for contain */
}
.price-small{ font-size:.85rem; } /* Reduced from .95rem for compact cards */

/* ================================
   Kiosk inputs
================================ */
.kioskboard-input,
#scanInput,
#scanInputPanel{
  font-size:15px;
  padding:.45rem .75rem;
  border-radius:.5rem;
}

/* Reduce on-screen keyboard height */
#KioskBoard-VirtualKeyboard .kioskboard-key {
  height: 40px !important;
  min-height: 40px !important;
  max-height: 40px !important;
  font-size: 14px !important;
  padding: 6px !important;
  margin: 1px !important;
}

#KioskBoard-VirtualKeyboard .kioskboard-row {
  margin-bottom: 1px !important;
}

#KioskBoard-VirtualKeyboard {
  padding: 6px !important;
}

/* ----- Kiosk header (shared) ----- */
.kiosk-header {
  position: sticky;
  top: 0;
  z-index: 1050;
  flex-shrink: 0; /* Don't shrink in flexbox layouts */
}

/* Ensure header container doesn't inherit body flexbox */
.kiosk-header .container-fluid {
  display: flex !important;
  flex-direction: row !important;
  justify-content: space-between !important;
  align-items: center !important;
  max-width: 100% !important;
  width: 100% !important;
}
.kiosk-nav-link:hover { text-decoration: underline; }
.kiosk-badge {
  display: inline-block; min-width: 20px; padding: 1px 6px; border-radius: 999px;
  background: #0d6efd; color: #fff; font-size: 12px; text-align: center; margin-left: 6px;
}

/* Removed old padding - now using flexbox layout */

/* Optional: product card add button padding — no longer needed with top toasts,
   but keep a bit of breathing room at the card bottom */
.prod-card .btn.btn-primary { margin-left: 6px; }

/* ---- Kiosk catalog: smooth swaps ---- */
#catalogProducts {
  position: relative;
  transition: opacity 300ms ease-in-out, filter 300ms ease-in-out;
}

/* Fade + desaturate while loading new products */
#catalogProducts.is-loading {
  opacity: 0.3;
  filter: saturate(0.7);
  pointer-events: none;
}

/* Optional: gentle "pop" animation on product cards */
#catalogProducts .prod-card {
  will-change: opacity, transform;
  transition: opacity 200ms ease, transform 200ms ease;
}
#catalogProducts .prod-card.fade-enter {
  opacity: 0;
  transform: translateY(8px);
}
#catalogProducts .prod-card.fade-enter.fade-enter-active {
  opacity: 1;
  transform: translateY(0);
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  #catalogProducts,
  #catalogProducts .prod-card {
    transition: none !important;
  }
}

/* Subtle spinner centered in the pane */
#catalogProducts.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;
  height: 32px;
  margin: -16px 0 0 -16px;
  border: 3px solid rgba(0,0,0,0.15);
  border-top-color: rgba(0,0,0,0.45);
  border-radius: 50%;
  animation: kioskspin 0.8s linear infinite;
  z-index: 2;
}

@keyframes kioskspin { to { transform: rotate(360deg); } }

/* Smooth “pop in” for product cards (used by catalog_live.js) */
.prod-card.fade-enter { opacity: 0; transform: translateY(4px); }
.prod-card.fade-enter.fade-enter-active {
  opacity: 1;
  transform: none;
  transition: opacity .22s ease, transform .22s ease;
}
