/* Estilos Generales */

body {
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    background-color: #f0f2f5;
    margin: 0;
    padding: 0px;
    display: flex; /* Convierte el body en un contenedor flex */
    flex-direction: column; /* Organiza los elementos hijos (header, main, footer) en columna */
    min-height: 100vh; /* Asegura que el body ocupe al menos el 100% de la altura de la ventana */
}

h2 {
    color: #003366;
    text-align: center;
    display: block;
    width: fit-content;
    margin: 0 auto 10px auto;
}

/* Contenedores principales y formularios (regla global para pantalla) */
form,
.preview {
    max-width: 900px;
    margin: auto;
    padding: 20px;
    box-sizing: border-box;
}

/* ESTILOS ESPECÍFICOS PARA LAS PÁGINAS CON .container (licencia.html, horas_particulares.html) */
/* Esto asegura que el .container crezca en PANTALLA, empujando el footer. */
body > .container {
    flex-grow: 1; /* Permite que este contenedor se expanda */
    display: flex; /* Convierte .container en un flex container */
    flex-direction: column; /* Apila sus hijos (h2, form, preview) verticalmente */
}

/* Y los elementos dentro del .container también deben crecer en PANTALLA */
body > .container > form,
body > .container > .preview {
    flex-grow: 1; /* Permite que el formulario O la vista previa ocupen el espacio restante del .container */
    display: flex; /* Necesario para que su propio contenido se organice verticalmente */
    flex-direction: column;
}


/* Estilos para alinear los radio buttons en la página de horas particulares */
.radio-group {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 5px;
}

.radio-group input[type="radio"] {
    width: auto;
    padding: 0;
    margin-right: -10px;
}

.radio-group label {
    display: inline-block;
    font-weight: normal;
    color: inherit;
    margin-bottom: 0;
}

/* Nuevos estilos para agrupar campos en una misma fila (ej: fechas) */
.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 10px;
}

/* Estilos para los 'form-group' dentro de un 'form-row' */
.form-row .flex-item {
    flex: 1;
    min-width: 280px;
    margin-bottom: 0;
}

/* Estilos para el grupo de selección de funcionario (N° y Nombre) */
.funcionario-select-group {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    margin-top: 5px;
}

/* Ajustes específicos para las etiquetas y selects dentro de .funcionario-select-group */
.funcionario-select-group label {
    display: inline-block;
    font-weight: normal;
    color: inherit;
    margin-bottom: 0;
    flex-shrink: 0;
}

.funcionario-select-group select {
    flex-grow: 1;
    width: auto;
    min-width: 150px;
}

/* IMPORTANTE: Ocultar la vista previa por defecto */
.preview {
    display: none;
}

#previewContent {
    text-align: left;
}

/* Contenedor para cada grupo de firma */
.grupo-firma {
    margin-bottom: 50px;
    display: flex;
    align-items: baseline;
}

/* Estilo para el texto de la firma */
.firma-texto {
    text-align: right;
    margin-right: 15px;
    flex-shrink: 0;
    min-width: 280px;
}


/* Elementos de Formulario */
.form-group {
    margin-bottom: 10px;
}

.form-group label {
    font-weight: bold;
    color: #003366;
    display: block;
    margin-bottom: 4px;
}

select,
input[type="text"],
input[type="time"],
input[type="date"] {
    padding: 6px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 100%;
    box-sizing: border-box;
}

input[type="checkbox"] {
    width: auto;
}

/* Botones */
.btn {
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 500;
    background-color: #003366;
    color: white;
    border: 1px solid #1a252f;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out, box-shadow 0.2s;
    text-decoration: none;
    display: inline-block;
    box-sizing: border-box;
    vertical-align: middle;
    line-height: 1.2;
}

.btn:hover {
    background-color: #1f2a38;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* Para alinear botones al lado en el formulario */
.form-actions {
    display: flex;
    justify-content: flex-start;
    gap: 15px;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* Estilos para los botones de acción dentro de la vista previa */
#previewArea .actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

/* REGLA ESPECÍFICA: Para uniformar el tamaño Y centrar el texto SÓLO de los botones dentro de #previewArea .actions */
#previewArea .actions .btn {
    min-width: 150px;
    height: 42px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
}

/* Nuevos estilos para los botones de la página de selección (index.html) */
.selection-container {
    text-align: center;
    padding: 50px 20px;
}

.selection-button {
    display: inline-block;
    margin: 10px; /* Reduced margin */
    padding: 15px 25px; /* Reduced padding */
    font-size: 1.1em; /* Slightly reduced font size */
    text-decoration: none;
    background-color: #003366;
    color: white;
    border: 1px solid #1a252f;
    border-radius: 6px;
    transition: background-color 0.2s ease-in-out, box-shadow 0.2s;
    min-width: 220px; /* Slightly reduced min-width */
    box-sizing: border-box; /* Ensure padding is included */
}

.selection-button:hover {
    background-color: #1f2a38;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.selection-title {
    color: #003366;
    margin-bottom: 40px;
    font-size: 2.5em;
}


/* Tablas */
table {
    background-color: white;
    border: 1px solid #ccc;
    width: 100%;
    margin-top: 20px;
    border-collapse: collapse;
}

td,
th {
    padding: 6px;
    border: 1px solid #aaa;
    text-align: center;
}

/* Pie de página (Estilo general, se ajusta en impresión) */
.footer {
    text-align: center;
    font-size: 13px;
    color: #003366;
    padding: 15px 0;
    background-color: #e0e2e5;
    flex-shrink: 0;
    width: 100%;
}


/* ======================================= */
/* ESTILOS PARA EL LOGO Y EL TÍTULO INYECTADO (para vista previa en pantalla) */
/* ======================================= */

.print-logo-container {
    text-align: center;
    margin-bottom: 20px;
    padding-top: 10px;
    display: block;
}

.print-logo-img {
    width: 200px;
    height: auto;
}

.print-title {
    text-align: center;
    color: #003366;
    margin-top: 0;
    margin-bottom: 25px;
    font-size: 24px;
    display: block;
}

#previewActionButtons {
    display: none;
}
/* ======================================= */
/* Estilos para IMPRESIÓN */
/* ======================================= */
@media print {

    /* CLAVE: Asegura que el body sea un contenedor flex que empuja el footer */
    body {
        margin: 0 !important;
        padding: 0 !important;
        font-size: 14px !important;
        display: flex !important;
        flex-direction: column !important;
        min-height: 98vh !important; /* Asegura casi el 100% de la altura de la página */
        justify-content: flex-start !important; /* Alinea los ítems al inicio */
    }

    * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        box-sizing: border-box;
    }

    /* === REGLAS GENERALES DE IMPRESIÓN (PARA PÁGINAS CON PREVIEW COMO LICENCIA Y HORAS) === */
    /* Ocultar formulario, botones y H2 principal por defecto en impresión */
    /* Asegura que el contenedor principal .container crezca en estas páginas */
    body:not(.cambio-turno-page) > .container {
        flex-grow: 1 !important; /* CLAVE: Este contenedor principal debe crecer */
        display: flex !important; /* Lo convierte en un flex container */
        flex-direction: column !important; /* Apila su contenido verticalmente */
        max-width: none !important; /* Permite que el contenedor use todo el ancho */
        margin: 0 !important;
        padding: 0 !important;
    }

    body:not(.cambio-turno-page) form,
    body:not(.cambio-turno-page) .btn,
    body:not(.cambio-turno-page) .form-actions,
    body:not(.cambio-turno-page) h2#mainTitle { /* Specific ID for main title */
        display: none !important;
    }

    /* Mostrar la vista previa por defecto en impresión para páginas que la usan */
    body:not(.cambio-turno-page) .preview {
        display: block !important;
        flex-grow: 1 !important; /* CLAVE: Asegura que la vista previa crezca dentro del .container */
        display: flex !important; /* Lo convierte en flex container */
        flex-direction: column !important; /* Apila su contenido verticalmente */
        max-width: 900px !important; /* Mantén un ancho máximo razonable para el contenido interno */
        margin: 0 auto !important; /* Centra el contenido de la vista previa */
        padding: 10px !important;
        padding-top: 20px !important;
    }

    /* === FIN REGLAS GENERALES DE IMPRESIÓN === */


    /* === REGLAS ESPECÍFICAS PARA CAMBIO DE TURNO (cuando se quiere imprimir el formulario) === */
    body.cambio-turno-page form {
        display: block !important; /* Muestra el formulario para cambio_turno.html */
        flex-grow: 1 !important; /* Permite que el formulario crezca y empuje el footer */
        display: flex !important;
        flex-direction: column !important;
        max-width: none !important; /* Permite que el formulario use todo el ancho */
        margin: 0 auto !important; /* Centra el contenido */
        padding: 10px !important;
        padding-top: 20px !important;
    }

    body.cambio-turno-page .preview {
        display: none !important; /* Oculta la vista previa si el formulario se va a imprimir completo */
    }

    body.cambio-turno-page h2 {
        display: block !important; /* Muestra el H2 original para cambio_turno.html */
    }

    body.cambio-turno-page .btn,
    body.cambio-turno-page .form-actions {
        display: none !important; /* Oculta los botones y acciones del formulario en impresión */
    }
    /* === FIN REGLAS ESPECÍFICAS PARA CAMBIO DE TURNO === */


    /* === REGLAS CLAVE PARA EL PIE DE PÁGINA EN IMPRESIÓN === */

    /* El contenido real dentro de previewArea también puede necesitar crecer */
    #previewContent {
        flex-grow: 1 !important; /* Asegura que el contenido crezca dentro de #previewArea */
        text-align: left !important;
    }

    /* El pie de página debe "pegarse" al final */
    .footer {
        margin-top: auto !important; /* ¡CLAVE! Empuja el footer al final */
        flex-shrink: 0 !important; /* Evita que el footer se encoja */
        width: 100% !important; /* Asegura que ocupe todo el ancho */
        background-color: transparent !important;
        color: #000 !important;
        padding: 10px 0 !important;
    }

    /* === FIN DE REGLAS CLAVE PARA EL PIE DE PÁGINA === */

    .print-logo-container {
        display: block !important;
        text-align: center !important;
        margin-top: 0 !important;
        margin-bottom: 20px !important;
        padding-top: 0 !important;
        width: 100% !important;
    }

    .print-logo-img {
        display: inline-block !important;
        width: 450px !important;
        height: auto !important;
        max-width: 80% !important;
        max-height: none !important;
    }

    .print-title {
        display: block !important;
        margin-top: 0 !important;
        margin-bottom: 25px !important;
        width: 100% !important;
    }

    .signature-line {
        margin-bottom: 5px;
    }
.preview-signatures {
    margin-top: 35px; /* O el valor que prefieras */
	text-align: right;
}
    table {
        width: auto !important;
        border-collapse: collapse !important;
        table-layout: fixed !important;
        margin: 0 auto;
    }

    th,
    td {
        border: 1px solid #000 !important;
        padding: 4px 6px !important;
        font-size: 14px !important;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    /* Tamaños de columnas para impresión */
    th:nth-child(1),
    td:nth-child(1) {
        width: 40px !important;
    }

    th:nth-child(2),
    td:nth-child(2) {
        width: 220px !important;
    }

    th:nth-child(3),
    td:nth-child(3) {
        width: 40px !important;
    }

    th:nth-child(4),
    td:nth-child(4) {
        width: 90px !important;
    }

    th:nth-child(5),
    td:nth-child(5) {
        width: 55px !important;
    }

    th:nth-child(6),
    td:nth-child(6) {
        width: 55px !important;
    }

    th:nth-child(7),
    td:nth-child(7) {
        width: 70px !important;
    }

    .signature-line-wide {
        border-bottom: 1px solid black;
        margin-bottom: 5px;
    }

    .firma-texto-bottom {
        font-size: 0.9em;
        margin-top: 5px;
        display: block;
    }

    #previewContent .grupo-firma {
        display: flex;
        flex-direction: row;
        margin-bottom: 50px !important;
        align-items: baseline;
        justify-content: flex-start;
        margin: 0;
    }

    .firma-texto {
        min-width: 600px;
        text-align: right;
        margin-right: 15px;
        flex-shrink: 0;
    }

    #previewContent>div[style*="justify-content: space-between"] {
        display: flex;
        justify-content: space-between;
        width: 100%;
        margin-top: 50px;
    }

    #previewContent>div[style*="justify-content: space-between"]>div:nth-child(1) {
        text-align: left;
        align-items: flex-start;
    }

    #previewContent>div[style*="justify-content: space-between"]>div:nth-child(2) {
        text-align: center;
        align-items: center;
    }

    #previewContent>div[style*="justify-content: space-between"]>div:nth-child(3) {
        text-align: right;
        align-items: flex-end;
    }

    .signature-line-wide {
        width: 7cm !important;
    }

    #previewContent .grupo-firma {
        margin: 0 5mm;
    }
}