/* 
  Estilos globales para Control Horario
  Aplicado a los paneles de Admin, Empleado y Fabricante para un look&feel homogéneo.
  Se utiliza principalmente Tailwind CSS, pero este fichero define bases y helpers.
*/

body {
  background-color: #f3f4f6; /* Tailwind gray-100 */
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
}

/* Transición suave para todos los botones */
button {
  transition: background-color 0.2s ease-in-out;
}

/*
  Clases de ayuda para colores de texto semánticos.
  Útil para aplicar estilos dinámicamente desde JS.
*/
.text-success, .saldo-positivo {
    color: #059669; /* Tailwind green-600 */
    font-weight: 600;
}

.text-danger, .saldo-negativo {
    color: #dc2626; /* Tailwind red-600 */
    font-weight: 600;
}

.text-info, .saldo-positivo-extra {
    color: #2563eb; /* Tailwind blue-600 */
    font-weight: 600;
}

/*
  Ajustes responsivos para pantallas pequeñas (móviles).
  Tailwind se encarga de la mayoría, pero aquí se pueden añadir ajustes globales.
*/
@media (max-width: 640px) {
    /* Reducir un poco el padding general en móviles */
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    /* Ajustar tamaños de fuente de cabeceras en móvil */
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.125rem; }
}

/* Estilo unificado para el eslogan en el pie de página */
footer #footerSlogan {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #94a3b8; /* Tailwind slate-400 */
}

/* Contenedor para tablas con scroll horizontal en móvil */
.table-wrapper {
  position: relative;
  overflow-x: auto;
}
.table-wrapper::-webkit-scrollbar {
  display: none; /* Oculta la barra de scroll en Chrome, Safari, etc. */
}
.table-wrapper {
  -ms-overflow-style: none;  /* Oculta la barra de scroll en IE y Edge */
  scrollbar-width: none;  /* Oculta la barra de scroll en Firefox */
}
@media (max-width: 768px) { /* breakpoint 'md' de Tailwind */
  .table-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 2rem;
    background: linear-gradient(to left, #ffffff, rgba(255, 255, 255, 0));
    pointer-events: none;
    border-radius: 0.5rem; /* Hereda el redondeo si lo hay */
  }
}

/* Estilos para los iconos de información */
.info-icon::before {
  content: 'i';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: serif;
  font-style: italic;
  font-weight: bold;
  color: #9ca3af; /* gray-400 */
  border: 1px solid #d1d5db; /* gray-300 */
  border-radius: 9999px; /* rounded-full */
  width: 1.25rem; 
  height: 1.25rem;
  line-height: 1;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
}
.info-icon:hover::before {
    background-color: #e5e7eb; /* gray-200 */
    color: #4b5563; /* gray-600 */
    border-color: #9ca3af; /* gray-400 */
}

/* --- Estilos de Foco Globales para Mejorar la Visibilidad --- */
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #0ea5e9; /* sky-500 */
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.4);
}

/* --- ESTILO PARA RESALTAR CAJAS DE FILTROS --- */
.filter-actions-box {
  border: 1px solid #bae6fd; /* sky-200 */
  box-shadow: 0 0 15px rgba(14, 165, 233, 0.2); /* sky-500 con opacidad */
}

/* --- TABLE SCROLLER BUTTONS (CORRECTED) --- */
.table-scroll-btn {
  position: sticky; /* <-- Clave para el posicionamiento */
  top: 50%;
  transform: translateY(-50%);
  background-color: rgba(255, 255, 255, 0.95);
  border: 1px solid #d1d5db; /* gray-300 */
  color: #374151; /* gray-700 */
  width: 2.5rem;   /* Aumentado para mejor tacto */
  height: 2.5rem;  /* Aumentado para mejor tacto */
  border-radius: 9999px;
  font-size: 1.5rem;
  font-weight: bold;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1); /* Sombra más pronunciada */
  transition: all 0.2s ease;
}

.table-scroll-btn.left { left: 0.5rem; }
.table-scroll-btn.right { right: 0.5rem; }

.table-scroll-btn:hover {
  background-color: #f9fafb; /* gray-50 */
  color: #000;
  transform: translateY(-50%) scale(1.05);
}

.table-scroll-btn:disabled {
  opacity: 0.2;
  cursor: not-allowed;
  transform: translateY(-50%) scale(1);
}

.table-scroll-btn.hidden {
  display: none;
}

/* --- ESTILOS PARA TARJETAS DE ESTADÍSTICAS --- */
.stat-card {
  padding: 1rem;
  border-radius: 0.5rem;
}
.stat-card-title {
  font-size: 0.875rem; /* text-sm */
  color: #4b5563; /* text-gray-600 */
  font-weight: 500;
}
.stat-card-number {
  font-size: 2.25rem; /* text-4xl */
  font-weight: 700; /* font-bold */
  line-height: 1.1;
  margin-top: 0.25rem;
}

.filter-btn-active {
  background-color: #dc2626 !important; /* red-600 */
  color: white !important;
  border-color: #b91c1c !important; /* red-700 */
}

.date-alert {
  color: #dc2626; /* red-600 */
  font-weight: 700; /* font-bold */
}

@media (max-width: 640px) {
  #fabCostHistoryContainer .accordion-header span.text-md {
    font-size: 0.875rem; /* Reduce de 'md' a 'sm' */
  }
}

@media (max-width: 640px) {
    #loginView h2 {
        font-size: 1.125rem; /* Título más pequeño */
        margin-bottom: 1rem;
    }
    #formLogin {
        gap: 0.75rem; /* Reduce el espacio entre campos */
    }
}

/* Corrección para modales en pantallas pequeñas */
.modal-content {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 4rem); /* Altura máxima del 90% de la pantalla */
}

#infoModalContent, #legalModalContent, .modal-form-content {
    overflow-y: auto; /* Permite scroll vertical SOLO en el contenido */
    flex-shrink: 1;
    min-height: 0;
    -webkit-overflow-scrolling: touch; /* AÑADIDO: Activa el scroll nativo en iOS */
}

/* --- FILTROS COMPACTOS PARA MÓVIL (FABRICANTE) --- */
@media (max-width: 640px) {

    /* Grid principal de filtros */
    .filter-actions-box .flex-wrap {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.5rem !important;
        align-items: end !important;
    }

    /* Inputs de Fecha (Inicio/Fin) */
    .filter-actions-box > div:has(input[type="date"]) {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
    }

    /* Selectores (Empresa): Ancho completo */
    .filter-actions-box > div:has(select) {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        margin: 0 !important;
    }
    .filter-actions-box select { width: 100% !important; }

    /* Estilo Inputs Fecha */
    .filter-actions-box input[type="date"] {
        width: 100% !important;
        font-size: 0.75rem !important;
        padding: 0.1rem 0.2rem !important;
        height: 2rem !important;
    }
    .filter-actions-box label {
        font-size: 0.7rem !important;
        margin-bottom: 0.1rem !important;
    }

    /* Forzar que los grupos de botones (Ayer/Hoy, etc.) ocupen TODO el ancho */
    .filter-actions-box .flex.items-center.rounded-md {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 2px !important;
        width: 100% !important; /* CLAVE */
        grid-column: 1 / -1 !important;
        box-shadow: none !important;
        background: transparent !important;
        margin-top: 0.25rem !important;
    }
    .filter-actions-box .flex.items-center.rounded-md button {
        width: 100% !important;
        justify-content: center !important;
        border-radius: 0.25rem !important;
        border: 1px solid #d1d5db !important;
        font-size: 0.7rem !important;
        padding: 0.3rem !important;
        margin: 0 !important;
    }

    /* Botones Acción */
    .filter-actions-box > button {
        grid-column: 1 / -1 !important;
        width: 100%;
        padding: 0.4rem !important;
        font-size: 0.8rem !important;
        margin-top: 0.25rem;
    }
    
    span[id^="fMsg"] {
        grid-column: 1 / -1; text-align: center; font-size: 0.7rem;
    }


}



/* --- CORRECCIONES VISUALES MÓVIL (FABRICANTE) --- */
@media (max-width: 640px) {

    /* 1. FILTROS RÁPIDOS: ALINEACIÓN 2 EN 2 */
    
    /* Convertir el contenedor de filtros en una cuadrícula estricta de 2 columnas */
    .filter-actions-box .flex-wrap {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.5rem !important;
        align-items: end !important;
    }

    /* Elementos que deben ocupar TODO el ancho (Selectores, Grupos de botones) */
    .filter-actions-box > div:has(select),
    .filter-actions-box .flex.items-center.rounded-md {
        grid-column: 1 / -1 !important;
        width: 100% !important;
    }

    /* Fechas: Ocupan 1 columna cada una (se ponen lado a lado) */
    .filter-actions-box > div:has(input[type="date"]) {
        width: 100% !important;
    }

    /* Botones de Acción (Cargar, Imprimir): Ponerlos en la cuadrícula (1 columna cada uno) */
    #btnLoadAssistances, #btnPrintAssistances,
    #btnLoadCostReport,
    #btnLoadFabCostHistory, #btnFabCostHistoryPdf {
        width: 100% !important;
        margin-top: 0 !important;
        font-size: 0.75rem !important;
        padding: 0.5rem 0.25rem !important;
        height: 100% !important;
        white-space: normal !important; /* Permitir texto en varias líneas si es largo */
        line-height: 1.2 !important;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
    }
    
    /* Forzar grupos de botones (Ayer/Hoy) a ser grid de 2 */
    .filter-actions-box .flex.items-center.rounded-md {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 1px !important;
        background: #e5e7eb;
        padding: 1px;
    }
    .filter-actions-box .flex.items-center.rounded-md button {
        width: 100% !important;
        border: none !important;
        margin: 0 !important;
    }


    /* 2. PESTAÑA COSTES: TEXTOS CORTADOS */
    
    /* Permitir que los textos largos de los botones se ajusten y no se salgan */
    #costsContent button {
        white-space: normal !important;
        height: auto !important;
        min-height: 2.5rem;
        padding: 0.5rem !important;
    }
    
    /* Contenedor de los filtros de año/mes en costes */
    #costsContent .flex-wrap {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
    }
    /* Botón Calcular Costes (ocupa 2 columnas) */
    #btnCalculateCosts {
        grid-column: 1 / -1 !important;
        width: 100% !important;
    }


    /* 3. PERSONALIZACIÓN: INPUT DE FICHERO */
    
    /* Hacemos que el contenedor del input de archivo sea vertical */
    #brandingContent .flex.items-center.gap-4 {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    
    /* El contenedor del botón "Seleccionar" y el nombre del archivo */
    #brandingContent .flex-1 > .flex.items-center {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    
    #fab_logo_select_btn {
        border-radius: 0.375rem 0.375rem 0 0 !important;
        border-right: 1px solid #d1d5db !important;
        border-bottom: none !important;
        width: 100% !important;
        text-align: center !important;
    }
    
    #fab_logo_name_display {
        border-radius: 0 0 0.375rem 0.375rem !important;
        border-left: 1px solid #d1d5db !important;
        border-top: 1px solid #d1d5db !important;
        width: 100% !important;
        text-align: center !important;
        display: block !important;
    }
    
    #fab_logo_preview {
        margin: 0 auto 1rem auto !important;
        max-height: 80px;
    }
}

/* --- CORRECCIÓN MAESTRA VISUAL MÓVIL (FABRICANTE) --- */
@media (max-width: 640px) {

    /* --- 1. FILTROS RÁPIDOS --- */
    .filter-actions-box .flex-wrap {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.5rem !important;
        align-items: end !important;
    }

    /* Fechas: Lado a lado */
    .filter-actions-box > div:has(input[type="date"]) {
        width: 100% !important;
        margin: 0 !important;
    }
    .filter-actions-box input[type="date"] {
        width: 100% !important;
        font-size: 0.75rem !important;
        padding: 0.2rem !important;
    }

    /* Selectores: Ancho completo */
    .filter-actions-box > div:has(select) {
        grid-column: 1 / -1 !important;
        width: 100% !important;
    }
    .filter-actions-box select { width: 100% !important; }

    /* Grupos de Botones Rápidos (Ayer/Hoy): Grid interno 2 cols */
    .filter-actions-box .flex.items-center.rounded-md {
        grid-column: 1 / -1 !important;
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        width: 100% !important;
        gap: 1px !important;
        background: #d1d5db;
        padding: 1px;
        margin-top: 0.25rem !important;
    }
    .filter-actions-box .flex.items-center.rounded-md button {
        width: 100% !important;
        margin: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        font-size: 0.75rem !important;
        justify-content: center !important;
    }

    /* Botones Finales (Cargar/Imprimir): LADO A LADO */
    /* Usamos selectores ID para asegurar que estos específicos se pongan en 2 columnas */
    #btnLoadAssistances, #btnPrintAssistances,
    #btnLoadCostReport, #btnLoadFabCostHistory, #btnFabCostHistoryPdf {
        grid-column: auto !important; /* Dejar que fluyan en el grid 1fr 1fr */
        width: 100% !important;
        font-size: 0.7rem !important;
        padding: 0.5rem 0.1rem !important;
        height: 100% !important;
        white-space: normal !important; /* Permitir que el texto baje de línea */
        line-height: 1.1 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
    }
    
    /* Mensajes */
    span[id^="fMsg"] { grid-column: 1 / -1 !important; text-align: center; font-size: 0.7rem; }


    /* --- 2. PESTAÑA COSTES (Solución desbordamiento) --- */
    
    /* Contenedor de filtros de costes */
    #costsContent .flex-wrap {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.5rem !important;
    }
    
    /* Botón Calcular: Ancho completo y texto ajustable */
    #btnCalculateCosts {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        white-space: normal !important;
        height: auto !important;
        padding: 0.5rem !important;
        font-size: 0.85rem !important;
    }

    /* --- 3. PERSONALIZACIÓN (Input Fichero) --- */
    
    /* Forzar columna vertical en el selector de archivo */
    #brandingContent .flex.items-center.gap-4 {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
    }
    
    /* Contenedor del input file */
    #brandingContent .flex-1 {
        width: 100% !important;
    }
    
    #brandingContent .flex-1 > .flex.items-center {
        flex-direction: column !important;
        width: 100% !important;
    }
    
    /* Botón Seleccionar */
    #fab_logo_select_btn {
        width: 100% !important;
        border-radius: 0.375rem 0.375rem 0 0 !important;
        border-right: 1px solid #d1d5db !important;
        border-bottom: none !important;
    }
    
    /* Texto nombre archivo */
    #fab_logo_name_display {
        width: 100% !important;
        border-radius: 0 0 0.375rem 0.375rem !important;
        border-left: 1px solid #d1d5db !important;
        border-top: 1px solid #d1d5db !important;
        text-align: center !important;
        padding: 0.5rem !important;
    }
}

/* --- CORRECCIÓN MAESTRA VISUAL MÓVIL (FABRICANTE) --- */
@media (max-width: 640px) {

    /* --- 1. FILTROS RÁPIDOS --- */
    .filter-actions-box .flex-wrap {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.5rem !important;
        align-items: stretch !important; /* Stretch para que botones tengan misma altura */
    }

    /* Fechas: Lado a lado (50% cada una) */
    .filter-actions-box > div:has(input[type="date"]) {
        width: 100% !important;
        margin: 0 !important;
    }
    .filter-actions-box input[type="date"] {
        width: 100% !important;
        font-size: 0.75rem !important;
        padding: 0.2rem !important;
    }
	/* Fechas: Lado a lado */
    .filter-actions-box > div:has(input[type="date"]) {
        grid-column: span 1 !important;
    }

    /* Selectores: Ancho completo */
    .filter-actions-box > div:has(select) {
        grid-column: 1 / -1 !important;
        width: 100% !important;
    }
    .filter-actions-box select { width: 100% !important; }

    /* Grupos de Botones Rápidos (Ayer/Hoy): Grid interno 2 cols */
    .filter-actions-box .flex.items-center.rounded-md {
        grid-column: 1 / -1 !important;
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        width: 100% !important;
        gap: 0.5rem !important;
        background: #d1d5db;
        padding: 1px;
        margin-top: 0.25rem !important;
    }
    .filter-actions-box .flex.items-center.rounded-md button {
        width: 100% !important;
        margin: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        font-size: 0.75rem !important;
        justify-content: center !important;
    }

    /* Botones Finales (Cargar/Imprimir): LADO A LADO (50% cada uno) */
    /* Al no poner grid-column 1/-1, se colocarán uno en cada celda disponible */
    .filter-actions-box > button {
        grid-column: span 1 !important; 
        width: 100% !important;
        font-size: 0.7rem !important;
        padding: 0.5rem 0.1rem !important;
        height: auto !important;
        min-height: 2.5rem !important;
        white-space: normal !important; /* Permitir que el texto baje de línea */
        line-height: 1.1 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        margin-top: 0.25rem !important;
    }
    
    /* Mensajes: Abajo del todo centrado */
    span[id^="fMsg"] { grid-column: 1 / -1 !important; text-align: center; font-size: 0.7rem; }


    /* --- 2. PESTAÑA COSTES (Solución desbordamiento) --- */
    
    /* Contenedor de filtros de costes */
    #costsContent .flex-wrap {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
    }
    
    #costsContent .flex-wrap > div {
        width: 100% !important;
    }

    /* Botón Calcular: Ancho completo y texto ajustable */
    #btnCalculateCosts, #btnLoadCostReport {
        white-space: normal !important;
        height: auto !important;
        padding: 0.75rem !important;
    }
    #costCompanySelect {
        min-width: 0 !important;
    }

    /* --- 3. PERSONALIZACIÓN (Input Fichero) --- */
    
    /* Forzar columna vertical en el selector de archivo */
    #brandingContent .flex.items-center.gap-4 {
        flex-direction: column !important;
        align-items: stretch !important;
        text-align: center !important;
    }
    
    /* Contenedor del input file */
    #brandingContent .flex-1 {
        width: 100% !important;
    }
    
    #brandingContent .flex-1 > .flex.items-center {
        flex-direction: column !important;
        width: 100% !important;
    }
    
    /* Botón Seleccionar */
    #fab_logo_select_btn {
        width: 100% !important;
        border-radius: 0.375rem 0.375rem 0 0 !important;
        border-right: 1px solid #d1d5db !important;
        border-bottom: none !important;
    }
    
    /* Texto nombre archivo */
    #fab_logo_name_display {
        width: 100% !important;
        border-radius: 0 0 0.375rem 0.375rem !important;
        border-left: 1px solid #d1d5db !important;
        border-top: 1px solid #d1d5db !important;
        text-align: center !important;
        padding: 0.5rem !important;
    }
}