/**
 * Estilos compartidos para formularios de Entidades (Gestores y Generadores)
 * Basado en el diseño del formulario de Register
 * CORNARE - Sistema de Gestión de Residuos
 */

/* ========================================
   ANIMACIONES
   ======================================== */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

/* ========================================
   CONTENEDOR PRINCIPAL
   ======================================== */
.form-entidades-container {
    animation: fadeIn 0.3s ease-out;
}

/* ========================================
   HEADER CON BRANDING
   ======================================== */
.form-entidades-header {
    border-radius: 0.5rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease;
}

.form-entidades-header:hover {
    transform: translateY(-2px);
}

.form-entidades-header .header-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.9;
}

.form-entidades-header h2 {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.form-entidades-header .lead {
    opacity: 0.9;
    font-size: 1.1rem;
}

/* Header Gestor (Verde) */
.form-entidades-header.header-gestor {
    background: #00833e !important;
    color: #ffffff;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Header Generador (Verde - Tono diferente) */
.form-entidades-header.header-generador {
    background: #00833e !important;
    color: #ffffff;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Header Genérico (Azul) */
.form-entidades-header.header-generico {
    background: #00833e !important;
    color: #ffffff;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Header Corrección de Cuenta (Naranja/Advertencia) */
.form-entidades-header.header-correccion {
    background: #00833e !important;
    color: #212529;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-entidades-header.header-correccion h2,
.form-entidades-header.header-correccion p {
    color: #212529;
}

.form-entidades-header.header-correccion .opacity-75 {
    opacity: 0.8 !important;
}

/* ========================================
   SECCIONES DEL FORMULARIO
   ======================================== */
.seccion-titulo {
    color: #198754;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 0.75rem;
    margin-bottom: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.seccion-titulo i {
    margin-right: 0.5rem;
    font-size: 1.1em;
    color: #198754;
}

.seccion-titulo.titulo-gestor {
    color: #198754;
    border-bottom-color: rgba(25, 135, 84, 0.3);
}

.seccion-titulo.titulo-generador {
    color: #198754;
    border-bottom-color: rgba(25, 135, 84, 0.3);
}

/* ========================================
   CARDS
   ======================================== */
.card-formulario {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    transition: box-shadow 0.2s ease;
    margin-bottom: 1.5rem;
    background-color: rgba(255, 255, 255, 0.80);
}

.card-formulario:hover {
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
}

.card-formulario .card-header {
    background-color: #198754;
    border-bottom: none;
    padding: 1rem 1.25rem;
}

.card-formulario .card-header h5 {
    margin-bottom: 0;
    color: #ffffff;
    font-weight: 600;
}

.card-formulario .card-header h5 i {
    color: #ffffff;
}

.card-formulario .card-body {
    padding: 1.25rem;
}

/* Card de información lateral */
.card-info-lateral {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    background-color: rgba(255, 255, 255, 0.80);
}

.card-info-lateral .card-header {
    background-color: #198754;
    border-bottom: none;
}

.card-info-lateral .card-header h6,
.card-info-lateral .card-header .card-title {
    color: #ffffff !important;
    font-weight: 600;
}

.card-info-lateral .card-header i {
    color: #ffffff !important;
}

.card-info-lateral .list-check li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #f1f1f1;
}

.card-info-lateral .list-check li:last-child {
    border-bottom: none;
}

/* Cards con fondo de color - asegurar texto blanco */
.card .card-header.bg-success,
.card .card-header.bg-primary,
.card .card-header.bg-info,
.card .card-header.bg-danger {
    color: #ffffff !important;
}

.card .card-header.bg-success h6,
.card .card-header.bg-primary h6,
.card .card-header.bg-info h6,
.card .card-header.bg-danger h6,
.card .card-header.bg-success .card-title,
.card .card-header.bg-primary .card-title,
.card .card-header.bg-info .card-title,
.card .card-header.bg-danger .card-title {
    color: #ffffff !important;
}

.card .card-header.bg-success i,
.card .card-header.bg-primary i,
.card .card-header.bg-info i,
.card .card-header.bg-danger i {
    color: #ffffff !important;
}

/* Card de warning con texto blanco */
.card .card-header.bg-warning {
    color: #ffffff !important;
}

.card .card-header.bg-warning h6,
.card .card-header.bg-warning .card-title,
.card .card-header.bg-warning i {
    color: #ffffff !important;
}

/* Card de acciones */
.card-acciones {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    background-color: rgba(255, 255, 255, 0.80);
}

.card-acciones .card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

/* ========================================
   CAMPOS DE FORMULARIO
   ======================================== */
.form-label {
    font-weight: 500;
    color: #495057;
    margin-bottom: 0.5rem;
}

.form-label i {
    color: #6c757d;
}

.form-label .required-field,
.form-label .text-danger {
    color: #dc3545;
    font-weight: bold;
}

.form-control,
.form-select {
    border: 1px solid #ced4da;
    padding: 0.5rem 0.75rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.15);
}

.form-control.is-valid,
.form-select.is-valid {
    border-color: #198754;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%23198754' d='M2.3 6.73.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");
    padding-right: calc(1.5em + 0.75rem);
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

/* ========================================
   VALIDACIONES
   ======================================== */
.is-invalid {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25) !important;
}

.invalid-feedback {
    display: block;
    color: #dc3545;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.valid-feedback {
    display: block;
    color: #198754;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Alerta de validación */
.alert-validation {
    position: sticky;
    top: 70px;
    z-index: 1000;
    animation: slideDown 0.3s ease-out;
    border-radius: 0.5rem;
}

.error-list {
    list-style: none;
    padding-left: 0;
    margin-bottom: 0;
}

.error-list li {
    padding: 8px 12px;
    margin-bottom: 6px;
    background-color: rgba(220, 53, 69, 0.1);
    border-left: 4px solid #dc3545;
    border-radius: 4px;
}

.error-list li strong {
    display: inline-block;
    min-width: 30px;
    color: #dc3545;
}

/* ========================================
   TIPO DE ENTIDAD SELECTOR
   ======================================== */
.tipo-entidad-selector {
    border: 2px solid #e9ecef;
    border-radius: 0.5rem;
    padding: 1.25rem;
    transition: all 0.2s ease;
    cursor: pointer;
    background-color: #fff;
}

.tipo-entidad-selector:hover {
    border-color: #00833e;
    background-color: #f8f9fa;
}

.tipo-entidad-selector.selected {
    border-color: #00833e;
    background-color: rgba(0, 144, 69, 0.05);
}

.tipo-entidad-selector.selected.gestor {
    border-color: #198754;
    background-color: rgba(25, 135, 84, 0.05);
}

.tipo-entidad-selector.selected.generador {
    border-color: #fd7e14;
    background-color: rgba(253, 126, 20, 0.05);
}

.tipo-entidad-selector .form-check-input {
    margin-top: 0.25rem;
}

.tipo-entidad-selector .form-check-label {
    cursor: pointer;
}

.tipo-entidad-selector .icon-tipo {
    font-size: 1.5rem;
    margin-right: 0.5rem;
}

.tipo-entidad-selector .descripcion-tipo {
    font-size: 0.875rem;
    color: #6c757d;
    margin-top: 0.25rem;
}

/* ========================================
   REPRESENTANTE LEGAL
   ======================================== */
.seccion-representante {
    background-color: #f8f9fa;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-top: 1rem;
    border: 1px dashed #dee2e6;
}

.seccion-representante.nuevo {
    background-color: rgba(0, 144, 69, 0.05);
    border-color: #00833e;
}

/* ========================================
   BOTONES
   ======================================== */
.btn-crear-entidad {
    padding: 0.75rem 2rem;
    font-weight: 500;
    font-size: 1.1rem;
    transition: all 0.2s ease;
}

.btn-crear-entidad:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-crear-entidad.btn-gestor {
    background: #198754;
    border-color: #157347;
}

.btn-crear-entidad.btn-gestor:hover {
    background: #198754;
}

.btn-crear-entidad.btn-generador {
    background: #fd7e14;
    border-color: #e66b00;
}

.btn-crear-entidad.btn-generador:hover {
    background: #e66b00;
}

/* Botón con loading */
.btn-loading {
    position: relative;
    pointer-events: none;
}

.btn-loading::after {
    content: "";
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1rem;
    height: 1rem;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: translateY(-50%) rotate(360deg);
    }
}

/* ========================================
   INFORMACIÓN DE AYUDA
   ======================================== */
.info-requisitos {
    padding: 0;
}

.info-requisitos li {
    padding: 0.5rem 0;
    display: flex;
    align-items: flex-start;
}

.info-requisitos li i {
    margin-right: 0.5rem;
    margin-top: 0.25rem;
}

.info-seguridad {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 0.5rem;
}

/* ========================================
   FORMULARIO INPUT GROUP
   ======================================== */
.input-group .btn-toggle-password {
    background-color: #fff;
    border-color: #ced4da;
    color: #6c757d;
}

.input-group .btn-toggle-password:hover {
    background-color: #f8f9fa;
    color: #495057;
}

.input-group .btn-toggle-password:focus {
    box-shadow: none;
    border-color: #86b7fe;
}

/* ========================================
   RADIO Y CHECKBOX
   ======================================== */
.form-check-entidad {
    padding: 1rem;
    border: 1px solid #e9ecef;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
}

.form-check-entidad:hover {
    background-color: #f8f9fa;
}

.form-check-entidad .form-check-input:checked ~ .form-check-label {
    font-weight: 500;
}

/* ========================================
   BADGE DE ESTADO
   ======================================== */
.badge-estado {
    font-size: 0.75rem;
    padding: 0.4em 0.8em;
    font-weight: 500;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 991.98px) {
    .card-info-lateral {
        position: relative;
        top: 0;
        margin-top: 1.5rem;
    }

    .form-entidades-header .header-icon {
        font-size: 2.5rem;
    }

    .btn-crear-entidad {
        width: 100%;
    }
}

@media (max-width: 767.98px) {
    .form-entidades-header {
        padding: 1.5rem !important;
    }

    .form-entidades-header h2 {
        font-size: 1.5rem;
    }

    .seccion-titulo {
        font-size: 1rem;
    }

    .tipo-entidad-selector {
        padding: 1rem;
    }
}

/* ========================================
   HEADERS CON FONDO OSCURO
   ======================================== */
/* Asegurar texto blanco en headers con fondo de color */
.form-entidades-header h2,
.form-entidades-header h3,
.form-entidades-header h4,
.form-entidades-header p,
.form-entidades-header span,
.form-entidades-header .lead {
    color: #ffffff !important;
}

.form-entidades-header.header-correccion h2,
.form-entidades-header.header-correccion p {
    color: #212529 !important;
}

/* ========================================
   SEDES ADICIONALES
   ======================================== */
.sede-adicional-card {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 1rem;
    margin-bottom: 1rem;
    background-color: #fafbfc;
    position: relative;
    animation: fadeIn 0.3s ease-out;
}

.sede-adicional-card .btn-eliminar-sede {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
}

.sede-adicional-card .sede-numero {
    font-weight: 600;
    color: #0d6efd;
    margin-bottom: 0.75rem;
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
    .card-acciones,
    .btn-crear-entidad,
    .btn-outline-secondary {
        display: none !important;
    }

    .card-formulario {
        box-shadow: none;
        border: 1px solid #dee2e6;
    }
}

/* ========================================
   FIX PARA DROPDOWNS (SELECTS)
   Asegurar visibilidad de opciones en todos los navegadores
   ======================================== */
.form-entidades-container select.form-select,
.form-entidades-container select.form-select option {
    background-color: #ffffff !important;
    color: #212529 !important;
}

.form-entidades-container select.form-select:focus {
    background-color: #ffffff !important;
    color: #212529 !important;
}

/* Opciones del select con estilos explícitos */
.form-entidades-container select option {
    background: #ffffff !important;
    color: #212529 !important;
    padding: 8px 12px;
}

.form-entidades-container select option:hover,
.form-entidades-container select option:focus,
.form-entidades-container select option:checked {
    background: #e9ecef !important;
    color: #212529 !important;
}
