/* ============================================
   MODAL - Componente compartido
   Usado por: dashboard, mapa-ofertas, mis-aplicaciones,
   mis-aplicaciones-trabajador, perfil-trabajador,
   notificaciones, historial-ofertas
   ============================================ */

/* ============================================
   ANIMACIONES
   ============================================ */

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   OVERLAY
   ============================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal-overlay);
    padding: var(--padding-md);
    padding-top: calc(env(safe-area-inset-top, 20px) + 3rem);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + var(--padding-md));
    animation: modalFadeIn var(--transition-fast);
}

.modal-overlay.active {
    display: flex;
}

/* ============================================
   CONTENEDOR
   ============================================ */

.modal-content {
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-modal);
    max-width: 600px;
    width: 100%;
    max-height: calc(100vh - env(safe-area-inset-top, 20px) - env(safe-area-inset-bottom, 0px) - 5rem);
    overflow-y: auto;
    position: relative;
    animation: modalSlideUp var(--transition-base);
}

/* Variantes de tamaño */
.modal-content--sm {
    max-width: 400px;
}

.modal-content--md {
    max-width: 500px;
}

/* ============================================
   BOTON CERRAR
   ============================================ */

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    min-width: 44px;
    min-height: 44px;
    border: none;
    background: var(--gray-200);
    border-radius: var(--radius-full);
    font-size: var(--text-xl);
    color: var(--dark);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: all var(--transition-fast);
    z-index: 10;
}

.modal-close:hover {
    background: var(--danger);
    color: var(--white);
    transform: rotate(90deg);
}

/* Dentro de header: sin position absolute */
.modal-header .modal-close {
    position: static;
    flex-shrink: 0;
}

/* ============================================
   HEADER
   ============================================ */

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg) var(--space-xl);
    border-bottom: 2px solid var(--light);
}

.modal-header h2,
.modal-header h3 {
    margin: 0;
    font-size: var(--text-2xl);
    color: var(--dark);
}

/* ============================================
   BODY
   ============================================ */

.modal-body {
    padding: var(--space-xl);
    padding-bottom: calc(var(--space-xl) + env(safe-area-inset-bottom, 0px));
}

/* ============================================
   FOOTER
   ============================================ */

.modal-footer {
    display: flex;
    gap: var(--gap-md);
    justify-content: flex-end;
    padding: var(--space-lg) var(--space-xl);
    border-top: 2px solid var(--light);
}

/* ============================================
   VARIANTES DE HEADER
   ============================================ */

/* Warning gradient (calificar trabajador - empleador) */
.modal-header--warning {
    background: linear-gradient(135deg, var(--warning) 0%, #d97706 100%);
    border-bottom: none;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.modal-header--warning h2 {
    color: var(--white);
}

.modal-header--warning .modal-close {
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
}

.modal-header--warning .modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Primary gradient (calificar empleador - trabajador) */
.modal-header--primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-bottom: none;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.modal-header--primary h2 {
    color: var(--white);
}

.modal-header--primary .modal-close {
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
}

.modal-header--primary .modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* ============================================
   SCROLLBAR
   ============================================ */

.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track {
    background: var(--light);
}

.modal-content::-webkit-scrollbar-thumb {
    background: var(--gray);
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-height: 95vh;
    }

    .modal-body {
        padding: var(--space-lg);
        padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom, 0px));
    }

    .modal-footer {
        flex-direction: column;
    }

    .modal-footer .btn {
        width: 100%;
    }
}

/* ============================================
   REPORTAR MODAL
   ============================================ */

.reportar-subtitulo {
    font-size: var(--text-sm);
    color: var(--gray-500);
    margin-bottom: 1rem;
    font-style: italic;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reportar-label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.reportar-motivos {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.reportar-motivo-label {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0.75rem;
    border: 1.5px solid var(--gray-200);
    border-radius: 8px;
    cursor: pointer;
    font-size: var(--text-sm);
    color: var(--gray-700);
    transition: border-color 0.15s, background 0.15s;
}

.reportar-motivo-label:has(input:checked) {
    border-color: var(--danger);
    background: var(--danger-light);
    color: var(--danger);
    font-weight: 500;
}

.reportar-motivo-label input[type="radio"] {
    accent-color: var(--danger);
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

.reportar-descripcion {
    width: 100%;
    box-sizing: border-box;
    padding: 0.625rem 0.75rem;
    border: 1.5px solid var(--gray-200);
    border-radius: 8px;
    font-family: inherit;
    font-size: var(--text-sm);
    color: var(--gray-700);
    resize: none;
    margin-top: 0.5rem;
    transition: border-color 0.15s;
}

.reportar-descripcion:focus {
    outline: none;
    border-color: var(--primary);
}

/* Botón flotante "Reportar" en detalle de oferta */
.btn-reportar-link {
    display: block;
    width: 100%;
    background: none;
    border: none;
    padding: 0.5rem;
    font-size: var(--text-xs);
    color: var(--gray-400);
    cursor: pointer;
    text-align: center;
    margin-top: 0.25rem;
    transition: color 0.15s;
}

.btn-reportar-link:hover {
    color: var(--danger);
}

/* Botón "Reportar perfil" en perfil público */
.btn-reportar-perfil {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: none;
    border: 1.5px solid var(--gray-200);
    border-radius: 20px;
    padding: 0.375rem 0.875rem;
    font-size: var(--text-xs);
    color: var(--gray-400);
    cursor: pointer;
    margin-top: 0.75rem;
    transition: border-color 0.15s, color 0.15s;
}

.btn-reportar-perfil:hover {
    border-color: var(--danger);
    color: var(--danger);
}

/* ============================================
   ACCESIBILIDAD
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .modal-overlay,
    .modal-content {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
