/* ============================================================
   productos.css — Estilos para gestión de productos
   Estilo: moderno, minimalista, estilo AliExpress/Amazon
   ============================================================ */

/* ─── Variables ──────────────────────────────────────────── */
:root {
    --prod-card-radius: 16px;
    --prod-shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
    --prod-shadow-hover: 0 12px 32px rgba(15, 23, 42, 0.14);
    --prod-accent: #f57c11;
    --prod-accent-soft: rgba(245, 124, 17, 0.12);
    --prod-bg: #ffffff;
    --prod-border: rgba(15, 23, 42, 0.07);
    --prod-text: #0f172a;
    --prod-muted: #64748b;
    --prod-success: #22c55e;
    --prod-danger: #ef4444;
    --prod-warning: #f59e0b;
}

/* ─── QR Scanner Modal ──────────────────────────────────── */
.qr-scanner-viewport {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    background: #000;
}

.qr-scanner-viewport video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.qr-scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.qr-scanner-frame {
    position: absolute;
    top: 15%;
    left: 15%;
    width: 70%;
    height: 70%;
    border: 2px solid rgba(245, 124, 17, 0.6);
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.4);
}

.qr-scanner-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #f57c11, transparent);
    animation: qrScanLine 2s ease-in-out infinite;
}

@keyframes qrScanLine {
    0% { top: 0; }
    50% { top: 100%; }
    100% { top: 0; }
}

/* ─── QR Display en cards y tablas ───────────────────────── */
.producto-qr-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.04);
    color: var(--prod-muted);
    font-size: 0.65rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.producto-qr-badge:hover {
    background: var(--prod-accent-soft);
    color: var(--prod-accent);
}

.producto-qr-badge .material-icons {
    font-size: 0.85rem;
}

/* ─── Botón escanear en toolbar ─────────────────────────── */
.btn-scan-qr {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    border-radius: 12px;
    border: 1px solid var(--prod-border);
    background: var(--prod-bg);
    color: var(--prod-text);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-scan-qr:hover {
    border-color: var(--prod-accent);
    background: var(--prod-accent-soft);
    color: var(--prod-accent);
}

.btn-scan-qr .material-icons {
    font-size: 1.1rem;
}

/* ─── Productos Grid ─────────────────────────────────────── */
.productos-grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

/* ─── Card Principal ─────────────────────────────────────── */
.producto-card {
    background: var(--prod-bg);
    border: 1px solid var(--prod-border);
    border-radius: var(--prod-card-radius);
    box-shadow: var(--prod-shadow);
    transition: box-shadow 0.25s ease, transform 0.25s ease;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.producto-card:hover {
    box-shadow: var(--prod-shadow-hover);
    transform: translateY(-4px);
}

/* ─── Imagen del producto (4:3 aspect ratio) ────────────── */
.producto-imagen {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #f0f2f5;
    background-image: 
        radial-gradient(circle at 25% 25%, rgba(15, 23, 42, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, rgba(245, 124, 17, 0.04) 0%, transparent 50%);
    overflow: hidden;
    cursor: pointer;
}

.producto-imagen-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--prod-muted);
    font-size: 4rem;
}

/* Badges sobre la imagen */
.producto-badges {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    z-index: 10;
}

.badge-promo {
    background: var(--prod-danger);
    color: white;
    padding: 0.35rem 0.65rem;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.badge-original {
    position: absolute;
    top: 0.75rem;
    right: 0;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #78350f;
    padding: 0.35rem 0.7rem;
    border-radius: 8px 0 0 8px;
    font-size: 0.7rem;
    font-weight: 700;
    box-shadow: 0 2px 12px rgba(245, 158, 11, 0.4);
    letter-spacing: 0.02em;
}

.badge-descuento-pago {
    background: var(--prod-success);
    color: white;
    padding: 0.35rem 0.65rem;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3);
}

.badge-stock-bajo {
    background: var(--prod-warning);
    color: white;
    padding: 0.35rem 0.65rem;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.producto-card.oculto-cliente {
    background: #f1f3f5;
    border-color: #dee2e6;
}

.producto-card.oculto-cliente:hover {
    box-shadow: var(--prod-shadow);
    transform: none;
}

.producto-card.oculto-cliente .producto-imagen {
    filter: grayscale(0.65) brightness(1.03);
}

.producto-card.oculto-cliente .producto-body {
    opacity: 0.7;
}

.producto-card.oculto-cliente .producto-titulo,
.producto-card.oculto-cliente .producto-marca {
    color: var(--prod-text);
    opacity: 0.6;
}

.producto-card.oculto-cliente .producto-precio-final {
    color: var(--prod-muted);
}

.btn-prod-visibilidad {
    color: #6366f1;
    border-color: rgba(99, 102, 241, 0.3);
}

.btn-prod-visibilidad:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: #6366f1;
}

/* ─── Body del Card ──────────────────────────────────────── */
.producto-body {
    padding: 0.85rem 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* SKU */
.producto-sku {
    font-size: 0.7rem;
    color: var(--prod-muted);
    font-weight: 600;
    letter-spacing: 0.05em;
    margin-bottom: 0.35rem;
    text-transform: uppercase;
}

/* Marca */
.producto-marca {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--prod-accent);
    margin-bottom: 0.15rem;
    line-height: 1.2;
}

/* Título (Nombre del producto) */
.producto-titulo {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--prod-text);
    line-height: 1.25;
    margin-bottom: 0.15rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Proveedor badge */
.producto-proveedor {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.7rem;
    color: var(--prod-muted);
    font-weight: 600;
    margin-bottom: 0.35rem;
    padding: 0.15rem 0.5rem;
    background: rgba(15, 23, 42, 0.04);
    border-radius: 6px;
    width: fit-content;
    min-height: 22px;
    height: 22px;
}

.producto-proveedor .material-icons {
    font-size: 0.85rem;
    color: var(--prod-accent);
}

/* ─── Tabla de inventario por lotes en productos ────────── */
.prod-lotes-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.78rem;
    margin-top: 0.5rem;
}

.prod-lotes-table th {
    padding: 0.4rem 0.6rem;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--prod-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid var(--prod-border);
}

.prod-lotes-table td {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--prod-border);
    vertical-align: middle;
}

.prod-lotes-table tr:last-child td {
    border-bottom: none;
}

.prod-lotes-table tr:hover td {
    background: rgba(245, 124, 17, 0.03);
}

.prod-lote-progress {
    height: 5px;
    border-radius: 3px;
    background: var(--prod-border);
    overflow: hidden;
    min-width: 50px;
}

.prod-lote-progress-bar {
    height: 100%;
    border-radius: 3px;
    background: var(--prod-accent);
    transition: width 0.5s ease;
}

/* ─── Acordeón FIFO ──────────────────────────── */
.lotes-section {
    max-height: 500px;
    overflow-y: auto;
}

.lotes-seccion-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--prod-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--prod-border);
    margin-bottom: 0.25rem;
}
.lotes-seccion-header .material-icons {
    font-size: 1.1rem;
    color: var(--prod-accent);
}

.lote-accordion-item {
    border: 1px solid var(--prod-border) !important;
    border-radius: 10px !important;
    margin-bottom: 0.4rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: box-shadow 0.2s ease;
}
.lote-accordion-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.lote-simple-card {
    padding: 0 !important;
    cursor: default;
    border: 1px solid var(--prod-border) !important;
    border-radius: 10px !important;
    margin-bottom: 0.4rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    background: linear-gradient(135deg, #fafafa, #f5f5f5);
    transition: box-shadow 0.2s ease;
}
.lote-simple-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.lote-simple-card .d-flex {
    background: transparent;
    border-radius: 10px;
}

.lote-accordion-header {
    margin: 0;
}

.lote-accordion-btn {
    padding: 0.6rem 0.9rem !important;
    font-size: 0.82rem !important;
    background: linear-gradient(135deg, #fafafa, #f5f5f5) !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 10px !important;
    transition: background 0.2s ease;
}
.lote-accordion-btn:not(.collapsed) {
    background: linear-gradient(135deg, #fff8f0, #fff3e0) !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}
.lote-accordion-btn:focus {
    box-shadow: none !important;
}
.lote-accordion-btn::after {
    display: none !important;
}

.lote-icono-header {
    font-size: 1.1rem;
    color: var(--prod-accent);
}

.lote-pres-header {
    color: #333;
    font-size: 0.85rem;
}
.lote-accordion-btn:not(.collapsed) .lote-pres-header {
    color: var(--prod-accent);
}

.lote-cant-header {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
}

.lote-unds-header {
    font-size: 0.7rem;
    font-weight: 600;
}

.lote-expand-icon {
    font-size: 1.2rem;
    color: #999;
    transition: transform 0.3s ease;
}
.lote-accordion-btn:not(.collapsed) .lote-expand-icon {
    transform: rotate(180deg);
    color: var(--prod-accent);
}

.lote-accordion-body {
    padding: 0.6rem 0.9rem !important;
    background: white;
    border-top: 1px solid var(--prod-border);
}

/* Subtabla dentro del acordeón */
.lote-subtable {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}
.lote-subtable th {
    padding: 0.3rem 0.5rem;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--prod-muted);
    text-transform: uppercase;
    border-bottom: 1px solid var(--prod-border);
    background: #fafafa;
}
.lote-subtable td {
    padding: 0.3rem 0.5rem;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}
.lote-subtable tbody tr:last-child td {
    border-bottom: none;
}

.lote-fila-padre {
    background: rgba(245, 124, 17, 0.06);
}
.lote-fila-padre td {
    border-bottom: 2px solid rgba(245, 124, 17, 0.15) !important;
}

.lote-fila-hijo td {
    padding-left: 1.8rem !important;
    color: #666;
    font-size: 0.72rem;
}

.lote-pres-col {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.lote-icono-primario {
    font-size: 1rem;
    color: var(--prod-accent);
}

.lote-pres-nombre {
    color: var(--prod-accent-dark, #cc6a0a);
}

.lote-unds-col {
    font-weight: 600;
    font-size: 0.7rem;
}

.lote-consumo-col {
    min-width: 100px;
}

.lotes-footer {
    font-size: 0.78rem;
}

/* ─── Separador y subtotal en tabla FIFO ─────────────────── */
.prod-lote-separator td {
    background: rgba(15, 23, 42, 0.04);
    padding: 0.5rem 0.6rem 0.3rem !important;
    border-bottom: 2px solid var(--prod-border) !important;
    font-size: 0.78rem;
    letter-spacing: 0.02em;
}

.prod-lote-subtotal td {
    background: rgba(245, 124, 17, 0.04);
    padding: 0.35rem 0.6rem !important;
    border-top: 2px solid rgba(245, 124, 17, 0.15);
    font-size: 0.72rem;
    color: var(--prod-muted);
}

/* Descripción */
.producto-descripcion {
    font-size: 0.78rem;
    color: var(--prod-text);
    line-height: 1.35;
    margin-bottom: 0.65rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 2.4em;
    min-height: 2.4em;
}

/* Garantía */
.producto-garantia {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.7rem;
    color: var(--prod-success);
    margin-bottom: 0.5rem;
}

.producto-garantia .material-icons {
    font-size: 0.9rem;
}

/* ─── Presentaciones (estilo píldoras, fila + flechas a los lados) ─────────── */
.producto-presentaciones {
    margin-bottom: 0.65rem;
    min-height: 32px;
    max-height: 48px;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 6px;             /* ← flecha | píldoras | flecha → */
}

.presentaciones-pills {
    flex: 1 1 auto;
    min-width: 0;                  /* permite que la fila scrollable encoga (el resto lo ocupan las flechas) */
    display: flex;
    flex-wrap: nowrap;             /* 1 sola fila: lo que no cabe se NAVEGA (antes se escondía) */
    gap: 0.4rem;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scrollbar-width: none;         /* sin scrollbar: navega con las flechas */
    -ms-overflow-style: none;
}
.presentaciones-pills::-webkit-scrollbar { display: none; }

/* La píldora NO se parte en 2 líneas ni se encoge: con 5+ presentaciones el
   contenido DESENBORDA y lo navega el scroll + flechas (no desaparece) */
.presentaciones-pills .presentacion-pill { white-space: nowrap; flex-shrink: 0; }

/* ─── Flechas de navegación de presentaciones (discretas, solo si hay overflow) ─
   FUERA del área scrollable de las píldoras (lane propio a cada lado, dentro de la card):
   fondo oscuro como la píldora activa (#334155) con icono blanco para resaltarlas. */
.pres-nav {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    border-radius: 6px;
    background: #334155;
    border: none;
    display: none;                 /* JS las activa (.on) cuando hay más contenido de ese lado */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.9;
    transition: opacity 0.15s ease, background 0.15s ease;
    user-select: none;
}
.pres-nav.on { display: flex; }
.pres-nav:hover { opacity: 1; background: #1e293b; }
.pres-nav .material-icons { font-size: 14px; color: #fff; pointer-events: none; }

.presentacion-pill {
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    border: 1.5px solid var(--prod-border);
    background: var(--prod-bg);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--prod-text);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.presentacion-pill:hover {
    border-color: #475569;
    background: rgba(71, 85, 105, 0.1);
}

.presentacion-pill.active {
    border-color: #334155;
    background: #334155;
    color: white;
}

/* Píldora SIN STOCK: gris oscuro, se ve deshabilitada (no seleccionable) */
.presentacion-pill.sin-stock,
.presentacion-pill.sin-stock:hover,
.presentacion-pill.sin-stock.active {
    border-color: #475569;
    background: #475569;
    color: rgba(255, 255, 255, 0.55);
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.85;
}

/* ─── Precio ─────────────────────────────────────────────── */
.producto-precio-container {
    padding: 0.7rem 0.8rem;
    background: rgba(15, 23, 42, 0.03);
    border-radius: 10px;
    margin-bottom: 0.65rem;
}

.producto-precio-original {
    font-size: 0.75rem;
    color: var(--prod-muted);
    text-decoration: line-through;
    margin-bottom: 0.15rem;
}

.producto-precio-final {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--prod-accent);
    line-height: 1;
}

.producto-precio-final.con-promo {
    color: var(--prod-danger);
}

.producto-precio-ahorro {
    font-size: 0.7rem;
    color: var(--prod-success);
    font-weight: 600;
    margin-top: 0.25rem;
}

/* Precio NO DISPONIBLE (presentación sin stock) */
.producto-precio-no-disponible {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #94a3b8;
}

.producto-precio-no-disponible .material-icons {
    font-size: 1rem;
}

/* ─── Footer / Acciones ──────────────────────────────────── */
.producto-footer {
    padding: 0 1.25rem 1rem;
    display: flex;
    gap: 0.4rem;
    margin-top: auto;
}

.btn-prod {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.45rem 0.65rem;
    border-radius: 8px;
    font-size: 0.72rem;
    font-weight: 600;
    border: 1px solid var(--prod-border);
    background: transparent;
    color: var(--prod-text);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-prod .material-icons {
    font-size: 0.9rem;
}

.btn-prod:hover {
    background: rgba(15, 23, 42, 0.06);
    border-color: rgba(15, 23, 42, 0.15);
}

.btn-prod-primary {
    background: var(--prod-accent);
    border-color: var(--prod-accent);
    color: white;
    flex: 1;
}

.btn-prod-primary:hover {
    background: #e06e00;
    border-color: #e06e00;
    color: white;
}

.btn-prod-icon {
    flex: 0;
    width: 32px;
    height: 32px;
    padding: 0;
}

.btn-prod-warning {
    color: var(--prod-warning);
    border-color: rgba(245, 158, 11, 0.3);
}

.btn-prod-warning:hover {
    background: rgba(245, 158, 11, 0.1);
    border-color: var(--prod-warning);
}

.btn-prod-danger {
    color: var(--prod-danger);
    border-color: rgba(239, 68, 68, 0.3);
}

.btn-prod-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--prod-danger);
}

/* ─── Toolbar compacto ────────────────────────────────────── */
.productos-toolbar {
    margin-bottom: 1.25rem;
}

.productos-filtros {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
}

/* Wrapper del buscador (icono + input) */
.search-wrapper {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-wrapper .search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1rem;
    color: var(--prod-muted);
    pointer-events: none;
    z-index: 2;
}

.search-wrapper .search-input {
    width: 100%;
    padding: 0.45rem 0.85rem 0.45rem 2.2rem;
    font-size: 0.82rem;
    border: 1px solid var(--prod-border);
    border-radius: 10px;
    background: var(--prod-bg);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-wrapper .search-input:focus {
    border-color: var(--prod-accent);
    box-shadow: 0 0 0 3px var(--prod-accent-soft);
    outline: none;
}

.search-wrapper .search-input::placeholder {
    color: #94a3b8;
    font-size: 0.78rem;
}

/* Contenedor de acciones (selects, moneda, botón) */
.filtros-acciones {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

/* Selects compactos */
.filtro-select {
    padding: 0.35rem 1.6rem 0.35rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid var(--prod-border);
    border-radius: 8px;
    background: var(--prod-bg);
    color: var(--prod-text);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    min-height: 32px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.filtro-select:hover {
    border-color: #94a3b8;
}

.filtro-select:focus {
    border-color: var(--prod-accent);
    box-shadow: 0 0 0 2px var(--prod-accent-soft);
    outline: none;
}

/* Píldoras de moneda */
.moneda-pills {
    display: flex;
    align-items: center;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--prod-border);
    background: var(--prod-bg);
}

.moneda-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    padding: 0.32rem 0.49rem;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    border: none;
    background: transparent;
    color: var(--prod-muted);
    line-height: 1;
}

/* 🔎 Iconos 2px más grandes (21 → 23px) manteniendo el ancho del switch:
   se compensa restando padding horizontal a la píldora */
.moneda-icono {
    display: block;
    width: 23px;
    height: 23px;
    transition: transform 0.2s ease;
}

.moneda-pill:not(:last-child) {
    border-right: 1px solid var(--prod-border);
}

.moneda-pill:hover {
    background: rgba(15, 23, 42, 0.04);
    color: var(--prod-text);
}

.moneda-pill:hover .moneda-icono {
    transform: scale(1.12);
}

.moneda-pills .btn-check:checked + .moneda-pill {
    background: var(--prod-accent);
    color: white;
    border-color: var(--prod-accent);
}

.moneda-pills .btn-check:checked + .moneda-pill:not(:last-child) {
    border-right-color: var(--prod-accent);
}

.moneda-pills .btn-check:checked + .moneda-pill .moneda-icono {
    color: #fff;
}

/* Botón icono de gestión categorías */
.filtro-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--prod-border);
    border-radius: 8px;
    background: var(--prod-bg);
    color: var(--prod-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.filtro-icon-btn:hover {
    border-color: var(--prod-accent);
    background: var(--prod-accent-soft);
    color: var(--prod-accent);
}

.filtro-icon-btn .material-icons {
    font-size: 1.1rem;
}

/* Categorías badges en detalles */
.categoria-item {
    transition: background 0.2s ease;
}

.categoria-item:hover {
    background: rgba(15, 23, 42, 0.04);
}

.categorias-lista {
    max-height: 300px;
    overflow-y: auto;
}

/* ─── Loading ────────────────────────────────────────────── */
.productos-loading {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem;
    color: var(--prod-muted);
}

.productos-loading .spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--prod-border);
    border-top-color: var(--prod-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ─── Empty State ────────────────────────────────────────── */
.productos-empty {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    color: var(--prod-muted);
}

.productos-empty .material-icons {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

/* ─── Modal de Producto ──────────────────────────────────── */
.modal-prod .modal-content {
    border-radius: 20px;
    border: none;
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.2);
}

.modal-prod .modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--prod-border);
    background: rgba(15, 23, 42, 0.02);
}

.modal-prod .modal-title {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-prod .modal-body {
    padding: 1.5rem;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-prod .form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--prod-muted);
    margin-bottom: 0.3rem;
}

.modal-prod .form-control,
.modal-prod .form-select,
.modal-prod textarea {
    border-radius: 12px;
    border: 1px solid var(--prod-border);
    padding: 0.55rem 0.85rem;
    font-size: 0.88rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.modal-prod .form-control:focus,
.modal-prod .form-select:focus,
.modal-prod textarea:focus {
    border-color: var(--prod-accent);
    box-shadow: 0 0 0 3px var(--prod-accent-soft);
    outline: none;
}

/* Switch para descuentos */
.form-check-switch .form-check-input {
    width: 3rem;
    height: 1.5rem;
    cursor: pointer;
}

.form-check-switch .form-check-input:checked {
    background-color: var(--prod-accent);
    border-color: var(--prod-accent);
}

/* Sección de descuentos */
.descuentos-section {
    background: var(--prod-accent-soft);
    border: 1px solid var(--prod-accent);
    border-radius: 12px;
    padding: 1rem;
    margin-top: 0.75rem;
}

/* Presentación item en formulario */
.presentacion-form-item {
    background: rgba(15, 23, 42, 0.03);
    border: 1px solid var(--prod-border);
    border-radius: 12px;
    padding: 0.85rem;
    margin-bottom: 0.75rem;
}

.presentacion-form-item h6 {
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--prod-text);
}

/* Upload de imágenes */
.image-upload-zone {
    border: 2px dashed var(--prod-border);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: rgba(15, 23, 42, 0.02);
}

.image-upload-zone:hover {
    border-color: var(--prod-accent);
    background: var(--prod-accent-soft);
}

.image-upload-zone .material-icons {
    font-size: 2.5rem;
    color: var(--prod-accent);
    margin-bottom: 0.5rem;
}

.image-preview {
    max-width: 100%;
    max-height: 150px;
    border-radius: 8px;
    margin-top: 0.5rem;
}

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 767px) {
    .productos-grid {
        grid-template-columns: 1fr;
    }

    .search-wrapper {
        min-width: 0;
        width: 100%;
    }
    
    .filtros-acciones {
        width: 100%;
        justify-content: flex-start;
    }
    
    .filtro-select {
        flex: 1;
        min-width: 0;
    }

    .producto-imagen {
        aspect-ratio: 4 / 3;
        min-height: 180px;
    }

    .producto-precio-final {
        font-size: 1.25rem;
    }
}

@media (min-width: 768px) and (max-width: 1199px) {
    .productos-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}


/* === ESTILOS MODAL MEJORADOS === */
.modal-prod .modal-dialog { max-width: 750px; }
.modal-prod .modal-content { border-radius: 16px; }
.modal-prod .modal-header { padding: 1rem 1.25rem; font-size: 1rem; }
.modal-prod .modal-body { padding: 1.25rem; max-height: 70vh; overflow-y: auto; }
.modal-prod .form-label { font-size: 0.75rem; }
.modal-prod .form-control-sm { padding: 0.35rem 0.6rem; font-size: 0.8rem; }
.presentacion-form-item { background: white; border: 1px solid var(--prod-border); border-radius: 12px; padding: 1rem; margin-bottom: 0.85rem; }
.presentacion-form-item .header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--prod-border); }
.presentacion-form-item .header h6 { font-size: 0.85rem; font-weight: 700; margin: 0; color: var(--prod-accent); }
.fotos-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.65rem; margin-top: 0.65rem; }
.foto-upload-box {
    position: relative;
    aspect-ratio: 1;
    border: 2px dashed var(--prod-border);
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    background: rgba(15, 23, 42, 0.02);
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.foto-upload-box:hover {
    border-color: var(--prod-accent);
    background: var(--prod-accent-soft);
}

/* Overlay con icono y texto (visible solo si no hay imagen) */
.foto-upload-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1;
    pointer-events: none;
}

.foto-upload-overlay .material-icons {
    font-size: 2rem;
    color: var(--prod-accent);
    opacity: 0.5;
}

.foto-upload-overlay p {
    font-size: 0.65rem;
    color: var(--prod-muted);
    margin: 0.25rem 0 0;
}

/* Imagen de preview (se muestra cuando hay foto) */
.foto-preview {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
    top: 0;
    left: 0;
    z-index: 2;
    border-radius: 8px;
}

.foto-preview ~ .foto-upload-overlay {
    display: none;
}

/* Botón eliminar foto (hover sobre imagen) */
.foto-delete-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    z-index: 10;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.55);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    backdrop-filter: blur(2px);
}

.foto-upload-box:hover .foto-delete-btn {
    opacity: 1;
}

.foto-delete-btn:hover {
    background: rgba(239, 68, 68, 0.85);
    transform: scale(1.15);
}

.foto-delete-btn .material-icons {
    font-size: 14px !important;
    line-height: 1;
}

/* File input oculto pero accesible (SIN pointer-events:none para permitir .click() programático) */
.foto-upload-box input[type='file'] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
    opacity: 0;
}

/* Cuando hay una imagen preview, ocultar el overlay */
.foto-upload-box:has(.foto-preview) .foto-upload-overlay {
    display: none;
}

/* QR Preview box en formulario */
.qr-preview-box {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    background: #f0f0f0;
    overflow: hidden;
    flex-shrink: 0;
}

.qr-preview-box img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Estado drag-over */
.foto-upload-dragover {
    border-color: var(--prod-accent) !important;
    background: rgba(245, 124, 17, 0.15) !important;
    box-shadow: 0 0 0 4px rgba(245, 124, 17, 0.15);
}


/* === AJUSTES VISUALES === */
.producto-card { height: 100%; } /* Cards misma altura */
.producto-badges { max-width: 85%; gap: 0.3rem; } /* Badges m\u00e1s espacio */
.badge-promo, .badge-descuento-pago, .badge-stock-bajo { padding: 0.2rem 0.45rem; font-size: 0.62rem; white-space: nowrap; } /* Badges sin salto */
.badge-original { padding: 0.22rem 0.5rem; font-size: 0.62rem; } /* Badge oro más pequeño */
.producto-descripcion { height: 2.7em; } /* Altura fija descripci\u00f3n */
.btn-prod { min-height: 34px; padding: 0.55rem 0.8rem; font-size: 0.75rem; white-space: nowrap; } /* Botones mejor proporci\u00f3n */
.btn-prod .material-icons { font-size: 1rem; } /* \u00cdconos m\u00e1s grandes */
.btn-prod-icon { width: 34px; min-width: 34px; height: 34px; flex: 0 0 auto; } /* Botones icono cuadrados */
.producto-header-info { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.4rem; gap: 0.5rem; } /* Header con garant\u00eda */
.producto-garantia { font-size: 0.65rem; white-space: nowrap; gap: 0.25rem; margin: 0; } /* Garant\u00eda en header */


/* === ALTURA FIJA PARA TODAS LAS SECCIONES === */
.producto-header-info { height: 20px; min-height: 20px; } /* Header fijo */
.producto-titulo { height: 2.4em; min-height: 2.4em; } /* Nombre hasta 2 líneas */
.producto-marca { height: 20px; min-height: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } /* Marca 1 línea */
.producto-proveedor { min-height: 22px; height: 22px; } /* Proveedor fijo */
.producto-descripcion { height: 2.4em; min-height: 2.4em; } /* Descripción hasta 2 líneas */
.producto-presentaciones { min-height: 32px; height: 32px; max-height: 48px; overflow: hidden; display: flex; align-items: center; gap: 6px; } /* Píldoras: 1 fila + flechas a los lados */
.producto-precio-container { height: 70px; min-height: 70px; display: flex; flex-direction: column; justify-content: center; } /* Precio fijo */
.producto-footer { height: 42px; min-height: 42px; } /* Footer fijo */


/* ═══════════════════════════════════════════════════════
   TOGGLE SWITCHES — Descuentos en modal de productos
   Estilo: moderno, minimalista, con animaciones suaves
   ═══════════════════════════════════════════════════════ */

/* ─── Wrapper de cada switch ─── */
.descuento-switch-wrapper {
    background: rgba(15, 23, 42, 0.02);
    border: 1px solid var(--prod-border);
    border-radius: 14px;
    padding: 0.85rem 1rem;
    margin-bottom: 0.5rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.descuento-switch-wrapper:has(.toggle-switch input:checked) {
    border-color: rgba(245, 124, 17, 0.2);
    background: rgba(245, 124, 17, 0.04);
    box-shadow: 0 0 0 2px rgba(245, 124, 17, 0.06);
}

/* ─── Fila del switch (toggle + info) ─── */
.descuento-switch {
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    user-select: none;
}

/* ─── Toggle Switch personalizado ─── */
.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    width: 46px;
    height: 26px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #e2e8f0;
    border-radius: 26px;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--prod-accent);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15), 0 0 0 4px rgba(245, 124, 17, 0.12);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
    box-shadow: 0 2px 8px rgba(245, 124, 17, 0.35);
}

.toggle-switch input:focus-visible + .toggle-slider {
    outline: 2px solid var(--prod-accent);
    outline-offset: 2px;
}

/* ─── Info del switch (título + descripción) ─── */
.switch-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.switch-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--prod-text);
    line-height: 1.2;
}

.switch-desc {
    font-size: 0.7rem;
    color: var(--prod-muted);
    line-height: 1.3;
}

/* ─── Collapse animado ─── */
.descuento-collapse {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.25s ease,
                margin 0.3s ease;
    opacity: 0;
    margin-top: 0;
}

.descuento-collapse.open {
    grid-template-rows: 1fr;
    opacity: 1;
    margin-top: 0.75rem;
}

.descuento-collapse-inner {
    overflow: hidden;
    min-height: 0;
}

/* ─── Grid de campos de pago ─── */
.descuento-pago-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.65rem;
    padding: 0.65rem 0.5rem 0.35rem;
    margin-top: 0.25rem;
    background: rgba(245, 124, 17, 0.05);
    border-radius: 10px;
    border: 1px solid rgba(245, 124, 17, 0.1);
}

.pago-field {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.pago-field .form-label {
    font-size: 0.7rem !important;
    font-weight: 600;
    color: var(--prod-text);
    margin-bottom: 0.15rem;
    white-space: nowrap;
}

.pago-input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.pago-input-group input {
    padding-right: 1.6rem !important;
    text-align: right;
    font-weight: 600;
    font-size: 0.85rem;
    border-radius: 8px !important;
    background: white;
}

.pago-input-group input:focus {
    border-color: var(--prod-accent) !important;
    box-shadow: 0 0 0 2px rgba(245, 124, 17, 0.12) !important;
}

.pago-suffix {
    position: absolute;
    right: 0.55rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--prod-muted);
    pointer-events: none;
}

/* ─── Responsive para los pagos grid ─── */
@media (max-width: 767px) {
    .descuento-pago-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .pago-field .form-label {
        font-size: 0.65rem !important;
    }
    
    .descuento-switch {
        gap: 0.75rem;
    }
    
    .switch-title {
        font-size: 0.8rem;
    }
    
    .switch-desc {
        font-size: 0.65rem;
    }
    
    .toggle-switch {
        width: 40px;
        height: 22px;
    }
    
    .toggle-slider::before {
        width: 16px;
        height: 16px;
        top: 3px;
        left: 3px;
    }
    
    .toggle-switch input:checked + .toggle-slider::before {
        transform: translateX(18px);
    }
}


/* ═══════════════════════════════════════════════════════
   CARRUSEL DE IMÁGENES — Product Cards
   Estilo: manual (sin autoplay), con flechas y dots
   ═══════════════════════════════════════════════════════ */

.producto-carousel {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    background: #f8f9fa;
}

.carousel-track {
    display: flex;
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    height: 100%;
    width: 100%;
}

.carousel-slide {
    min-width: 100%;
    height: 100%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.carousel-slide img {
    max-width: 95%;
    max-height: 90%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    border-radius: 4px;
    transition: transform 0.3s ease;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.producto-card:hover .carousel-slide img {
    transform: scale(1.08);
}

/* ─── Flechas de navegación ─── */
.carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
    color: #334155;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.25s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    z-index: 5;
    padding: 0;
    line-height: 1;
}

.producto-carousel:hover .carousel-arrow {
    opacity: 1;
}

.carousel-arrow:hover {
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
    transform: translateY(-50%) scale(1.08);
}

.carousel-arrow:active {
    transform: translateY(-50%) scale(0.95);
}

.carousel-arrow .material-icons {
    font-size: 1.25rem;
    line-height: 1;
}

.carousel-prev {
    left: 6px;
}

.carousel-next {
    right: 6px;
}

/* ─── Dots de navegación ─── */
.carousel-dots {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 5px;
    z-index: 5;
}

.carousel-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.carousel-dot.active {
    background: var(--prod-accent);
    width: 18px;
    border-radius: 4px;
    border-color: var(--prod-accent);
    box-shadow: 0 0 8px rgba(245, 124, 17, 0.4);
}

.carousel-dot:hover:not(.active) {
    background: rgba(255, 255, 255, 0.8);
    transform: scale(1.3);
}

/* ─── Ajustes responsive ─── */
@media (max-width: 767px) {
    .carousel-arrow {
        width: 28px;
        height: 28px;
        opacity: 0.7;
    }
    
    .carousel-arrow .material-icons {
        font-size: 1.1rem;
    }
    
    .carousel-dot {
        width: 6px;
        height: 6px;
    }
    
    .carousel-dot.active {
        width: 14px;
    }
}

/* ─── 🔍 Lightbox: ver la foto del producto en grande (clic en la imagen) ─── */
.prod-img-zoom {
    cursor: zoom-in;
}

.prod-lightbox {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: rgba(8, 10, 15, 0.88);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    animation: prodLightboxIn 0.18s ease;
}

.prod-lightbox img {
    max-width: 92vw;
    max-height: 88vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    cursor: default;
}

.prod-lightbox-close {
    position: absolute;
    top: 16px;
    right: 20px;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease;
}

.prod-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.28);
}

@keyframes prodLightboxIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
