/* ==========================================================================
   REGLAS CRÍTICAS DE VISIBILIDAD (Garantiza que los modales inicien ocultos)
   ========================================================================== */
.oculto { display: none !important; }

/* ==========================================================================
   VARIABLES Y BASE DE DISEÑO
   ========================================================================== */
#hugo-app-container {
    --bg-fondo: #f8fafc;          
    --bg-cajas: #ffffff;          
    --borde: #e2e8f0; 
    --borde-fuerte: #cbd5e1;
    
    --texto-principal: #0f172a;   /* Texto muy oscuro para máximo contraste sobre blanco */
    --texto-secundario: #475569;  /* Gris oscuro para textos secundarios legibles */
    
    --primario: #2563eb;          
    --primario-hover: #1e40af;
    --primario-light: #eff6ff;
    
    --verde: #10b981;             
    --verde-hover: #059669;
    --verde-light: #ecfdf5;
    
    --rojo: #ef4444;              
    --rojo-hover: #dc2626;
    --rojo-light: #fef2f2;
    
    --amarillo: #f59e0b;
    --amarillo-light: #fffbeb;

    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--texto-principal);
    max-width: 1400px;
    margin: 20px auto;
    line-height: 1.5;
}

#hugo-app-container * { box-sizing: border-box; }

/* ==========================================================================
   CABECERA Y HEADER
   ========================================================================== */
.hugo-header {
    display: flex; justify-content: space-between; align-items: center;
    background: var(--bg-cajas); padding: 24px 30px; border-radius: 16px;
    border: 1px solid var(--borde); margin-bottom: 24px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}
.header-titulos h2 { margin: 0; font-size: 24px; font-weight: 800; color: var(--primario); }
.subtitulo-header { color: var(--texto-secundario); font-size: 14px; font-weight: 500; }
.header-acciones { display: flex; flex-wrap: wrap; gap: 12px; }

/* ==========================================================================
   BUSCADOR GLOBAL FLOTANTE
   ========================================================================== */
.buscador-global-container {
    background: white;
    padding: 24px;
    border-radius: 16px;
    margin-bottom: 24px;
    border: 1px solid var(--borde);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}
.grupo-buscador-global {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}
.lupa-icon { position: absolute; left: 18px; font-size: 20px; color: var(--primario); pointer-events: none; }
#input-buscador-global {
    width: 100%;
    padding: 16px 20px 16px 52px;
    font-size: 17px;
    color: var(--texto-principal);
    border: 2px solid var(--borde-fuerte);
    border-radius: 12px;
    background: #f8fafc;
    transition: all 0.3s ease;
}
#input-buscador-global::placeholder { color: #94a3b8; }
#input-buscador-global:focus {
    background: white; border-color: var(--primario);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1); outline: none;
}
#indicador-busqueda { position: absolute; right: 20px; font-size: 13px; color: var(--texto-secundario); font-weight: 700; }

/* Dropdown Flotante */
#resultados-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    width: 100%;
    background: white;
    border: 1px solid var(--borde-fuerte);
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    z-index: 1000;
    max-height: 450px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#lista-resultados-global {
    overflow-y: auto;
    flex: 1;
}
.pie-desplegable {
    background: #f8fafc;
    padding: 12px 20px;
    border-top: 1px solid var(--borde);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.btn-link { background: none; border: none; color: var(--primario); font-weight: 700; cursor: pointer; text-decoration: underline; }

/* ==========================================================================
   BOTONERAS UNIFICADAS (SOLUCIÓN HOVER FONDO BLANCO)
   ========================================================================== */
.botonera-unificada {
    display: flex;
    flex-wrap: wrap; 
    gap: 10px;
    width: 100%;
}

.btn-item-seleccion {
    flex: 1 1 calc(25% - 10px); 
    min-width: 90px;
    padding: 12px 10px;
    font-size: 14px;
    font-weight: 700;
    border: 2px solid var(--borde-fuerte);
    border-radius: 10px;
    background: white;
    color: var(--texto-secundario);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap; 
}

/* --- SOLUCIÓN A LETRAS BLANCAS --- 
   Ahora el hover es celeste claro con texto azul marino fuerte. 
   Esto garantiza visibilidad 100% en fondos blancos. */
.btn-item-seleccion:hover, .btn-item-seleccion.activo {
    background: var(--primario-light) !important; /* Celeste suave (#eff6ff) */
    color: var(--primario-hover) !important;      /* Azul oscuro (#1e40af) NO blanco */
    border-color: var(--primario) !important;     /* Borde azul intenso */
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.1);
    transform: translateY(-2px);
}

.prov-check { font-weight: 900; margin-right: 6px; }

/* ==========================================================================
   FORMULARIOS Y CAJAS
   ========================================================================== */
.hugo-layout-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }
.caja-seccion {
    background: var(--bg-cajas); border-radius: 16px; padding: 28px;
    border: 1px solid var(--borde); margin-bottom: 24px; position: relative;
}
.titulo-seccion { margin-top: 0; margin-bottom: 20px; color: var(--texto-principal); font-size: 18px; font-weight: 800; border-bottom: 2px solid var(--borde); padding-bottom: 12px; }

.accent-blue::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 5px; background: var(--primario); }
.accent-yellow::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 5px; background: var(--amarillo); }
.accent-green::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 5px; background: var(--verde); }

.grid-form-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 15px; }
.grid-form-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 15px; }
.grupo-input label { display: block; font-weight: 700; margin-bottom: 8px; font-size: 13px; color: var(--texto-principal); text-transform: uppercase; }
.grupo-input input, .grupo-input select, .grupo-input textarea { 
    width: 100%; padding: 12px; border: 2px solid var(--borde-fuerte); 
    border-radius: 10px; font-size: 15px; background: white; color: var(--texto-principal);
}
.grupo-input input:focus, .grupo-input select:focus, .grupo-input textarea:focus { 
    border-color: var(--primario); outline: none; box-shadow: 0 0 0 3px rgba(37,99,235,0.1); 
}

/* ==========================================================================
   PESTAÑAS
   ========================================================================== */
.hugo-pestanas { display: flex; gap: 10px; border-bottom: 2px solid var(--borde); margin-bottom: 20px; overflow-x: auto; padding-bottom: 5px; }
.pestana { 
    padding: 12px 20px; background: none; border: none; border-bottom: 3px solid transparent; 
    font-size: 15px; font-weight: 700; color: var(--texto-secundario); cursor: pointer; white-space: nowrap; 
}
.pestana:hover { color: var(--primario); }
.pestana.activa { color: var(--primario); border-bottom-color: var(--primario); }
.badge { display: inline-block; background: var(--borde); color: var(--texto-principal); padding: 2px 8px; border-radius: 20px; font-size: 12px; margin-left: 6px; font-weight: 800; }
.pestana.activa .badge { background: var(--primario-light); color: var(--primario); }

/* ==========================================================================
   GESTIÓN DE TABLA Y URGENCIA
   ========================================================================== */
.hugo-tabla-contenedor { overflow-x: auto; border: 1px solid var(--borde); border-radius: 12px; }
#tabla-pedidos { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 700px; }
#tabla-pedidos th { 
    background: #f8fafc; padding: 14px; text-align: left; 
    color: var(--texto-principal); font-size: 13px; 
    text-transform: uppercase; font-weight: 800; border-bottom: 2px solid var(--borde); 
}
#tabla-pedidos td { padding: 16px 14px; border-bottom: 1px solid var(--borde); vertical-align: top; }

/* Casillas de selección masiva */
#tabla-pedidos input[type="checkbox"] {
    accent-color: var(--primario);
    width: 18px;
    height: 18px;
}

/* Badges de prioridad clickeables */
.badge-urgencia-toggle {
    padding: 4px 10px; border-radius: 6px; font-size: 11px; font-weight: 800;
    cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
    transition: 0.2s; user-select: none; border: 1px solid transparent;
}
.badge-urgencia-toggle.urgente { background: var(--rojo); color: white; }
.badge-urgencia-toggle.normal { background: var(--verde-light); color: var(--verde-hover); border-color: var(--verde); }
.badge-urgencia-toggle:hover { transform: scale(1.05); filter: brightness(1.1); }

tr.fila-urgente { background-color: var(--rojo-light) !important; border-left: 4px solid var(--rojo) !important; }

/* Inputs de Filtro de Tabla */
.input-filtro { padding: 10px 14px; border: 2px solid var(--borde-fuerte); border-radius: 8px; font-size: 14px; flex: 1; min-width: 200px; color: var(--texto-principal); background: white; }

/* ==========================================================================
   BOTONES DE ACCIÓN 
   ========================================================================== */
.btn-accion { 
    padding: 10px 14px; border-radius: 8px; font-size: 13px; font-weight: 700; 
    border: none; cursor: pointer; transition: 0.2s; display: inline-flex; 
    align-items: center; gap: 6px; text-align: center;
}
.btn-verde { background: var(--verde); color: white; }
.btn-verde:hover { background: var(--verde-hover); }
.btn-rojo { background: var(--rojo); color: white; }
.btn-rojo:hover { background: var(--rojo-hover); }
.btn-gris { background: #f1f5f9; color: var(--texto-principal); border: 1px solid var(--borde-fuerte); }
.btn-gris:hover { background: #e2e8f0; }

.btn-guardar-principal { width: 100%; padding: 16px; background: var(--primario); color: white; border: none; border-radius: 10px; font-weight: 800; font-size: 16px; cursor: pointer; transition: 0.2s; }
.btn-guardar-principal:hover { background: var(--primario-hover); transform: translateY(-2px); }

.w-full-btn { width: 100%; justify-content: center; margin-bottom: 5px; }

/* ==========================================================================
   MODALES Y POPUPS
   ========================================================================== */
.hugo-modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.85); display: flex; justify-content: center; align-items: center; 
    z-index: 99999; backdrop-filter: blur(4px);
}
.hugo-modal-contenido { 
    background: white; padding: 35px; border-radius: 20px; width: 95%; max-width: 500px; 
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5); border: 1px solid var(--borde);
    max-height: 90vh; overflow-y: auto;
}
.animar-entrada { animation: modalFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes modalFadeIn { from { opacity: 0; transform: translateY(20px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ==========================================================================
   TAREAS Y TOASTS
   ========================================================================== */
.form-tareas { display: flex; gap: 10px; }
.form-tareas input { flex: 1; padding: 12px; border: 2px solid var(--borde-fuerte); border-radius: 8px; font-size: 14px; }
.btn-add-tarea { background: var(--texto-principal); color: white; border: none; border-radius: 8px; width: 45px; font-weight: bold; font-size: 18px; cursor: pointer; }

.lista-tareas-ui, .lista-lateral-ui { list-style: none; padding: 0; margin: 0; }

#hugo-toasts { position: fixed; bottom: 25px; right: 25px; display: flex; flex-direction: column; gap: 10px; z-index: 100000; pointer-events: none; }
.hugo-toast { background: #1e293b; color: white; padding: 16px 25px; border-radius: 12px; font-weight: 700; font-size: 14px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); border-left: 5px solid var(--primario); animation: toastIn 0.3s ease; }
.hugo-toast.error { border-left-color: var(--rojo); background: #7f1d1d; }

@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 1024px) {
    .hugo-layout-grid { grid-template-columns: 1fr; }
    .grid-form-3 { grid-template-columns: 1fr; }
    .span-2 { grid-column: span 1; }
}

@media (max-width: 768px) {
    .btn-item-seleccion { flex: 1 1 45%; } 
    .hugo-header { flex-direction: column; gap: 15px; text-align: center; }
    .grid-form-2 { grid-template-columns: 1fr; }
    .barra-herramientas-tabla { flex-direction: column; align-items: stretch !important; }
    .input-filtro { width: 100%; }
    #barra-acciones-masivas { flex-direction: column; align-items: stretch; }
}