/* ============================================
   RESPONSIVE GENERAL - DySoftw
   AdminLTE 2.4.0 + Bootstrap 3.4.1
   ============================================ */

/* --- MÓVIL (menos de 768px) --- */
@media (max-width: 767px) {

    .main-sidebar,
    .left-side {
        padding-top: 50px;
    }

    .main-header .logo {
        height: 50px;
        line-height: 50px;
        font-size: 15px;
        padding: 0 10px;
    }

    .main-header .navbar {
        min-height: 50px;
        margin-left: 0;
    }

    .content-wrapper {
        padding: 10px;
    }

    .content-header {
        padding: 10px 10px 0 10px;
    }

    .content-header h1 {
        font-size: 18px;
        margin-top: 5px;
    }

    .box {
        margin-bottom: 10px;
    }

    .box-header {
        padding: 8px 10px;
    }

    .box-header .box-title {
        font-size: 15px;
    }

    .box-body {
        padding: 10px;
    }

    .btn {
        padding: 7px 11px;
        font-size: 13px;
    }

    .btn-xs {
        padding: 3px 6px;
        font-size: 11px;
    }

    .table-responsive {
        border: none;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .form-group {
        margin-bottom: 10px;
    }

    .hide-mobile {
        display: none !important;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: 100%;
        margin-left: 0;
    }

    .dataTables_wrapper .dataTables_paginate {
        float: none !important;
        text-align: center;
        margin-top: 8px;
    }

    .dataTables_wrapper .dataTables_paginate .paginate_button {
        padding: 3px 7px;
        font-size: 12px;
    }

    .dataTables_wrapper .dataTables_info {
        text-align: center;
        font-size: 12px;
    }
}

/* --- TABLET (768px a 991px) --- */
@media (min-width: 768px) and (max-width: 991px) {

    .content-header h1 {
        font-size: 20px;
    }

    .main-sidebar {
        width: 210px;
    }

    .content-wrapper,
    .main-footer {
        margin-left: 210px;
    }
}

/* --- POS / PANTALLAS MEDIANAS (992px a 1366px) --- */
@media (min-width: 992px) and (max-width: 1366px) {

    .main-sidebar {
        width: 220px;
    }

    .content-wrapper,
    .main-footer {
        margin-left: 220px;
    }
}

/* --- TABLAS DATATABLES EN MÓVIL --- */
@media (max-width: 767px) {
    table.dataTable thead th,
    table.dataTable tbody td {
        font-size: 12px;
        padding: 6px 4px;
    }

    table.dataTable .btn-xs {
        padding: 3px 6px;
        font-size: 11px;
    }
}

/* --- SELECT2 AL 100% EN MÓVIL --- */
@media (max-width: 767px) {
    .select2-container {
        width: 100% !important;
    }
}

/* --- MODALES A PANTALLA COMPLETA EN MÓVIL --- */
@media (max-width: 767px) {
    .modal-dialog {
        margin: 5px;
    }

    .modal-body {
        max-height: calc(100vh - 160px);
        overflow-y: auto;
    }
}

/* --- SCROLL SUAVE --- */
body {
    -webkit-overflow-scrolling: touch;
}


/* ============================================
   STICKY FOOTER - Arregla el espacio azul
   ============================================ */


.wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.content-wrapper {
    flex: 1 0 auto;
}

.main-footer {
    flex-shrink: 0;
    margin-left: 230px;
}

@media (max-width: 767px) {
    .main-footer {
        margin-left: 0;
    }
}


/* ============================================
   FORMULARIO DE PRODUCTOS - RESPONSIVE MEJORADO
   ============================================ */

/* Labels que solo se ven en móvil */
.label-movil {
    display: none;
    font-size: 10px;
    font-weight: 600;
    color: #666;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Header sticky (contador) - oculto en desktop */
.productos-header {
    display: none;
}

/* Botón "Ir arriba" - oculto hasta hacer scroll */
#btnIrArriba {
    display: none;
}

/* Numeración de productos - oculta en desktop */
.producto-numero {
    display: none;
}


/* ============================================
   MÓVIL (menos de 768px)
   ============================================ */
@media (max-width: 767px) {

    /* ✅ Mostrar labels en móvil */
    .label-movil {
        display: block;
    }

    /* ✅ Header sticky con contador de productos */
    .productos-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        position: sticky;
        top: 50px;
        z-index: 100;
        background: #fff;
        padding: 8px 12px;
        border-bottom: 2px solid #3c8dbc;
        margin-bottom: 10px;
        box-shadow: 0 2px 4px rgba(0,0,0,.1);
    }

    .productos-header .titulo {
        font-size: 13px;
        font-weight: 600;
        color: #333;
    }

 .productos-header .contador {
    background: #fff;
    color: #3c8dbc;
    padding: 3px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    display: inline-block;
    margin-left: 10px; /* Separación extra por si acaso */
}

    /* ✅ Numeración visible de cada producto */
    .producto-numero {
        display: block;
        margin-bottom: 6px;
    }

    .producto-numero .badge-numero {
        display: inline-block;
        background: #3c8dbc;
        color: #fff;
        padding: 3px 10px;
        border-radius: 12px;
        font-size: 11px;
        font-weight: 600;
        margin-right: 6px;
    }

    .producto-numero .nombre-producto {
        font-size: 12px;
        color: #555;
        font-weight: 500;
    }

    /* ✅ Tarjeta compacta + borde izquierdo de color */
    .producto-row {
        border: 1px solid #e0e0e0;
        
        border-radius: 5px;
        margin-bottom: 8px !important;
        padding: 8px !important;
        background: #fafafa;
    }

    /* ✅ Colores alternados (zebra) */
    .producto-row:nth-child(odd) {
        
        background: #fafafa;
    }

    .producto-row:nth-child(even) {
        
        background: #ffffff;
    }

    /* ✅ Inputs táctiles y compactos */
    .producto-row input,
    .producto-row select {
        height: 38px !important;
        font-size: 14px !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .producto-row .input-group {
        width: 100%;
    }

    .producto-row [style*="max-width"] {
        max-width: 100% !important;
    }

    .producto-row .quitarProducto {
        padding: 6px 10px;
        font-size: 13px;
    }

    .producto-row .col-xs-6,
    .producto-row .col-xs-12 {
        margin-bottom: 6px;
    }

    .producto-row > div:last-child {
        margin-bottom: 0 !important;
    }

    /* ✅ Botón "Ir arriba" flotante */
    #btnIrArriba {
        display: none;
        position: fixed;
        bottom: 20px;
        right: 20px;
        z-index: 9999;
        width: 48px;
        height: 48px;
        border-radius: 50%;
        background: #3c8dbc;
        color: #fff;
        border: none;
        box-shadow: 0 2px 8px rgba(0,0,0,.3);
        font-size: 18px;
        cursor: pointer;
        transition: background .2s;
    }

    #btnIrArriba:hover,
    #btnIrArriba:active {
        background: #367fa9;
    }
}


/* ============================================
   TABLET (768px - 991px)
   ============================================ */
@media (min-width: 768px) and (max-width: 991px) {

    .producto-row {
        border: 1px solid #e0e0e0;
    border-radius: 5px;
    background: #fafafa;
    margin-bottom: 8px !important;
    padding: 8px !important;
    box-sizing: border-box;
    width: 100%;
    }

    /* Sin colores alternados, todos iguales */
.producto-row:nth-child(odd),
.producto-row:nth-child(even) {
    background: #fafafa;
    border-color: #e0e0e0;
}

    .producto-row input,
    .producto-row select {
        font-size: 12px !important;
        height: 36px !important;
    }
}

@media (max-width: 767px) {
    button.agregarProducto {
        width: 55%;
        padding: 8px 12px;
        font-size: 12px;
        margin-top: 5px;
    }
}

/* En responsive.css */
.productos-wrapper {
    padding: 0 10px;
    overflow: hidden;
}


/* ============================================
   TÍTULO DEL CLIENTE
   ============================================ */
.clientes-header {
    display: none;
    background: linear-gradient(135deg, #00a65a 0%, #008d4c 100%);
    color: #fff;
    padding: 8px 15px;
    border-radius: 6px; 
    margin-top: 20px !important;
    margin-bottom: 15px !important;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 4px 6px rgba(0,0,0,.1);
    width: 100%;
    border-left: 4px solid #00733e;
}

/* Animación suave al aparecer */
body:has(.nuevoCliente .row) .clientes-header {
    display: block;
    animation: fadeInDown 0.3s ease-in-out;
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}


.nuevoCliente {
    background: #ffffff;
    padding: 15px !important;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    border: 1px solid #e0e0e0;
    margin-bottom: 15px !important;
    display: none; /* 👈 Oculto por defecto */
}

body:has(.nuevoCliente .row) .nuevoCliente {
    display: block;
    background: #ffffff;
    padding: 15px !important;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    border: 1px solid #e0e0e0;
    margin-bottom: 15px !important;
}

.nuevoCliente input[readonly] {
    color: #333 !important;
    background-color: #f9f9f9 !important;
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}


/* Oculto por defecto */
.productos-header {
    display: none;
    background: #3c8dbc; 
    color: #fff;
    padding: 10px 15px;
    border-radius: 6px;
    margin-top: 20px !important;    
    margin-bottom: 10px !important; 
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 3px 6px rgba(0,0,0,.15);
    width: 100%;
    border-left: 4px solid #204d74;
    justify-content: space-between; /* Esto empuja uno a la izquierda y otro a la derecha */
    align-items: center;
}

/* Forzar que se vea como flex para que el ícono y el texto queden alineados */
body:has(.nuevoProducto .producto-row) .productos-header,
body:has(.nuevoOproducto .producto-row) .productos-header,
body:has(.nuevoOrdenFormulacion .producto-row) .productos-header {
    display: flex !important; 
    animation: fadeInDown 0.3s ease;
}

/* Evitar que los productos se salgan de la caja */
.nuevoProducto, 
.nuevoOproducto, 
.nuevoOrdenFormulacion {
    width: 100%;
    overflow: hidden;
}

/* Tarjeta del producto (Ajuste para que no se desborde) */
.producto-row {
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-bottom: 10px !important;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    padding: 10px !important;
    background: #fff;
}


/* ============================================
   BOTÓN FLOTANTE "VOLVER ARRIBA"
   ============================================ */
#btnSubirTop {
    display: none; /* Oculto al inicio */
    position: fixed !important; 
    bottom: 30px !important;
    right: 30px !important;
    z-index: 9999999 !important; /* Altísimo para que pase por encima de todo */
    width: 55px;
    height: 55px;
    border-radius: 50%;
    background: #3c8dbc;
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    font-size: 22px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#btnSubirTop:hover {
    background: #367fa9;
    transform: scale(1.1);
}

@media (max-width: 767px) {
    #btnSubirTop {
        width: 50px;
        height: 50px;
        bottom: 20px !important;
        right: 20px !important;
    }
}

/* Ocultar en computadores y tablets grandes (1024px en adelante) */
@media (min-width: 992px) {
    #btnSubirTop {
        display: none !important;
    }
}