/* =========================================
   FORMULARIO DE JUSTIFICACIONES
   ========================================= */

/* Fila de pestañas: franja gris a todo el ancho (BS5 deja card-header casi blanco). */
.justification-panel.card > .justification-tab-header {
    background-color: transparent !important;
    --bs-card-cap-bg: transparent;
    padding: 0 !important;
}

.justification-tab-header__row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    width: 100%;
    min-height: 2.75rem;
    background-color: #720034 !important;
    border-bottom: 1px solid #5b0029;
    box-sizing: border-box;
}

/* Relleno vinotinto a la derecha de las pestañas (y refuerza la franja si el ul no ocupa el 100%). */
.justification-tab-header__spacer {
    flex: 1 1 auto;
    min-width: 1rem;
    min-height: 2.75rem;
    background-color: #720034 !important;
}

.justification-inner-nav {
    --bs-nav-tabs-border-width: 0;
    border-bottom: none !important;
    gap: 0.5rem;
}

.justification-inner-nav .nav-item {
    margin-bottom: 0;
}

/* Base común pestañas CREAR / VER */
.justification-inner-nav .nav-link {
    margin-bottom: -1px;
    border-radius: 6px 6px 0 0 !important;
    padding: 0.5rem 0.95rem;
}

/* Inactiva: mismo vinotinto que la franja + texto blanco (estilo encabezado modal). */
.justification-inner-nav .nav-link:not(.active) {
    border: 1px solid transparent !important;
    color: #ffffff !important;
    background-color: #720034 !important;
}

.justification-inner-nav .nav-link:hover:not(.active),
.justification-inner-nav .nav-link:focus-visible:not(.active) {
    color: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.35) !important;
    background-color: #8a0140 !important;
}

/* Activa: blanca y “pega” visualmente con el cuerpo del formulario. */
.justification-inner-nav .nav-link.active,
.justification-inner-nav .nav-link.active:hover,
.justification-inner-nav .nav-link.active:focus {
    color: #212529 !important;
    background-color: #ffffff !important;
    border: 1px solid #d6d6d6 !important;
    border-bottom-color: #ffffff !important;
    position: relative;
    z-index: 2;
}

.justification-inner-nav .nav-link .fa {
    margin-right: 0.35rem;
}

/* Encabezado "Justificaciones Creadas": mismo vinotinto que las pestañas.
   :not(.justification-tab-header) para no tocar la franja de pestañas. */
.justification-page .justification-panel > .card-header:not(.justification-tab-header) {
    background-color: #720034 !important;
    --bs-card-cap-bg: #720034;
    border-bottom: 1px solid #5b0029 !important;
    color: #ffffff !important;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.justification-page .justification-panel > .card-header:not(.justification-tab-header) .text-center {
    color: #ffffff !important;
}

#frmJustification .form-control,
#editJustification .form-control {
    border-radius: 20px !important;
    border-color: #D6D6D6;
    min-width: 0;
}

/* Select BS5 dentro del mismo formulario */
#frmJustification .form-select,
#editJustification .form-select {
    border-radius: 20px !important;
    border-color: #D6D6D6;
    width: 100%;
}

#frmJustification .input-group,
#editJustification .input-group,
#frmJustificationEdit .input-group {
    width: 100%;
    min-width: 0;
    flex-wrap: nowrap;
}

/* Inputs de fecha: addon a la derecha */
#frmJustification #start_date_justification,
#frmJustification #end_date_justification {
    border-radius: 20px 0 0 20px !important;
}

/* Input de búsqueda: addon a la derecha */
#editJustification #searchJustification {
    border-radius: 20px 0 0 20px !important;
}

#frmJustification .input-group-addon,
#frmJustification .input-group-text,
#frmJustificationEdit .input-group-text,
#editJustification .input-group-text,
#editJustification .input-group-addon {
    border-radius: 0 20px 20px 0 !important;
    border-color: #D6D6D6;
    background-color: #fff;
    flex: 0 0 48px;
    justify-content: center;
    cursor: pointer;
}

#frmJustification .input-group > .form-control,
#frmJustificationEdit .input-group > .form-control,
#editJustification .input-group > .form-control {
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
}

#frmJustification input[type="file"].form-control {
    width: 100%;
}

@media (max-width: 575.98px) {
    .justification-page {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }

    .justification-page .card-body,
    .justification-card-body {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    .justification-form {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    #frmJustification .row.mb-3.align-items-center > [class*="col-"] {
        width: 100%;
        max-width: 100%;
        flex: 0 0 100%;
    }

    #frmJustification .col-form-label {
        padding-bottom: 0.35rem;
    }

    .justification-inner-nav {
        width: 100%;
        flex-wrap: nowrap;
        gap: 0.25rem;
    }

    .justification-inner-nav .nav-item {
        flex: 1 1 50%;
        min-width: 0;
    }

    .justification-inner-nav .nav-link {
        width: 100%;
        white-space: normal;
        text-align: center;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
        font-size: 0.85rem;
    }

    .justification-tab-header__spacer {
        display: none;
    }
}

/* =========================================================
   PANTALLAS PEQUEÑAS: lista "Ver justificaciones" como tarjetas
   La tabla de 7 columnas no cabe en móvil; la convertimos en
   tarjetas apiladas usando data-label en cada celda.
   ========================================================= */
.justification-search {
    width: 100%;
}

/* Fila/tarjeta oculta por el buscador. Selector muy específico para ganarle
   a "table.justification-table.fcaq-table tbody tr { display:block !important }". */
.justification-table tr.justification-row-hidden,
table.justification-table.fcaq-table tbody tr.justification-row-hidden,
table.justification-table.fcaq-table tbody tr.justification-row-hidden td {
    display: none !important;
}

@media (max-width: 767.98px) { 
    /* Lista "Ver justificaciones": anula .fcaq-table (cada celda gris suelta)
       y muestra tarjetas apiladas con data-label en cada fila. */
    .justification-page .table-responsive {
        overflow-x: visible !important;
    }

    .justification-page .justification-panel .card-body {
        padding-left: 0.65rem !important;
        padding-right: 0.65rem !important;
    }

    .justification-search .form-control {
        border: 1px solid #d6d6d6;
        border-right: 0;
        border-radius: 20px 0 0 20px !important;
        min-height: 42px;
    }

    .justification-search .input-group-text {
        border: 1px solid #d6d6d6;
        border-left: 0;
        border-radius: 0 20px 20px 0 !important;
        background: #fff;
        min-width: 44px;
        justify-content: center;
    }

    table.justification-table.fcaq-table {
        display: block !important;
        width: 100% !important;
        border-collapse: collapse !important;
        border-spacing: 0 !important;
        margin-bottom: 0;
    }

    table.justification-table.fcaq-table thead,
    table.justification-table.fcaq-table thead tr,
    table.justification-table.fcaq-table thead td {
        display: none !important;
    }

    table.justification-table.fcaq-table tbody {
        display: block !important;
        width: 100% !important;
    }

    table.justification-table.fcaq-table tbody tr {
        display: block !important;
        width: 100% !important;
        box-sizing: border-box;
        border: 1px solid #e7d4de;
        border-radius: 12px;
        background: #ffffff !important;
        box-shadow: 0 2px 8px rgba(114, 0, 52, 0.08);
        margin-bottom: 0.85rem;
        padding: 0.35rem 0.85rem 0.15rem;
    }

    table.justification-table.fcaq-table tbody td {
        display: flex !important;
        align-items: flex-start;
        justify-content: space-between;
        gap: 0.75rem;
        width: 100% !important;
        max-width: 100% !important;
        text-align: right !important;
        border: 0 !important;
        border-radius: 0 !important;
        background: transparent !important;
        background-color: transparent !important;
        border-bottom: 1px solid #f1e7ed !important;
        padding: 0.55rem 0.15rem !important;
        white-space: normal !important;
        vertical-align: top !important;
    }

    table.justification-table.fcaq-table tbody tr td:last-child {
        border-bottom: 0 !important;
    }

    table.justification-table.fcaq-table tbody td::before {
        content: attr(data-label);
        flex: 0 0 38%;
        max-width: 38%;
        color: #720034;
        font-weight: 700;
        font-size: 0.72rem;
        letter-spacing: 0.03em;
        text-transform: uppercase;
        text-align: left;
        line-height: 1.35;
        padding-top: 0.1rem;
    }

    table.justification-table.fcaq-table tbody td > span {
        flex: 1 1 62%;
        text-align: right;
        white-space: normal !important;
        word-break: break-word;
        overflow-wrap: anywhere;
        line-height: 1.35;
    }

    /* Celda de acción: botón "Editar" centrado, sin etiqueta. */
    table.justification-table.fcaq-table tbody td.justification-action-cell {
        justify-content: center;
        padding-top: 0.7rem !important;
        padding-bottom: 0.55rem !important;
    }

    table.justification-table.fcaq-table tbody td.justification-action-cell::before {
        display: none !important;
        content: none !important;
    }

    .justification-action-cell .justification-action-label {
        display: inline !important;
    }

    .justification-action-cell .edit_justification {
        display: inline-flex;
        align-items: center;
        gap: 0.45rem;
        border: 1px solid #1f8a4c;
        border-radius: 18px;
        padding: 0.32rem 1rem;
        color: #1f8a4c;
        font-weight: 600;
        font-size: 0.85rem;
        text-transform: uppercase;
        letter-spacing: 0.02em;
        text-decoration: none;
    }

    .justification-action-cell .edit_justification:active {
        background: #eef7f1;
    }
}

/* Checkbox del compromiso: visible con borde vinotinto y check al marcar. */
#frmJustification #terms_justification.form-check-input,
#editJustification #terms_justification.form-check-input {
    width: 1.15rem;
    height: 1.15rem;
    border: 2px solid #720034 !important;
    border-radius: 4px !important;
    background-color: #fff;
    cursor: pointer;
    flex-shrink: 0;
}
#frmJustification #terms_justification.form-check-input:checked,
#editJustification #terms_justification.form-check-input:checked {
    background-color: #720034 !important;
    border-color: #720034 !important;
}
#frmJustification #terms_justification.form-check-input:focus,
#editJustification #terms_justification.form-check-input:focus {
    box-shadow: 0 0 0 0.2rem rgba(114, 0, 52, 0.25);
}

/* Mensaje de validación: rojo, encima del checkbox de compromiso. */
#frmJustification .justification-error-slot {
    width: 100%;
    text-align: center;
    margin-bottom: 0.5rem;
}
#frmJustification label.error.justification-error-msg,
#frmJustification .justification-error-slot label.error,
#frmJustificationEdit label.error.justification-error-msg {
    display: block;
    width: 100%;
    color: #dc3545 !important;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1.3;
    margin: 0.35rem 0 0;
    padding: 0;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: transparent !important;
}

/* Highlight rojo del checkbox cuando hay error. */
#frmJustification #terms_justification.form-check-input.error {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 0.18rem rgba(220, 53, 69, 0.25);
}

/* Inputs en estado de error (file, text, select, datepicker) */
#frmJustification .form-control.error,
#frmJustification .form-select.error,
#frmJustificationEdit .form-control.error,
#frmJustificationEdit .form-select.error {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 0.18rem rgba(220, 53, 69, 0.15) !important;
}

/* Cuando el input está dentro de un input-group (calendarios), aplica al addon también */
#frmJustification .input-group:has(.form-control.error) .input-group-text,
#frmJustificationEdit .input-group:has(.form-control.error) .input-group-text {
    border-color: #dc3545 !important;
}

/* Modal de feedback (error/exito) para justificaciones. */
.bootstrap-dialog.justification-feedback-dialog .modal-content {
    border-radius: 14px;
    border: 1px solid #ead7df;
    overflow: hidden;
}

.bootstrap-dialog.justification-feedback-dialog .modal-header,
.bootstrap-dialog.justification-feedback-dialog.type-success .modal-header,
.bootstrap-dialog.justification-feedback-dialog.type-danger .modal-header,
.bootstrap-dialog.justification-feedback-dialog.type-warning .modal-header,
.bootstrap-dialog.justification-feedback-dialog.type-info .modal-header,
.bootstrap-dialog.justification-feedback-dialog.type-primary .modal-header,
.bootstrap-dialog.justification-feedback-dialog.type-default .modal-header {
    background: #720034 !important;
    background-color: #720034 !important;
    border-bottom: 1px solid #5b0029 !important;
    color: #ffffff !important;
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.1rem;
}

.bootstrap-dialog.justification-feedback-dialog .bootstrap-dialog-title,
.bootstrap-dialog.justification-feedback-dialog.type-success .bootstrap-dialog-title,
.bootstrap-dialog.justification-feedback-dialog.type-danger .bootstrap-dialog-title {
    color: #ffffff !important;
    font-weight: 700;
    letter-spacing: 0.01em;
    order: 1;
    margin-right: auto;
}

.bootstrap-dialog.justification-feedback-dialog .bootstrap-dialog-close-button,
.bootstrap-dialog.justification-feedback-dialog .close,
.bootstrap-dialog.justification-feedback-dialog .bootstrap-dialog-close-button .glyphicon,
.bootstrap-dialog.justification-feedback-dialog .bootstrap-dialog-close-button a {
    color: #ffffff !important;
    opacity: 0.95;
    order: 2;
    margin-left: auto;
    float: none !important;
    font-size: 1.25rem;
    text-shadow: none;
}

.bootstrap-dialog.justification-feedback-dialog .bootstrap-dialog-close-button:hover,
.bootstrap-dialog.justification-feedback-dialog .close:hover {
    color: #ffffff !important;
    opacity: 1;
}

.bootstrap-dialog.justification-feedback-dialog .modal-body {
    color: #2f2f2f;
    font-size: 1rem;
    line-height: 1.4;
}

.bootstrap-dialog.justification-feedback-dialog .modal-footer {
    border-top: 0;
    padding-top: 0.25rem;
}

.bootstrap-dialog.justification-feedback-dialog .modal-footer .btn,
.bootstrap-dialog.justification-feedback-dialog .btn-danger,
.bootstrap-dialog.justification-feedback-dialog .btn-success,
.bootstrap-dialog.justification-feedback-dialog .btn-primary,
.bootstrap-dialog.justification-feedback-dialog .btn-warning,
.bootstrap-dialog.justification-feedback-dialog .btn-info,
.bootstrap-dialog.justification-feedback-dialog .btn-default {
    background-color: #720034 !important;
    border-color: #720034 !important;
    color: #ffffff !important;
    border-radius: 12px !important;
    min-width: 6.5rem;
    font-weight: 600;
}

.bootstrap-dialog.justification-feedback-dialog .modal-footer .btn:hover,
.bootstrap-dialog.justification-feedback-dialog .btn-danger:hover,
.bootstrap-dialog.justification-feedback-dialog .btn-success:hover {
    background-color: #5b0029 !important;
    border-color: #5b0029 !important;
}

/* Modal Editar Justificación */
.bootstrap-dialog.justification-edit-dialog .modal-dialog {
    max-width: 720px;
}

.bootstrap-dialog.justification-edit-dialog .modal-content {
    border-radius: 14px;
    border: 1px solid #ead7df;
    overflow: hidden;
}

.bootstrap-dialog.justification-edit-dialog .modal-header,
.bootstrap-dialog.justification-edit-dialog.type-success .modal-header,
.bootstrap-dialog.justification-edit-dialog.type-primary .modal-header,
.bootstrap-dialog.justification-edit-dialog.type-danger .modal-header {
    background: #720034 !important;
    background-color: #720034 !important;
    border-bottom: 1px solid #5b0029 !important;
    color: #ffffff !important;
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.1rem;
}

.bootstrap-dialog.justification-edit-dialog .bootstrap-dialog-title {
    color: #ffffff !important;
    font-weight: 700;
    order: 1;
    margin-right: auto;
}

.bootstrap-dialog.justification-edit-dialog .bootstrap-dialog-close-button,
.bootstrap-dialog.justification-edit-dialog .close {
    color: #ffffff !important;
    opacity: 0.95;
    order: 2;
    margin-left: auto;
    float: none !important;
    font-size: 1.25rem;
    text-shadow: none;
}

.bootstrap-dialog.justification-edit-dialog .bootstrap-dialog-close-button:hover,
.bootstrap-dialog.justification-edit-dialog .close:hover {
    color: #ffffff !important;
    opacity: 1;
}

.bootstrap-dialog.justification-edit-dialog .modal-body {
    padding: 1rem 1.25rem 0.5rem;
}

.bootstrap-dialog.justification-edit-dialog .modal-footer {
    border-top: 1px solid #ead7df;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem 1rem;
}

.bootstrap-dialog.justification-edit-dialog .justification-edit-btn-cancel {
    background: #ffffff !important;
    border: 1px solid #720034 !important;
    color: #720034 !important;
    border-radius: 12px !important;
    min-width: 7rem;
    font-weight: 600;
}

.bootstrap-dialog.justification-edit-dialog .justification-edit-btn-cancel:hover {
    background: #f8f1f4 !important;
    color: #720034 !important;
}

.bootstrap-dialog.justification-edit-dialog .justification-edit-btn-accept {
    min-width: 7rem;
}

.justification-edit-form .form-control,
.justification-edit-form .form-select {
    border-radius: 20px !important;
    border-color: #D6D6D6;
}

.justification-edit-form #start_date_justification_edit,
.justification-edit-form #end_date_justification_edit {
    border-radius: 20px 0 0 20px !important;
}

.justification-edit-form .input-group-text {
    border-radius: 0 20px 20px 0 !important;
    border-color: #D6D6D6;
    background-color: #fff;
}

.justification-edit-form .justification-edit-file-row .justification-edit-file-input {
    flex: 1 1 12rem;
    min-width: 0;
}

.justification-edit-form .btn-americano.btn-sm {
    padding: 0.35rem 0.9rem;
    font-size: 0.78rem;
    border-radius: 18px;
}
