/* =========================================
   1. ESTRUCTURA Y MARCA (BREXO)
   ========================================= */
.bg-login-custom {
    background-color: #052c3c;
    background-image: radial-gradient(circle at center, #e30613 0%, #1e1e1c 100%);
}

.bg-header-custom {
    background-color: #052c3c;
    border-bottom: 1px solid #0a3a4e;
}

.custom-scroll::-webkit-scrollbar { width: 6px; }
.custom-scroll::-webkit-scrollbar-thumb { background: #052c3c; border-radius: 10px; }

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* =========================================
   2. ANIMACIONES Y ESTADOS
   ========================================= */
.fade-in { animation: fadeIn 0.4s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.scale-in, .zoom-in { animation: scaleIn 0.3s ease-out; }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }

.stock-rojo { background: #fef2f2; border: 2px solid #ef4444; color: #991b1b; animation: pulse 2s infinite; }
.stock-naranja { background: #fff7ed; border: 2px solid #fb923c; color: #9a3412; }
.solo-lectura { opacity: 0.6; pointer-events: none; filter: grayscale(1); }

/* =========================================
   3. ESTILOS DE FORMULARIOS (MODERNO)
   ========================================= */
select, input {
    height: 54px !important;
    background-color: #f8fafc !important;
    border: 2px solid #e2e8f0 !important;
    border-radius: 18px !important;
    padding: 0 16px !important;
    font-weight: 700 !important;
    font-size: 13px !important;
    transition: all 0.3s ease !important;
    outline: none !important;
    appearance: none;
}

select:focus, input:focus {
    border-color: #009fe3 !important;
    background-color: #ffffff !important;
    box-shadow: 0 0 0 4px rgba(0, 159, 227, 0.1) !important;
}

select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 40px !important;
}

/* =========================================
   4. SEGURIDAD Y PERFIL
   ========================================= */
.role-vendedor #tab-produccion button,
.role-vendedor .btn-finalizar,
.role-vendedor .btn-insumos {
    display: none !important;
}

.btn-insumos {
    display: flex !important;
}

*:focus { outline: none !important; }

#perfil_new_pin::placeholder,
#perfil_confirm_pin::placeholder {
    letter-spacing: normal;
    font-size: 12px;
    font-weight: 700;
}

#modalMateriales .max-h-\[60vh\],
#modalMateriales .overflow-y-auto {
    overflow-y: visible !important;
    overflow-x: visible !important;
}

.fila-insumo {
    position: relative !important;
}

#whatsappMaster {
    padding-left: 40px !important;
}

@keyframes parpadeo-alerta {
    0%   { box-shadow: 0 0 0px #ef4444; border-color: transparent; }
    50%  { box-shadow: 0 0 20px #ef4444; border-color: #ef4444; }
    100% { box-shadow: 0 0 0px #ef4444; border-color: transparent; }
}

.orden-editada-reciente {
    animation: parpadeo-alerta 1.5s infinite;
    border-width: 2px !important;
    position: relative;
}

.orden-editada-reciente::after {
    content: "EDITADA";
    position: absolute;
    top: -10px;
    right: 10px;
    background: #ef4444;
    color: white;
    font-size: 8px;
    font-weight: 900;
    padding: 2px 8px;
    border-radius: 10px;
    z-index: 20;
}

/* =========================================
   5. MÓDULO VENTAS — TARJETAS DE ÍTEM
   Clase real: "p-4 bg-white border border-slate-100
   rounded-2xl shadow-sm mb-3 relative group"
   generada en addVentaItem()
   ========================================= */

/* Cada fila/ítem del formulario de venta */
#listaVentas > div {
    background: #ffffff;
    border: 2px solid #f1f5f9 !important;
    border-radius: 20px !important;
    padding: 16px !important;
    box-shadow: 0 4px 16px rgba(5, 44, 60, 0.06) !important;
    transition: box-shadow 0.25s ease, border-color 0.25s ease;
    animation: fadeIn 0.3s ease-out;
    position: relative;
}

#listaVentas > div:hover {
    border-color: #e2e8f0 !important;
    box-shadow: 0 8px 28px rgba(5, 44, 60, 0.10) !important;
}

/* Botón × cerrar del ítem */
#listaVentas > div .btn-cerrar {
    position: absolute !important;
    top: -10px !important;
    right: -10px !important;
    width: 26px !important;
    height: 26px !important;
    border-radius: 50% !important;
    background: #ffffff !important;
    border: 2px solid #fee2e2 !important;
    color: #fca5a5 !important;
    font-size: 14px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.15) !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    z-index: 10;
}

#listaVentas > div .btn-cerrar:hover {
    background: #ef4444 !important;
    border-color: #ef4444 !important;
    color: #ffffff !important;
    transform: scale(1.15) rotate(90deg) !important;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35) !important;
}

/* Input nombre del producto */
#listaVentas .input-nombre {
    height: 42px !important;
    border-radius: 12px !important;
    border: 2px solid #f1f5f9 !important;
    background: #f8fafc !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    color: #1e293b !important;
    transition: all 0.2s ease !important;
    padding: 0 12px !important;
}

#listaVentas .input-nombre:focus {
    border-color: #009fe3 !important;
    background: #ffffff !important;
    box-shadow: 0 0 0 3px rgba(0, 159, 227, 0.1) !important;
}

#listaVentas .input-nombre::placeholder {
    color: #cbd5e1 !important;
    font-weight: 600 !important;
    text-transform: none;
}

/* Select tipo (Und / M2) */
#listaVentas .select-tipo {
    height: 42px !important;
    border-radius: 12px !important;
    border: 2px solid #f1f5f9 !important;
    background: #f8fafc !important;
    font-size: 10px !important;
    font-weight: 800 !important;
    color: #475569 !important;
    padding: 0 32px 0 10px !important;
    min-width: 64px;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}

#listaVentas .select-tipo:focus {
    border-color: #009fe3 !important;
    background: #ffffff !important;
}

/* Botón buscar (+) */
#listaVentas .btn-buscar {
    width: 42px !important;
    height: 42px !important;
    border-radius: 12px !important;
    background: linear-gradient(135deg, #052c3c 0%, #0a4d65 100%) !important;
    color: #ffffff !important;
    border: none !important;
    font-size: 20px !important;
    font-weight: 900 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    box-shadow: 0 4px 12px rgba(5, 44, 60, 0.25) !important;
    transition: all 0.2s ease !important;
    flex-shrink: 0;
}

#listaVentas .btn-buscar:hover {
    background: linear-gradient(135deg, #009fe3 0%, #0077b6 100%) !important;
    box-shadow: 0 6px 18px rgba(0, 159, 227, 0.35) !important;
    transform: scale(1.06) !important;
}

#listaVentas .btn-buscar:active {
    transform: scale(0.95) !important;
}

/* Referencia precio m2 */
#listaVentas #ref-precio {
    font-size: 9px !important;
    font-weight: 800 !important;
    color: #10b981 !important;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    padding: 3px 10px !important;
    display: inline-block;
    margin-top: 4px !important;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

/* Input detalle */
#listaVentas .input-detalle {
    height: 38px !important;
    border-radius: 12px !important;
    border: 2px solid #f1f5f9 !important;
    background: #f8fafc !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    color: #475569 !important;
    padding: 0 12px !important;
    transition: all 0.2s ease !important;
}

#listaVentas .input-detalle:focus {
    border-color: #a5b4fc !important;
    background: #ffffff !important;
    box-shadow: 0 0 0 3px rgba(165, 180, 252, 0.15) !important;
}

#listaVentas .input-detalle::placeholder {
    color: #cbd5e1 !important;
    font-style: italic;
}

/* Inputs medidas (ancho / alto) */
#listaVentas .input-ancho,
#listaVentas .input-alto {
    height: 46px !important;
    border-radius: 14px !important;
    border: 2px solid #d1fae5 !important;
    background: #f0fdf4 !important;
    font-size: 13px !important;
    font-weight: 800 !important;
    color: #065f46 !important;
    text-align: center !important;
    transition: all 0.2s ease !important;
}

#listaVentas .input-ancho:focus,
#listaVentas .input-alto:focus {
    border-color: #10b981 !important;
    background: #ffffff !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12) !important;
}

/* Separador inferior del ítem */
#listaVentas > div .border-t {
    border-color: #f8fafc !important;
    margin-top: 12px !important;
    padding-top: 12px !important;
}

/* Label "Total ($)" */
#listaVentas > div .border-t span {
    font-size: 9px !important;
    font-weight: 900 !important;
    color: #94a3b8 !important;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Input precio final del ítem */
#listaVentas .input-precio {
    height: 40px !important;
    width: 100px !important;
    border-radius: 14px !important;
    border: 2px solid #d1fae5 !important;
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%) !important;
    font-size: 15px !important;
    font-weight: 900 !important;
    color: #059669 !important;
    text-align: right !important;
    padding: 0 12px !important;
    box-shadow: inset 0 2px 4px rgba(16, 185, 129, 0.08) !important;
    transition: all 0.2s ease !important;
}

#listaVentas .input-precio:focus {
    border-color: #10b981 !important;
    background: #ffffff !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15) !important;
    color: #047857 !important;
}

/* =========================================
   6. MÓDULO VENTAS — TOTAL GENERAL
   ID real: #displayTotalPedido
   ========================================= */

#displayTotalPedido {
    font-size: 28px !important;
    font-weight: 900 !important;
    color: #052c3c !important;
    letter-spacing: -0.5px;
    transition: all 0.3s ease;
}

/* Contenedor padre del total — apuntamos al wrapper cercano */
#displayTotalPedido {
    background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
    border-radius: 16px;
    padding: 8px 20px;
    border: 2px solid #bbf7d0;
    display: inline-block;
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.12);
}

/* =========================================
   7. MÓDULO VENTAS — BUSCADOR EN SWAL
   (Estilos inyectados en el popup de SweetAlert)
   ========================================= */

/* El SweetAlert de búsqueda hereda algunos globales,
   reforzamos los que redefine el JS inline */
#buscador-input {
    height: 46px !important;
    border-radius: 14px !important;
    border: 2px solid #e2e8f0 !important;
    background: #f8fafc !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #1e293b !important;
    padding: 0 16px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    transition: all 0.2s ease !important;
    margin-bottom: 12px !important;
}

#buscador-input:focus {
    border-color: #009fe3 !important;
    background: #ffffff !important;
    box-shadow: 0 0 0 4px rgba(0, 159, 227, 0.1) !important;
}

#resultados-lista {
    border-radius: 16px !important;
    border: 1.5px solid #f1f5f9 !important;
    background: #f8fafc !important;
    overflow: hidden !important;
    max-height: 240px !important;
    overflow-y: auto !important;
}

/* Fila de resultado individual (generada por JS) */
#resultados-lista > div {
    padding: 12px 14px !important;
    border-bottom: 1px solid #f1f5f9 !important;
    cursor: pointer !important;
    background: #ffffff !important;
    transition: all 0.15s ease !important;
    text-align: left !important;
}

#resultados-lista > div:last-child {
    border-bottom: none !important;
}

#resultados-lista > div:hover {
    background: linear-gradient(135deg, #f0fdf4, #ecfdf5) !important;
    padding-left: 20px !important;
}

#resultados-lista > div span {
    font-size: 12px !important;
    font-weight: 700 !important;
    color: #1e293b !important;
}

/* =========================================
   8. MÓDULO VENTAS — AVISOS / CHIPS DE ÓRDENES
   Clase real generada en escucharOrdenesListas()
   ========================================= */

/* Chip individual de orden lista */
#contenedorAvisosVendedor > div {
    background: #ffffff !important;
    border: 1.5px solid #f1f5f9 !important;
    border-radius: 30px !important;
    padding: 5px 14px 5px 5px !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    box-shadow: 0 2px 10px rgba(5, 44, 60, 0.08) !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    animation: fadeIn 0.3s ease-out;
}

#contenedorAvisosVendedor > div:hover {
    border-color: #009fe3 !important;
    box-shadow: 0 4px 16px rgba(0, 159, 227, 0.2) !important;
    transform: translateY(-1px) !important;
}

#contenedorAvisosVendedor > div:active {
    transform: scale(0.96) !important;
}

/* Badge de número de orden dentro del chip */
#contenedorAvisosVendedor > div > div:first-child {
    background: linear-gradient(135deg, #052c3c 0%, #0a4d65 100%) !important;
    color: #ffffff !important;
    font-size: 9px !important;
    font-weight: 900 !important;
    height: 26px !important;
    padding: 0 10px !important;
    border-radius: 20px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 2px 8px rgba(5, 44, 60, 0.3) !important;
    letter-spacing: 0.5px;
}

/* Nombre del cliente en el chip */
#contenedorAvisosVendedor .text-\[10px\] {
    font-size: 10px !important;
    font-weight: 800 !important;
    color: #1e293b !important;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* =========================================
   9. MÓDULO VENTAS — MODAL DETALLE ORDEN
   ID real: #modalDetalleOrden / #contenidoModalOrden
   ========================================= */

#modalDetalleOrden {
    backdrop-filter: blur(8px) !important;
    background: rgba(5, 44, 60, 0.5) !important;
}

/* Contenedor interno del modal */
#contenidoModalOrden {
    border-radius: 28px !important;
    box-shadow: 0 24px 64px rgba(5, 44, 60, 0.25) !important;
    animation: scaleIn 0.3s ease-out;
}

/* Tarjeta de cada producto dentro del modal */
#contenidoModalOrden .bg-white.border.border-slate-100.rounded-\[24px\] {
    border: 1.5px solid #f1f5f9 !important;
    box-shadow: 0 2px 8px rgba(5, 44, 60, 0.05) !important;
    transition: box-shadow 0.2s ease !important;
}

#contenidoModalOrden .bg-white.border.border-slate-100.rounded-\[24px\]:hover {
    box-shadow: 0 6px 20px rgba(5, 44, 60, 0.1) !important;
}

/* Botón cobrar dentro del modal */
#contenidoModalOrden .bg-emerald-500 {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35) !important;
    border-radius: 14px !important;
    font-size: 10px !important;
    font-weight: 900 !important;
    letter-spacing: 0.3px;
    transition: all 0.2s ease !important;
}

#contenidoModalOrden .bg-emerald-500:hover {
    transform: translateY(-1px) !important;
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45) !important;
}

/* Botón confirmar entrega (oscuro) */
#contenidoModalOrden .bg-\[\#052c3c\].text-white.shadow-xl {
    background: linear-gradient(135deg, #052c3c 0%, #0a4d65 100%) !important;
    box-shadow: 0 8px 28px rgba(5, 44, 60, 0.3) !important;
    transition: all 0.25s ease !important;
    letter-spacing: 0.5px;
}

#contenidoModalOrden .bg-\[\#052c3c\].text-white.shadow-xl:hover {
    background: linear-gradient(135deg, #0a4d65 0%, #0d6080 100%) !important;
    box-shadow: 0 12px 36px rgba(5, 44, 60, 0.4) !important;
    transform: translateY(-2px) !important;
}

/* =========================================
   10. SECCIÓN DE AVISOS VENDEDOR
   ID: #seccionAvisosVendedor
   ========================================= */

#seccionAvisosVendedor {
    border-radius: 20px;
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    border: 1.5px solid #f1f5f9;
    box-shadow: 0 4px 20px rgba(5, 44, 60, 0.06);
    padding: 12px 16px;
    margin-bottom: 16px;
    transition: all 0.3s ease;
}

/* =========================================
   11. INPUTS GLOBALES — CLIENTE Y WHATSAPP
   IDs: #clienteMaster / #whatsappMaster
   ========================================= */

#clienteMaster {
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%) !important;
    border: 2px solid #e2e8f0 !important;
    border-radius: 18px !important;
    font-weight: 800 !important;
    font-size: 13px !important;
    color: #1e293b !important;
    letter-spacing: 0.3px;
    transition: all 0.3s ease !important;
}

#clienteMaster:focus {
    border-color: #009fe3 !important;
    background: #ffffff !important;
    box-shadow: 0 0 0 4px rgba(0, 159, 227, 0.1) !important;
}

#clienteMaster::placeholder {
    color: #cbd5e1 !important;
    font-weight: 600 !important;
    letter-spacing: normal;
}

#whatsappMaster {
    padding-left: 48px !important;
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%) !important;
    border: 2px solid #e2e8f0 !important;
    border-radius: 18px !important;
    font-weight: 800 !important;
    font-size: 13px !important;
    color: #1e293b !important;
    transition: all 0.3s ease !important;
}

#whatsappMaster:focus {
    border-color: #25D366 !important;
    background: #ffffff !important;
    box-shadow: 0 0 0 4px rgba(37, 211, 102, 0.1) !important;
}

#whatsappMaster::placeholder {
    color: #cbd5e1 !important;
    font-weight: 600 !important;
}

/* =========================================
   12. SCROLLBARS PERSONALIZADOS
   ========================================= */

#resultados-lista::-webkit-scrollbar { width: 5px; }
#resultados-lista::-webkit-scrollbar-track { background: transparent; }
#resultados-lista::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
#resultados-lista::-webkit-scrollbar-thumb:hover { background: #009fe3; }

.max-h-\[160px\]::-webkit-scrollbar { width: 4px; }
.max-h-\[160px\]::-webkit-scrollbar-track { background: transparent; }
.max-h-\[160px\]::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 10px; }

/* =========================================
   13. RESPONSIVE
   ========================================= */

@media (max-width: 640px) {
    #listaVentas > div {
        padding: 12px !important;
        border-radius: 16px !important;
    }

    #listaVentas .btn-buscar {
        width: 38px !important;
        height: 38px !important;
    }

    #listaVentas .input-nombre {
        font-size: 10px !important;
    }

    #listaVentas .input-precio {
        width: 85px !important;
        font-size: 13px !important;
    }

    #displayTotalPedido {
        font-size: 22px !important;
    }
}