/* Estilos para la búsqueda junto a DataTables */
#searchContainer {
    display: inline-block;
    width: auto;
}

#searchContainer .input-group {
    width: auto;
    min-width: 250px;
    max-width: 300px;
}

#searchContainer .input-group-text {
    background-color: #f8f9fa;
    border-color: #dee2e6;
    border-right: 0;
    color: #6c757d;
}

#searchContainer .form-control {
    border-left: 0;
}

#searchContainer .form-control:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
    z-index: 0;
}

#searchContainer .form-control:focus + .input-group-text,
#searchContainer .form-control:focus ~ .input-group-text {
    border-color: #86b7fe;
}

/* Alineación de DataTables controls */
.dataTables_wrapper .row:first-child {
    margin-bottom: 15px;
    align-items: center;
}

.dataTables_wrapper .row:last-child {
    margin-top: 15px;
    align-items: center;
}

.dataTables_length {
    display: flex;
    align-items: center;
}

.dataTables_length label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
    margin-bottom: 0;
}

.dataTables_length select {
    width: auto;
    display: inline-block;
    margin: 0 5px;
}

/* Footer de DataTables */
.dataTables_info {
    padding-top: 8px;
}

.dataTables_paginate .pagination {
    margin-bottom: 0;
}

/* Responsive adjustments */
@media (max-width: 767px) {
    #searchContainer {
        display: block;
        margin-top: 10px;
    }

    #searchContainer .input-group {
        width: 100%;
        max-width: none;
    }

    .dataTables_info {
        text-align: center;
        margin-bottom: 10px;
    }

    .dataTables_wrapper .col-sm-12.d-flex {
        justify-content: center !important;
    }
}

/* Input personalizado con icono */
.input-group-custom {
    position: relative;
    margin-bottom: 0;
}

.input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    color: #6c757d;
    font-size: 14px;
    pointer-events: none;
    transition: color 0.3s ease;
}

.form-control-custom {
    width: 100%;
    height: 40px;
    padding: 8px 12px 8px 40px;
    border: 1px solid #ced4da;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
    color: #212529;
    background-color: #fff;
    background-clip: padding-box;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    appearance: none;
}

.form-control-custom:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
    outline: 0;
}

.form-control-custom:focus + .floating-label,
.form-control-custom:not(:placeholder-shown) + .floating-label,
.form-control-custom:valid + .floating-label,
.form-control-custom[value]:not([value=""]) + .floating-label {
    transform: translateY(-20px) scale(0.85);
    background: white;
    padding: 0 6px;
    color: #0d6efd;
    font-weight: 500;
}

.form-control-custom:focus ~ .input-icon {
    color: #0d6efd;
}

/* Select personalizado */
.form-control-custom:has-value + .floating-label,
select.form-control-custom:not([value=""]) + .floating-label,
select.form-control-custom option:checked + .floating-label {
    transform: translateY(-20px) scale(0.85);
    background: white;
    padding: 0 6px;
    color: #0d6efd;
    font-weight: 500;
}

/* Textarea personalizado */
.textarea-custom {
    height: 80px !important;
    resize: vertical;
    padding-top: 12px !important;
}

.textarea-custom + .floating-label {
    top: 12px;
}

.textarea-custom:focus + .floating-label,
.textarea-custom:not(:placeholder-shown) + .floating-label,
.textarea-custom:valid + .floating-label {
    transform: translateY(-20px) scale(0.85);
    background: white;
    padding: 0 6px;
    color: #0d6efd;
    font-weight: 500;
}

/* Floating label */
.floating-label {
    position: absolute;
    left: 40px;
    top: 11px;
    color: #6c757d;
    font-size: 14px;
    font-weight: 400;
    pointer-events: none;
    transform-origin: left top;
    transition: all 0.2s ease-in-out;
    z-index: 2;
    background: transparent;
}

.floating-label.active {
    transform: translateY(-24px) scale(0.85);
    background: white;
    padding: 0 6px;
    color: #0d6efd;
    font-weight: 500;
}

/* Estados de validación */
.form-control-custom.is-invalid {
    border-color: #dc3545;
}

.form-control-custom.is-invalid:focus {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.15);
}

.form-control-custom.is-invalid + .floating-label {
    color: #dc3545;
}

.form-control-custom.is-invalid ~ .input-icon {
    color: #dc3545;
}

/* Compatibilidad con form-floating existente para filtros */
.form-floating > label {
    padding-left: 1.5rem;
    transition: all 0.3s ease;
}

.form-floating > label i {
    transition: all 0.3s ease;
}

.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label,
.form-floating > .form-select ~ label {
    padding-left: 0.75rem;
    transform: scale(0.85) translateY(-0.5rem) translateX(0.15rem);
}

.form-floating > .form-control:focus ~ label i,
.form-floating > .form-control:not(:placeholder-shown) ~ label i,
.form-floating > .form-select ~ label i {
    display: none;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.table-responsive {
    position: relative;
    min-height: 300px;
}

#loadingTable {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 999;
}

.error-tooltip {
    position: absolute;
    background: #dc3545;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    margin-top: 5px;
    z-index: 1000;
    display: none;
    white-space: nowrap;
    max-width: auto !important;
    min-width: auto !important;
}

.error-tooltip .error-arrow {
    position: absolute;
    top: -5px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 5px solid #dc3545;
}

.error-tooltip .error-message {
    display: block;
}

.is-invalid {
    border-color: #dc3545 !important;
}

.is-invalid:focus {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25) !important;
}

@media (max-width: 768px) {
    .btn-group-sm .btn {
        padding: 0.25rem 0.4rem;
        font-size: 0.75rem;
    }

    .table-responsive {
        font-size: 0.875rem;
    }

    .form-floating > label {
        font-size: 0.875rem;
    }

    .card-header h4 {
        font-size: 1.1rem;
    }

    .col-auto .btn-sm {
        margin-bottom: 0.25rem;
    }
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 0.25rem 0.5rem;
}

.dataTables_wrapper .dataTables_info {
    padding-top: 0.5rem;
}

.badge {
    font-weight: 500;
    padding: 0.35em 0.65em;
}

.btn-group-sm > .btn {
    padding: 0.25rem 0.5rem;
}

.table > thead {
    background-color: #f8f9fa;
}

.table-hover tbody tr:hover {
    background-color: rgba(0, 123, 255, 0.05);
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "›";
    font-weight: bold;
    color: #6c757d;
}

.card-header {
    background-color: #fff;
    border-bottom: 2px solid #e9ecef;
}

.form-select:focus,
.form-control:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.15);
}

.btn-primary {
    background-color: #0d6efd;
    border-color: #0d6efd;
}

.btn-primary:hover {
    background-color: #0b5ed7;
    border-color: #0a58ca;
}

.spinner-border {
    width: 2rem;
    height: 2rem;
    border-width: 0.2em;
}

.dataTables_processing {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    margin-left: -50%;
    margin-top: -25px;
    z-index: 100;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
    --bs-table-accent-bg: rgba(0, 0, 0, 0.02);
}

.gap-2 {
    gap: 0.5rem;
}