/* =========================================
   1. VARIABLES Y CONFIGURACIÓN GLOBAL
   ========================================= */
:root {
    --primary:   #007bff;   /* Azul Principal */
    --success:   #10b981;   /* Verde Éxito/Ganador */
    --danger:    #dc2626;   /* Rojo Borrar/Error */
    --secondary: #6c757d;   /* Gris Secundario */
    --dark:      #333333;   /* Negro/Gris Oscuro */
    --light:     #f2f4f8;   /* Fondo Web */
    --white:     #ffffff;
    --radius:    12px;      /* Redondeado de tarjetas */
}

* {
    box-sizing: border-box; /* Vital para que los paddings no rompan el diseño */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--light);
    margin: 0;
    padding-bottom: 80px; /* Espacio extra abajo para el scroll */
    color: var(--dark);
}

.container {
    padding: 15px;
    max-width: 100%;
    margin: 0 auto;
}

/* =========================================
   2. BARRA SUPERIOR Y MENÚ (MÓVIL)
   ========================================= */
.header-bar {
    background: var(--dark);
    color: var(--white);
    padding: 15px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    height: 60px;
}

.menu-btn {
    font-size: 24px;
    cursor: pointer;
    margin-right: 15px;
    background: none;
    border: none;
    color: var(--white);
    padding: 0;
}

.page-title {
    font-size: 1.2rem;
    font-weight: bold;
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* MENÚ LATERAL (SIDENAV) */
.sidenav {
    height: 100%;
    width: 0; /* Cerrado por defecto en móvil */
    position: fixed;
    z-index: 2000;
    top: 0;
    left: 0;
    background-color: #111;
    overflow-x: hidden;
    transition: 0.3s;
    padding-top: 15px !important;         /* 50px;*/
    box-shadow: 2px 0 5px rgba(0,0,0,0.5);
}

.sidenav a {
    padding: 15px 30px;
    text-decoration: none;
    font-size: 18px;
    color: #818181;
    display: block;
    transition: 0.3s;
    border-bottom: 1px solid #222;
}

.sidenav a:hover { color: #f1f1f1; background-color: #222; }

.sidenav .closebtn {
    position: absolute !important;
    top: 5px; 
	right: 15px; 
	z-index: 10;
    font-size: 36px; margin-left: 50px;
    border: none; padding: 10px; 
    color: var(--white); background: transparent; cursor: pointer;
}

/* Fondo oscuro (Backdrop) */
#backdrop {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1500;
}

/* =========================================
   3. TARJETAS Y REJILLA (GRID)
   ========================================= */

/* Contenedor Grid Responsivo */
#resultados, #contenedorResultados {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

/* Estilo Base de Tarjeta */
.card, .card-comparativa {
    background: var(--white);
    border-radius: var(--radius);
    padding: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    border: 1px solid #eee;
    transition: transform 0.2s;
    overflow: hidden;
    height: 100%; 
    display: flex;
    flex-direction: column;
}

/*.card:active { transform: scale(0.98); } */

/* Cabeceras de Tarjeta */
.card-header, .card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 10px;
}

/* Cabecera oscura específica del comparador */
.card-head {
    background: var(--dark);
    color: var(--white);
    margin: -15px -15px 15px -15px; 
    padding: 12px 15px;
}

.card-sub, .prod-fam { 
    color: #ffffff; font-size: 0.9rem; margin-bottom: 15px; 
}

/* Acciones */
.card-actions {
    margin-top: auto; 
    display: flex;
    gap: 10px;
    padding-top: 10px;
}

/* =========================================
   4. FORMULARIOS Y BOTONES
   ========================================= */
.filtros-box {
    background: var(--white);
    padding: 15px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.form-control {
    width: 100%;
    padding: 12px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    background: #f9f9f9;
}

.form-control:focus {
    background: var(--white);
    border-color: var(--primary);
    outline: none;
}

/* Botones */
.btn, .btn-primary, .btn-danger, .btn-success, .btn-secondary {
    border: none;
    padding: 10px 0;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    display: block; 
    width: 100%;
    transition: opacity 0.2s;
}

.btn:hover { opacity: 0.9; }

.btn-primary   { background: var(--primary); color: white; }
.btn-danger    { background: #fee2e2; color: var(--danger); }
.btn-success   { background: var(--success); color: white; }
.btn-secondary { background: #e5e7eb; color: #374151; }

/* Botón Flotante */
.btn-float {
    display: block;
    width: 100%; 
    padding: 15px;
    margin-bottom: 15px;
    font-size: 1.1rem;
    background: var(--primary);
    color: white;
    border-radius: var(--radius);
    text-decoration: none;
    text-align: center;
    box-shadow: 0 4px 10px rgba(0,123,255,0.3);
}

/* =========================================
   5. UTILIDADES (Precios, Alertas, Badges)
   ========================================= */
.badge {
    background: #eef2ff;
    color: #4f46e5;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
}

.alerta { padding: 15px; border-radius: 8px; margin-bottom: 20px; text-align: center; }
.exito  { background: #d1fae5; color: #065f46; }

/* Formulario Edición Precios */
.precio-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid #f0f0f0; }
.precio-input { width: 100px; padding: 8px; text-align: right; border: 1px solid #ddd; border-radius: 6px; }

/* Comparador */
.grid-precios { flex-grow: 1; }
.fila-precio { display: flex; justify-content: space-between; align-items: center; padding: 12px 15px; border-bottom: 1px solid #f0f0f0; font-size: 0.95rem; }

/* CORRECCIÓN APLICADA AQUÍ: Se añade "border: 2px solid" */
.fila-precio.ganador { background-color: #e6fffa; color: #047857; font-weight: bold; border: 2px solid var(--success); }

.fila-precio.sin-precio { color: #ccc; }
.ganador .prov-nombre { color: #047857; }
.error { background: #fee2e2; color: #991b1b; border: 1px solid #f87171; }

/* =========================================
   6. VERSIÓN ESCRITORIO (PC > 1024px)
   ========================================= */
@media (min-width: 1024px) {
    
    .container {
        max-width: 1200px; 
    }

    /* MENÚ SIEMPRE ABIERTO Y FIJO A LA IZQUIERDA */
    .sidenav {
        width: 250px !important;
        padding-top: 80px;
        box-shadow: none;
        border-right: 1px solid #333;
    }

    /* Ocultamos elementos móviles */
    .sidenav .closebtn { display: none; }
    .menu-btn { display: none; }
    #backdrop { display: none !important; }

    /* EMPUJAMOS EL CONTENIDO A LA DERECHA Y ABAJO*/
    body {
        margin-left: 250px;
        padding-top: 80px;
    }
    
    /* ARREGLAMOS LA BARRA SUPERIOR PARA QUE NO LA TAPE EL MENÚ */
    .header-bar {
        left: 250px; 
        width: calc(100% - 250px);
        position: fixed; 
    }

    /* BOTÓN FLOTANTE */
    .btn-float {
        position: fixed;
        bottom: 40px; right: 40px;
        width: auto;
        border-radius: 50px;
        padding: 15px 30px;
        z-index: 90;
    }
}

/* Quitar las flechas (spinners) de los inputs numéricos */

/* Para Chrome, Safari, Edge, Opera */
input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  appearance: none; /* <-- Esto es lo que pedía VS Code */
  margin: 0; 
}

/* Para Firefox */
input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield; /* <-- Esto es lo que pedía VS Code */
}

/* =========================================================
   ESTILOS ESPECÍFICOS DE LA APP BALANCE Y RRHH
   ========================================================= */

/* Textos de importes */
.ingreso-text { color: var(--success, #10b981); font-weight: bold; }
.gasto-text { color: var(--danger, #ef4444); font-weight: bold; }
.nomina-text { color: #0284c7; font-weight: bold; }
.text-right { text-align: right !important; }

/* Tablas secundarias (Movimientos y nóminas) */
.tabla-movs { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.tabla-movs th, .tabla-movs td { padding: 12px; border-bottom: 1px solid #eee; text-align: left; }
.tabla-movs th { background: #f8fafc; color: #64748b; font-size: 0.85rem; text-transform: uppercase;}
.fila-inactiva { opacity: 0.6; background-color: #f9fafb; }

/* Badges (Etiquetas de estado) */
.badge-compras { background: #d1fae5; color: #065f46; padding: 4px 8px; border-radius: 6px; font-size: 0.75rem; font-weight: bold; }
.badge-finanzas { background: #f3f4f6; color: #4b5563; padding: 4px 8px; border-radius: 6px; font-size: 0.75rem; font-weight: bold; }
.badge-inactivo { background: #fee2e2; color: #991b1b; padding: 4px 8px; border-radius: 6px; font-size: 0.75rem; font-weight: bold; text-decoration: line-through; }
.badge-adelantos { background: #e0e7ff; color: #3730a3; padding: 4px 8px; border-radius: 6px; font-size: 0.75rem; font-weight: bold; margin-right: 4px; display: inline-block; margin-bottom: 4px; }
.badge-nominas { background: #d1fae5; color: #065f46; padding: 4px 8px; border-radius: 6px; font-size: 0.75rem; font-weight: bold; display: inline-block; margin-bottom: 4px; }

/* Botones pequeños de acción en tablas */
.btn-sm { padding: 6px 10px; font-size: 0.8rem; border-radius: 6px; text-decoration: none; display: inline-block; font-weight: bold; margin-bottom: 4px; cursor: pointer; border: none; }
.btn-archivar { background: #fca5a5; color: #7f1d1d; }
.btn-recuperar { background: #bbf7d0; color: #166534; }
.btn-quitar { background: #fef3c7; color: #92400e; }
.btn-poner { background: #e0e7ff; color: #3730a3; }
.btn-toggle-on { background: #fef3c7; color: #92400e; border: 1px solid #f59e0b; }
.btn-toggle-off { background: #f3f4f6; color: #4b5563; border: 1px solid #d1d5db; }

/* Contenedor de Checkbox bonito */
.checkbox-container { display: flex; align-items: center; gap: 10px; margin: 8px 0; cursor: pointer; background: #f8fafc; padding: 10px; border-radius: 8px; border: 1px solid #e2e8f0; }
.checkbox-container input[type="checkbox"] { width: 20px; height: 20px; cursor: pointer; }

/* =========================================================
   ESTILOS ESPECÍFICOS DEL DASHBOARD (PANEL DE CONTROL)
   ========================================================= */
.grid-dashboard { display: grid; grid-template-columns: 1fr; gap: 20px; }
@media (min-width: 1024px) { .grid-dashboard { grid-template-columns: 2fr 1fr; } }

.widget-container { display: flex; gap: 15px; margin-bottom: 25px; flex-wrap: wrap; }
.widget { flex: 1; min-width: 150px; padding: 20px; border-radius: 12px; text-align: center; color: white; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); }

.bg-ingresos { background: #d1fae5; color: #065f46; } 
.bg-gastos { background: #fee2e2; color: #991b1b; }   
.bg-balance { background: #fef3c7; color: #92400e; }  

.val-big { font-size: 1.6rem; font-weight: bold; display: block; margin-top: 5px; }

.tabla-dashboard { width: 100%; border-collapse: collapse; margin-top: 0px; font-size: 0.95rem; }
.tabla-dashboard th, .tabla-dashboard td { padding: 12px; border-bottom: 1px solid #eee; text-align: right; }
.tabla-dashboard th { background: #f8fafc; color: #64748b; font-size: 0.8rem; text-transform: uppercase; }
.tabla-dashboard td:first-child, .tabla-dashboard th:first-child { text-align: left; font-weight: bold; color: #333; }

.pos { color: #059669; font-weight: 500; }
.neg { color: #dc2626; font-weight: 500; }

.card-head-dashboard {
    background: var(--dark, #333);
    color: var(--white, #fff);
    padding: 10px 25px; /* <-- Rebajado de 15 a 10 para hacerla más fina */
    font-size: 1.1rem;
    font-weight: bold;
    border-radius: 12px 12px 0 0;
    cursor: pointer;
    user-select: none; /* Evita que se seleccione el texto al hacer doble clic */
    transition: background 0.3s;
}

.card-head-dashboard:hover {
    background-color: #637999; /* Un gris muy clarito al pasar el ratón */
}


/* =========================================================
   AJUSTES BLINDADOS PARA EL BUSCADOR SELECT2
   ========================================================= */
/* 1. UNIFICAR CUERPO Y FUENTE (Para que la letra sea idéntica) */
.form-control, 
.select2-container--default .select2-selection--single .select2-selection__rendered {
    font-family: Arial, sans-serif !important; 
    font-size: 1rem !important; /* Igualamos al tamaño que tenías en Select2 */
    color: #333 !important;
    line-height: normal !important;
}

/* 2. UNIFICAR CONTENEDOR (Altura, bordes y fondo) */
.form-control,
.select2-container .select2-selection--single { 
    height: 44px !important; 
    border: 1px solid #ccc !important; 
    border-radius: 8px !important; 
    background: #f9f9f9 !important;
    display: flex !important; 
    align-items: center !important;
    padding-left: 8px !important; /* Unificamos el espacio interno */
    box-sizing: border-box !important;
}

/* 3. AJUSTES ESPECÍFICOS PARA SELECT2 (Para que no se rompa la flecha) */
.select2-container--default .select2-selection--single .select2-selection__rendered { 
    padding-left: 4px !important; /* Ajuste fino para el texto dentro del buscador */
}

.select2-container--default .select2-selection--single .select2-selection__arrow { 
    height: 42px !important; 
}

/* Quitar el borde azul por defecto en ambos para mantener estética limpia */
.form-control:focus,
.select2-container--default.select2-container--focus .select2-selection--single {
    border-color: #aaa !important;
    outline: none !important;
}

.fila-graficos {
        display: flex;
        flex-wrap: wrap; /* Permite que el segundo baje si no cabe */
        gap: 20px;
        margin-bottom: 20px;
}

.card-grafico {
        background: white;
        padding: 20px;
        border-radius: 8px;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        flex: 1; /* Hace que crezcan por igual */
        min-width: 450px; /* Si la pantalla es menor a 900px (450+450), el segundo baja */
        height: fit-content;
}

.titulo-grafico {
        margin-top: 0;
        color: #1e293b;
        font-size: 1.1rem;
        margin-bottom: 15px;
}

.canvas-container {
        height: 350px; /* Un poco más de altura para que luzcan */
        position: relative;
}

/* Ajuste para móviles */
@media (max-width: 600px) {
	.card-grafico {
				min-width: 100%; /* En móviles ocupan todo el ancho */
				padding: 10px;
	}
	.canvas-container {
				height: 300px;
	}
}

/* 1. Ocultamos el icono por completo */
#fecha_pago::-webkit-calendar-picker-indicator {
    display: none !important;
    -webkit-appearance: none !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
}

/* 2. Aseguramos que el input se vea limpio y a la izquierda */
#fecha_pago {
    text-align: center !important;
    padding-left: 10px !important;
    cursor: pointer;
    -moz-appearance: textfield; /* Para Firefox */
}