/* ======================================================================
   RESET UNIVERSAL REFORZADO (Blindaje de Layout)
   ====================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: 100vh !important;
    overflow: hidden !important;
}

/* ======================================================================
   VARIABLES Y CONFIGURACIÓN GLOBAL (Cero fondos oscuros)
   ====================================================================== */
:root {
    --bg-light: #def4fd;
    --border-color: #e2e8f0;
    --text-main: #333333;
    --text-muted: #718096;
    --brand-blue: #3182ce;
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
}

body {
    display: flex;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-main);
}

/* ======================================================================
   SIDEBAR DINÁMICO
   ====================================================================== */
.sidebar {
    width: var(--sidebar-width);
    background: #ffffff;
    border-right: 1px solid var(--border-color);
    transition: width 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar-header {
    padding: 17px;
    font-weight: bold;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar.collapsed .sidebar-title {
    display: none;
}

.sidebar-header .logo-icon {
    color: var(--brand-blue);
    font-size: 1.2rem;
}

/* Enlaces del Menú */
.menu-link {
    padding: 15px 20px;
    color: #4a5568;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 2px solid #f8fafc;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.menu-link:hover {
    background: #edf2f7;
    color: var(--brand-blue);
}

.sidebar.collapsed .menu-text {
    display: none;
}

.menu-link i {
    font-size: 1.2rem;
    min-width: 25px;
    text-align: center;
}

/* ======================================================================
   CONTENEDOR PRINCIPAL Y HEADER
   ====================================================================== */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.navbar {
    height: 60px;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Modificador para botones en el navbar */
.btn-navbar-standard {
    flex: 0 0 auto !important; /* 💡 Esto impide que se estire */
    width: auto !important;    /* 💡 El tamaño dependerá de su texto */
    padding: 8px 16px !important; /* 💡 Padding adecuado para barra superior */
    margin: 0;
}

.btn-toggle {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #4a5568;
}

#dynamic-actions {
    flex: 1;
    display: flex;
    justify-content: flex-start; /* 💡 Alineamos a la izquierda para que fluya natural */
    align-items: center;
    gap: 15px;
    margin-left: 40px; /* 💡 ESTO SEPARA EL INPUT DEL ESCÁNER DEL TÍTULO DEL MÓDULO */
}

/* El área de la derecha (Sesión) */
.nav-right {
    display: flex;
    align-items: center;
    gap: 15px; /* Separación perfecta entre píldoras y botones */
}

/* 💡 PÍLDORAS DE INFORMACIÓN (Items y Usuario) */
.header-stat, .header-user {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 20px; /* Forma de píldora moderna */
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

/* Píldora de Productos Cargados (Gris Pastel) */
.header-stat {
    background-color: #f1f5f9;
    color: #475569;
    border-color: #e2e8f0;
}

/* Píldora de Usuario (Azul Pastel) */
.header-user {
    background-color: #ebf8ff;
    color: #2b6cb0;
    border-color: #bee3f8;
}

.header-stat i, .header-user i {
    font-size: 1.1rem;
}

/* 💡 BOTÓN DE SALIDA (Minimalista con hover peligro) */
.btn-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    color: #718096; /* Gris neutro por defecto */
    background-color: transparent;
    text-decoration: none;
    font-size: 1.4rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-logout:hover {
    background-color: #fff5f5; /* Fondo rojo pastel al pasar el mouse */
    color: #e53e3e; /* Ícono se vuelve rojo peligro */
    transform: scale(1.05); /* Pequeño salto táctil */
}

.content-area {
    flex: 1;
    overflow-y: auto;
}

.barcode-wrapper {
    display: flex;
    align-items: center;
    background: #f8fafc;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    padding: 0 15px;
    height: 38px;
    margin-right: 15px;
}

.barcode-wrapper i {
    color: #718096;
    margin-right: 8px;
}

.barcode-wrapper input#barcode-input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 1rem;
    width: 220px;
    padding: 5px 10px;
    color: #2d3748;
}

/* ==========================================================================
   ESTILOS GLOBALES MAESTROS (Módulos, Tablas, Forms)
   ========================================================================== */
.global-module-container {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: ##def4fd;
    padding: 20px;
}

.global-panel {
    max-width: 1000px;
    margin: 0 auto;
    background: #ffffff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    border: 1px solid var(--border-color);
}

.global-module-title {
    color: #919191;
    margin: 0 0 20px 0;
    font-size: 1.2rem;
    font-weight: 500;
}

/* Tablas Responsivas */
.global-table-wrapper {
    overflow-x: auto;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.global-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.global-table th, .global-table td {
    padding: 12px 15px;
    border-top: 1px solid var(--border-color);
    text-align: left;
    font-size: 0.95rem;
    color: #2d3748;
}

.global-table th {
    background-color: #edf2f7;
    color: #4a5568;
    font-weight: bold;
}

.global-table tr:hover {
    background-color: #f7fafc;
}

.thead-sticky th {
    position: sticky;
    top: 0;
    z-index: 5;
    background-color: #edf2f7;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Formularios e Inputs */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

.global-input, .global-select {
    padding: 10px 15px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 0.95rem;
    color: #2d3748;
    background-color: #f8fafc;
    transition: all 0.2s ease;
    box-sizing: border-box;
    width: 100%;
}

.global-select {
    appearance: none;
    cursor: pointer;
}

.global-input:focus, .global-select:focus {
    outline: none;
    border-color: var(--brand-blue);
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}

.global-form-group { margin-bottom: 15px; }
.global-label { display: block; font-weight: 600; margin-bottom: 5px; font-size: 0.9rem; color: var(--text-main); }
.global-checkbox-group { display: flex; flex-direction: column; gap: 10px; margin-top: 5px; }
.global-checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--text-muted); cursor: pointer; }


/* Utilitarias Globales */
.global-flex-row { display: flex; align-items: center; gap: 15px; }
.global-flex-between { justify-content: space-between; }
.global-margin-bottom { margin-bottom: 20px; }
.global-text-bold { font-weight: bold; }
.global-text-secondary { color: #4a5568; }
.global-input-search { width: 100%; max-width: 400px; }
.global-pagination-wrapper { margin-top: 20px; display: flex; gap: 5px; justify-content: center; }
.global-grid-2-col { display: grid; grid-template-columns: 1fr 1fr; gap: 25px; }
@media (max-width: 768px) { .global-grid-2-col { grid-template-columns: 1fr; } }

/* Texto Utilities */
.text-danger-custom, .global-text-danger { color: #e53e3e !important; }
.text-muted-custom { color: #718096; font-size: 0.95rem; }
.global-text-primary { color: #2b6cb0; font-size: 1.3rem; font-weight: bold; }
.global-text-right { text-align: right !important; }
.global-text-center { text-align: center !important; }
.m-0 { margin: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }

/* Botones Viejos (Legacy) */
.global-btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 8px 16px; border: none; border-radius: 6px;
    font-weight: 600; font-size: 0.85rem; cursor: pointer;
    text-decoration: none; transition: background-color 0.2s, opacity 0.2s, transform 0.1s;
}
.global-btn:hover { opacity: 0.9; }
.global-btn:active { transform: scale(0.98); }
.global-btn-primary { background-color: var(--brand-blue); color: white; }
.global-btn-success { background-color: #48bb78; color: white; }
.global-btn-danger  { background-color: #e53e3e; color: white; }
.global-btn-secondary { background-color: var(--border-color); color: #4a5568; }


/* ======================================================================
   💡 MODALES ESTILO BOOTSTRAP 5.3 (CLON NATIVO PREMIUM)
   ====================================================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(33, 37, 41, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1055;

    /* Antídoto Anti-Congelamiento */
    display: flex;
    visibility: hidden;
    pointer-events: none;

    align-items: flex-start;
    justify-content: center;
    padding-top: 3.5rem;
    opacity: 0;
    transition: opacity 0.2s ease-out, visibility 0.2s ease-out;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* La Caja Blanca Principal (BLINDADA) */
.modal-box {
    background-color: #ffffff !important;
    padding: 0 !important;
    border: 1px solid rgba(0, 0, 0, 0.175);
    border-radius: 0.5rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    width: 100%;
    max-width: 500px;
    overflow: hidden !important;
    transform: translateY(-50px);
    transition: transform 0.3s ease-out;
    display: flex;
    flex-direction: column;
}

.modal-overlay.active .modal-box {
    transform: translateY(0);
}

/* Tallas extras para modales */
.modal-sm { max-width: 400px; }
.modal-lg { max-width: 650px; }

/* Cabecera del Modal */
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
    background-color: #f8fafc;
    border-top-left-radius: calc(0.5rem - 1px);
    border-top-right-radius: calc(0.5rem - 1px);
}

.modal-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 500;
    line-height: 1.5;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Botón X de cierre */
.btn-close-modal {
    box-sizing: content-box;
    width: 1em;
    height: 1em;
    padding: 0.25em 0.25em;
    color: #000;
    background: transparent;
    border: 0;
    border-radius: 0.375rem;
    opacity: 0.5;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s;
}
.btn-close-modal:hover { opacity: 0.85; }

/* Cuerpo del Modal */
.modal-body {
    position: relative;
    flex: 1 1 auto;
    padding: 1.5rem !important;
    color: #212529;
    overflow-y: auto;
    max-height: 65vh;
}

/* ======================================================================
   PIE DEL MODAL Y BOTONES PASTEL (Cuadrícula Estricta 2x2)
   ====================================================================== */
.modal-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    background-color: #fcfcfc;
    border-bottom-right-radius: calc(0.5rem - 1px);
    border-bottom-left-radius: calc(0.5rem - 1px);
    gap: 16px;
}

.bs-btn {
    flex: 1 1 calc(50% - 8px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 600;
    cursor: pointer;
    padding: 0.85rem 1rem;
    font-size: 0.95rem;
    border-radius: 0.5rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    position: relative;
}

.bs-btn:active { transform: scale(0.96); }

/* Separador Vertical Inteligente 2.0 */
.modal-footer .bs-btn:nth-child(even)::before {
    content: '';
    position: absolute;
    left: -9px;
    top: 20%;
    height: 60%;
    width: 1px;
    background-color: #cbd5e0;
}

.bs-btn-secondary { background-color: #f1f5f9; color: #475569; border-color: #e2e8f0; }
.bs-btn-secondary:hover { background-color: #e2e8f0; color: #334155; }

.bs-btn-primary { background-color: #ebf8ff; color: #2b6cb0; border-color: #bee3f8; }
.bs-btn-primary:hover { background-color: #bee3f8; color: #2c5282; }

.bs-btn-danger { background-color: #fff5f5; color: #c53030; border-color: #fed7d7; }
.bs-btn-danger:hover { background-color: #fed7d7; color: #9b2c2c; }

.bs-btn-success { background-color: #f0fff4; color: #2f855a; border-color: #c6f6d5; }
.bs-btn-success:hover { background-color: #c6f6d5; color: #276749; }

@media (max-width: 480px) {
    .bs-btn { flex: 1 1 100%; }
    .modal-footer .bs-btn:nth-child(even)::before { display: none; }
}


/* ======================================================================
   PARCHE SWEETALERT2 (DOMANDO EL MODO CAMALEÓN)
   ====================================================================== */
.modal-box .swal2-html-container {
    margin: 0 !important;
    padding: 1.5rem 1.5rem 0 1.5rem !important;
    font-size: 0.95rem;
    color: #718096;
}

.modal-box .swal2-input,
.modal-box .swal2-input.global-input {
    width: calc(100% - 3rem) !important;
    margin: 1rem auto 1.5rem auto !important;
    box-sizing: border-box !important;
    display: block;
}

.modal-box .swal2-validation-message {
    margin: 0 1.5rem 1.5rem 1.5rem !important;
    background: #fff5f5;
    color: #c53030;
    border-radius: 6px;
}

.modal-box .swal2-actions {
    width: 100%;
    box-sizing: border-box;
    margin: 0 !important;
}


/* ======================================================================
   NOTIFICACIONES (TOASTS)
   ====================================================================== */
#pos-notification-container {
    position: fixed;
    top: 70px;
    right: 20px;
    z-index: 9999;
    width: 300px;
}

.alert-pastel {
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 8px;
    border: 1px solid transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.alert-pastel.success { background-color: #dcfce7; color: #166534; border-color: #bbf7d0; }
.alert-pastel.danger { background-color: #fee2e2; color: #991b1b; border-color: #fecaca; }
.alert-pastel.info { background-color: #dbeafe; color: #1e40af; border-color: #bfdbfe; }

.btn-close-pastel {
    background: none;
    border: none;
    cursor: pointer;
    font-weight: bold;
    margin-left: 10px;
    opacity: 0.6;
}
.btn-close-pastel:hover { opacity: 1; }

/* ======================================================================
   SCROLLBARS PREMIUM (Estilo macOS / Minimalista)
   ====================================================================== */

/* 1. Para navegadores modernos (Chrome, Edge, Safari) */
::-webkit-scrollbar {
    width: 6px;  /* 💡 Muy delgado para scroll vertical */
    height: 6px; /* 💡 Muy delgado para scroll horizontal (categorías) */
}

/* El riel (La línea delgada del fondo) */
::-webkit-scrollbar-track {
    background: #fff0; /* Gris ultra claro, casi invisible */
    border-radius: 5px;
}

/* El pulgar (El rectángulo gris que se mueve) */
::-webkit-scrollbar-thumb {
    background: #cbd5e0; /* Gris pastel elegante */
    border-radius: 10px;
    transition: background 0.3s ease;
}

/* Efecto hover cuando agarras el scroll */
::-webkit-scrollbar-thumb:hover {
    background: #a0aec0; /* Se oscurece ligeramente para indicar que lo estás tocando */
}

/* 2. Para Firefox (Usa un estándar diferente pero logramos lo mismo) */
* {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e0 #f8fafc;
}

/* ==================================================================
   📱 RESPONSIVE DESIGN - DASHBOARD MASTER LAYOUT
   ================================================================== */
@media screen and (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 260px !important;
        z-index: 9999;
        transform: translateX(0);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 15px rgba(0,0,0,0.2);
    }

    .sidebar.collapsed { transform: translateX(-100%); }
    .main-wrapper { margin-left: 0 !important; width: 100%; }
    .navbar { flex-wrap: wrap; padding: 10px 15px; min-height: 60px; }
    .welcome-text { display: none; }

    #dynamic-actions {
        width: 100%;
        display: flex;
        justify-content: center;
        order: 3;
        margin-top: 10px;
    }

    #dynamic-actions button { width: 100%; text-align: center; padding: 10px; }
    #top-module-title .global-module-title { font-size: 1.1rem; }
}
/* ======================================================================
   PARCHE SWEETALERT2 (DOMANDO A LA LIBRERÍA - TONOS PASTEL)
   ====================================================================== */
div.swal2-popup {
    border-radius: 12px !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1) !important;
    padding: 25px 20px !important;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
}

div.swal2-title {
    color: #2d3748 !important;
    font-size: 1.4rem !important;
}

div.swal2-html-container {
    color: #718096 !important;
    font-size: 1rem !important;
}

div.swal2-actions {
    gap: 15px !important;
    margin-top: 25px !important;
    width: 100% !important;
}

/* Forzar que los botones de SweetAlert usen todo el ancho si hay varios */
.swal2-actions .bs-btn {
    margin: 0 !important;
    flex: 1; /* Hace que "Cancelar" y "Aceptar" midan lo mismo */
}
