/* =====================================================================
   FORMULARIOS MODERNOS Y RESPONSIVE
   ---------------------------------------------------------------------
   Unifica los tres estilos que habia mezclados en la aplicacion:
     1) Campo con raya abajo y la etiqueta DEBAJO (<small class="mx-2">)
        -> empleados, clientes...
     2) Etiqueta encima con .form-control de AdminLTE
        -> gastos, tipos de trabajo, usuarios...
     3) Campos sin ninguna clase (desplegables grises del navegador)
        -> periodos de cliente, partes, gastos...

   Se aplica solo a los formularios de las ventanas emergentes (#uni_modal)
   y a los de dentro de las paginas. No toca el login.

   PARA DESHACERLO: quitar la linea que carga este fichero en
   admin/inc/header.php (y en inc/header.php). No hace falta nada mas.
   ===================================================================== */

:root {
    --f-azul: #007bff;
    --f-borde: #ced4da;
    --f-borde-suave: #e9ecef;
    --f-texto: #212529;
    --f-etiqueta: #495057;
    --f-ayuda: #6c757d;
    --f-fondo: #f8f9fa;
}

/* ---------------------------------------------------------------------
   VENTANA EMERGENTE
   --------------------------------------------------------------------- */
#uni_modal .modal-content {
    border: none;
    border-radius: 12px !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}
#uni_modal .modal-header {
    background: var(--f-azul);
    color: #fff;
    border-bottom: none;
    border-radius: 0 !important;
    padding: 15px 22px;
}
#uni_modal .modal-header .modal-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
}
#uni_modal .modal-header .close,
#uni_modal .modal-header .btn-close {
    color: #fff;
    opacity: 0.85;
    text-shadow: none;
}
#uni_modal .modal-body {
    padding: 22px;
}
#uni_modal .modal-footer {
    background: var(--f-fondo);
    border-top: 1px solid var(--f-borde-suave);
    padding: 12px 22px;
    border-radius: 0 !important;
}
#uni_modal .modal-footer .btn {
    border-radius: 6px !important;
    padding: 7px 20px;
    font-weight: 500;
}

/* ---------------------------------------------------------------------
   ESPACIADO DE LOS GRUPOS
   --------------------------------------------------------------------- */
#uni_modal form .form-group,
.content-wrapper .card-body form .form-group {
    margin-bottom: 16px;
}

/* ---------------------------------------------------------------------
   ETIQUETAS: siempre ENCIMA del campo, mismo aspecto
   --------------------------------------------------------------------- */
#uni_modal form label:not(.custom-file-label):not(.label-check):not(.form-check-label),
#uni_modal form .control-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--f-etiqueta);
    margin-bottom: 6px;
}

/* Estilo 1: la etiqueta era un <small class="mx-2"> DESPUES del campo.
   Se reordena con flex para que aparezca encima, sin tocar el HTML. */
#uni_modal form .form-group:has(> small.mx-2),
.content-wrapper .card-body form .form-group:has(> small.mx-2) {
    display: flex;
    flex-direction: column;
}
#uni_modal form .form-group > small.mx-2,
.content-wrapper .card-body form .form-group > small.mx-2 {
    order: -1;
    margin: 0 0 6px !important;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--f-etiqueta);
}
/* Etiquetas y campos ya van en bloque: los <br> sueltos dentro de un grupo
   solo dejaban huecos en blanco. */
#uni_modal form .form-group > br,
.content-wrapper .card-body form .form-group:has(> small.mx-2) > br {
    display: none;
}

/* Textos de ayuda (p. ej. "Deje esto en blanco si...") */
#uni_modal form small.text-info,
#uni_modal form small.text-muted {
    display: block;
    margin-top: 5px;
    color: var(--f-ayuda) !important;
    font-size: 0.78rem;
}

/* ---------------------------------------------------------------------
   CAMPOS: mismo alto, borde completo y esquinas redondeadas
   Incluye los que no tenian ninguna clase (desplegables del navegador).
   Se excluyen casillas, ficheros, ocultos y los que gestionan select2/summernote.
   --------------------------------------------------------------------- */
#uni_modal form input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]):not([type="submit"]):not([type="button"]):not(.custom-file-input):not(.note-input),
#uni_modal form select:not(.select2-hidden-accessible),
#uni_modal form textarea:not(.note-codable) {
    display: block;
    width: 100%;
    min-height: 38px;
    padding: 7px 12px;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--f-texto);
    background-color: #fff;
    border: 1px solid var(--f-borde) !important;
    border-radius: 6px !important;
    box-shadow: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#uni_modal form textarea:not(.note-codable) {
    min-height: 80px;
    resize: vertical;
}
#uni_modal form select:not(.select2-hidden-accessible) {
    height: 38px;
    padding-right: 32px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23495057' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px 12px;
    cursor: pointer;
}

/* Al escribir: borde azul y halo suave */
#uni_modal form input:focus,
#uni_modal form select:focus,
#uni_modal form textarea:focus {
    border-color: var(--f-azul) !important;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15) !important;
    outline: none;
}

/* Desactivados (p. ej. "Periodo Jardín" sin cuota): que se note */
#uni_modal form input:disabled,
#uni_modal form select:disabled,
#uni_modal form textarea:disabled,
#uni_modal form input[readonly] {
    background-color: #f1f3f5 !important;
    color: #868e96;
    cursor: not-allowed;
}

#uni_modal form ::placeholder {
    color: #adb5bd;
    opacity: 1;
}

/* Campo con boton pegado (contraseña con el ojo): el grupo lleva el borde */
#uni_modal form .input-group {
    flex-wrap: nowrap;
}
#uni_modal form .input-group > input {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}
#uni_modal form .input-group-append .input-group-text {
    background: #fff !important;
    border: 1px solid var(--f-borde) !important;
    border-left: none !important;
    border-radius: 0 6px 6px 0 !important;
    min-height: 38px;
}

/* Botones dentro del formulario (Generar, Plantilla...) */
#uni_modal form .btn {
    border-radius: 6px !important;
    min-height: 38px;
}

/* select2 con el mismo aspecto que el resto de campos */
#uni_modal .select2-container--default .select2-selection--single,
#uni_modal .select2-container--default .select2-selection--multiple,
#uni_modal .select2-container--bootstrap4 .select2-selection {
    min-height: 38px;
    border: 1px solid var(--f-borde) !important;
    border-radius: 6px !important;
}
#uni_modal .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 36px;
    padding-left: 12px;
}
#uni_modal .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 36px;
}

/* summernote (editor de descripcion) */
#uni_modal .note-editor.note-frame {
    border: 1px solid var(--f-borde) !important;
    border-radius: 6px !important;
    overflow: hidden;
}

/* Casillas y listas de empleados */
#uni_modal form input[type="checkbox"],
#uni_modal form input[type="radio"] {
    width: 16px;
    height: 16px;
    margin-right: 6px;
    vertical-align: middle;
    accent-color: var(--f-azul);
}

/* Filas de dos o tres campos alineadas por arriba */
#uni_modal form .row {
    align-items: flex-start;
}

/* ---------------------------------------------------------------------
   RESPONSIVE
   --------------------------------------------------------------------- */

/* Tablet: las columnas de 3 pasan a 2 */
@media (max-width: 991.98px) {
    #uni_modal .modal-dialog.mid-large,
    #uni_modal .modal-dialog.modal-lg,
    #uni_modal .modal-dialog.large {
        max-width: 95%;
    }
    #uni_modal form .row > .col-md-4 {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* Movil: todo en una sola columna y ventana a pantalla casi completa */
@media (max-width: 767.98px) {
    /* custom.css fuerza "width:100% !important" en .mid-large/.large sin margen,
       y la ventana se salia de la pantalla. Ancho automatico con 8px a cada lado. */
    #uni_modal .modal-dialog,
    #uni_modal .modal-dialog.mid-large,
    #uni_modal .modal-dialog.large,
    #uni_modal .modal-dialog.modal-lg {
        width: auto !important;
        max-width: none !important;
        margin: 8px !important;
    }
    #uni_modal .modal-body {
        padding: 16px;
    }
    #uni_modal form .row > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }
    /* 16px evita que el iPhone haga zoom al tocar un campo */
    #uni_modal form input:not([type="checkbox"]):not([type="radio"]),
    #uni_modal form select,
    #uni_modal form textarea,
    #uni_modal form button.dropdown-toggle {
        font-size: 16px !important;
    }
    #uni_modal .modal-footer {
        padding: 10px 16px;
    }
    #uni_modal .modal-footer .btn {
        flex: 1 1 auto;
    }
}

/* ---------------------------------------------------------------------
   AJUSTES PUNTUALES
   --------------------------------------------------------------------- */

/* Dos campos seguidos dentro del mismo grupo (p. ej. "desde" y "Hasta" en partes):
   la segunda etiqueta iba pegada al campo de arriba */
#uni_modal form input:not([type="checkbox"]):not([type="radio"]):not(.custom-file-input) ~ label:not(.label-check):not(.custom-file-label):not(.form-check-label),
#uni_modal form select ~ label:not(.label-check),
#uni_modal form textarea ~ label:not(.label-check) {
    margin-top: 12px;
}

/* Botones desplegables sin clase .btn (p. ej. "Empleados" en partes):
   mismo aspecto que un desplegable normal */
#uni_modal form .dropdown > br { display: none; }
#uni_modal form button.dropdown-toggle:not(.btn) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 38px;
    padding: 7px 12px;
    font-size: 0.95rem;
    color: #212529;
    text-align: left;
    background: #fff;
    border: 1px solid var(--f-borde);
    border-radius: 6px;
    cursor: pointer;
}
#uni_modal form button.dropdown-toggle:not(.btn):focus {
    border-color: var(--f-azul);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
    outline: none;
}
#uni_modal form .dropdown .dropdown-menu {
    width: 100%;
    max-height: 280px;
    overflow-y: auto;
    border-radius: 6px;
    border-color: var(--f-borde-suave);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

/* Boton "Generar" junto a la contraseña: alineado con el campo, no con la etiqueta */
#uni_modal form .row:has(#generate-btn) {
    align-items: flex-end;
}
#uni_modal form .row:has(#generate-btn) > div:has(#generate-btn) {
    margin-bottom: 16px;
}
#uni_modal form #generate-btn {
    width: 100%;
}

/* Bloque "Mantenimiento / Departamento" del parte (.separado):
   salian dos desplegables pequeños y centrados. Ahora dos columnas a lo ancho. */
#uni_modal form .separado {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    align-items: start;
}
#uni_modal form .separado > .form-group {
    width: 100%;
    min-width: 0;
    margin-bottom: 16px;
}

/* Pie de la ventana: botones siempre visibles y del mismo tamaño en movil */
@media (max-width: 767.98px) {
    #uni_modal .modal-footer {
        display: flex !important;
        flex-wrap: nowrap;
        gap: 8px;
    }
    #uni_modal .modal-footer > * { margin: 0 !important; }
}

/* =====================================================================
   FORMULARIOS DENTRO DE LA PAGINA (no en ventana)
   ---------------------------------------------------------------------
   Mismo aspecto que los de las ventanas. Afecta sobre todo a la zona de
   los trabajadores: filtro de su lista de tareas y pantalla de perfil.
   ===================================================================== */
.content-wrapper .card-body form label:not(.custom-file-label):not(.label-check):not(.form-check-label):not(.mb-0),
.content-wrapper .card-body form .control-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--f-etiqueta);
    margin-bottom: 6px;
}

.content-wrapper .card-body form input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]):not([type="submit"]):not([type="button"]):not(.custom-file-input):not(.note-input),
.content-wrapper .card-body form select:not(.select2-hidden-accessible),
.content-wrapper .card-body form textarea:not(.note-codable) {
    display: block;
    width: 100%;
    min-height: 38px;
    padding: 7px 12px;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--f-texto);
    background-color: #fff;
    border: 1px solid var(--f-borde) !important;
    border-radius: 6px !important;
    box-shadow: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.content-wrapper .card-body form select:not(.select2-hidden-accessible) {
    height: 38px;
    padding-right: 32px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23495057' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px 12px;
}
.content-wrapper .card-body form input:focus,
.content-wrapper .card-body form select:focus,
.content-wrapper .card-body form textarea:focus {
    border-color: var(--f-azul) !important;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15) !important;
    outline: none;
}
.content-wrapper .card-body form input:disabled,
.content-wrapper .card-body form select:disabled,
.content-wrapper .card-body form input[readonly] {
    background-color: #f1f3f5 !important;
    color: #868e96;
}

/* Campo con el ojo de ver contraseña (perfil del trabajador) */
.content-wrapper .card-body form .input-group { flex-wrap: nowrap; }
.content-wrapper .card-body form .input-group > input {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}
.content-wrapper .card-body form .input-group-append .input-group-text {
    background: #fff !important;
    border: 1px solid var(--f-borde) !important;
    border-left: none !important;
    border-radius: 0 6px 6px 0 !important;
    min-height: 38px;
}

.content-wrapper .card-body form small.text-muted,
.content-wrapper .card-body form small.text-info {
    display: block;
    margin-top: 4px;
    color: var(--f-ayuda) !important;
    font-size: 0.78rem;
}

.content-wrapper .card-body form .btn {
    border-radius: 6px !important;
}

/* Filtro de fechas de la lista de tareas del TRABAJADOR: mismo bloque gris que
   el del admin (el admin ya lleva .filter-bg y no se toca) */
.content-wrapper .card-body form#employeeFilterForm > .row:not(.filter-bg) {
    background: var(--f-fondo);
    border: 1px solid var(--f-borde-suave);
    border-radius: 8px;
    padding: 15px 8px 0;
    margin: 10px 0 20px;
}
.content-wrapper .card-body form#employeeFilterForm > .row:not(.filter-bg) .btn {
    width: 100%;
    min-height: 38px;
    font-size: 0.95rem;
    font-weight: 500;
}

/* Pie de la tarjeta del perfil: boton con el mismo aspecto */
.content-wrapper .card-footer .btn {
    border-radius: 6px !important;
    padding: 7px 20px;
    font-weight: 500;
}

@media (max-width: 767.98px) {
    .content-wrapper .card-body form input:not([type="checkbox"]):not([type="radio"]),
    .content-wrapper .card-body form select,
    .content-wrapper .card-body form textarea {
        font-size: 16px !important;
    }
    .content-wrapper .card-body form .row > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }
}
