/**
 * Archivo: assets/css/shared/modals.css
 * Sistema: Allage - Estilos de Modales Globales
 * Versión: 1.1.3
 * Fecha: 11 Febrero 2026
 *
 * CHANGELOG v1.1.3:
 * - Botón X unificado: font-size 28px, width/height 36px
 * - Variante .dark-header para headers oscuros
 * - Eliminados duplicados en módulos (usan este global)
 *
 * CHANGELOG v1.1.2:
 * - Fix doble scroll: container overflow:hidden + flex layout
 * - Header/Footer: flex-shrink:0 (fijos)
 * - Body: flex:1 + scrollbar oculta (único con scroll)
 *
 * CHANGELOG v1.1.1:
 * - Fix doble scroll: overflow:hidden en overlay, visible en modal
 * - Ocultar scrollbar en modal-body (mantiene funcionalidad)
 *
 * CHANGELOG v1.1.0:
 * - Añadido .ltn-modal-header-left, -icon, -title para estructura header
 * - Añadido .ltn-modal-subtitle para subtítulos
 * - Añadido soporte para modales arrastrables (.dragging)
 * - Añadida animación @keyframes ltn-spin
 * - Actualizado overlay con var(--ltn-overlay-dark-60)
 *
 * DESCRIPCIÓN:
 * Estilos de modales compartidos entre admin y frontend.
 *
 * CLASES DISPONIBLES:
 * - .ltn-modal-close             : Botón X de cierre (headers claros)
 * - .ltn-modal-close.dark-header : Botón X de cierre (headers oscuros)
 * - .ltn-modal-overlay           : Overlay del modal
 * - .ltn-modal-content           : Contenedor del modal
 * - .ltn-modal-header            : Header del modal
 * - .ltn-modal-header-left       : Container icono + título
 * - .ltn-modal-header-icon       : Icono SVG del header
 * - .ltn-modal-header-title      : Container título + subtítulo
 * - .ltn-modal-subtitle          : Subtítulo del header
 * - .ltn-modal-body              : Cuerpo del modal
 * - .ltn-modal-footer            : Footer del modal
 */

/* ===========================================
   BOTÓN X DE CIERRE - UNIVERSAL v1.1.3
   Estilo unificado para todos los modales
   =========================================== */
.ltn-modal-close {
    background: transparent;
    border: none;
    font-size: 28px;  /* v1.1.3: Más grande (antes 1.5em ~24px) */
    font-weight: bold;
    cursor: pointer;
    color: var(--ltn-gray-400, #9CA3AF);
    padding: 0;
    border-radius: 6px;
    transition: all 0.2s ease;
    width: 36px;  /* v1.1.3: Más grande para 28px */
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
}

.ltn-modal-close:hover {
    background: var(--ltn-gray-100, #F8FAFC);
    color: var(--ltn-gray-900, #111827);
}

/* Variante para headers con fondo oscuro (verde corporativo) */
.ltn-modal-close.dark-header {
    color: var(--ltn-white, white);
    background: transparent;
}

.ltn-modal-close.dark-header:hover {
    background: var(--ltn-overlay-white-20, rgba(255, 255, 255, 0.2));
    color: var(--ltn-white, white);
}

/* ===========================================
   ESTRUCTURA MODAL BÁSICA
   =========================================== */
.ltn-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--ltn-overlay-dark-60, rgba(0, 0, 0, 0.6));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.ltn-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.ltn-modal-content {
    background: var(--ltn-white, white);
    border-radius: var(--ltn-border-radius-lg, 12px);
    box-shadow: 0 20px 60px var(--ltn-overlay-black-30, rgba(0, 0, 0, 0.3));
    width: 90%;
    max-width: 520px;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.ltn-modal-overlay.active .ltn-modal-content {
    transform: scale(1);
}

.ltn-modal-header {
    background: linear-gradient(135deg,
        var(--ltn-green-dark, #3e5120) 0%,
        var(--ltn-green-primary, #506727) 50%,
        var(--ltn-green-light, #BACD70) 100%);
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: var(--ltn-border-radius-lg, 12px) var(--ltn-border-radius-lg, 12px) 0 0;
    color: white;
}

.ltn-modal-header h3 {
    margin: 0;
    color: white;
    font-size: 1.15em;
    font-weight: 600;
    line-height: 1.3;
}

/* Container para icono + título en header */
.ltn-modal-header-left {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Icono SVG del header */
.ltn-modal-header-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ltn-white, white);
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.ltn-modal-header-icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
}

/* Container del título + subtítulo */
.ltn-modal-header-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Subtítulo del header */
.ltn-modal-subtitle,
.ltn-modal-header .modal-subtitle {
    margin: 0;
    color: var(--ltn-overlay-white-80, rgba(255, 255, 255, 0.8));
    font-size: 0.85em;
    font-weight: normal;
}

.ltn-modal-body {
    padding: 24px;
    max-height: calc(90vh - 180px);
    overflow-y: auto;
}

.ltn-modal-footer {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    background: var(--ltn-gray-100, #F8FAFC);
    border-top: 1px solid var(--ltn-gray-200, #E2E8F0);
    border-radius: 0 0 var(--ltn-border-radius-lg, 12px) var(--ltn-border-radius-lg, 12px);
    justify-content: flex-end;
}

/* ===========================================
   ANIMACIÓN DE ENTRADA
   =========================================== */
@keyframes ltn-modal-slide-in {
    from {
        transform: translate(-50%, -50%) scale(0.9);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* Animación de spinner para loading */
@keyframes ltn-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.ltn-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--ltn-overlay-white-30, rgba(255, 255, 255, 0.3));
    border-top-color: white;
    border-radius: 50%;
    animation: ltn-spin 0.8s linear infinite;
}

.ltn-spinner.small {
    width: 14px;
    height: 14px;
}

/* ===========================================
   SOPORTE PARA MODALES ARRASTRABLES
   =========================================== */
.ltn-modal-header.draggable {
    cursor: move;
    user-select: none;
}

.ltn-modal-content.dragging {
    cursor: move;
    user-select: none;
    transition: none !important;
}

/* ===========================================
   ALIAS DE COMPATIBILIDAD (.acf-* → .ltn-*)
   v1.1.3: Estilos idénticos a .ltn-modal-close
   =========================================== */
.acf-modal-close {
    background: transparent;
    border: none;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: var(--ltn-gray-400, #9CA3AF);
    padding: 0;
    border-radius: 6px;
    transition: all 0.2s ease;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
}

.acf-modal-close:hover {
    background: var(--ltn-gray-100, #F8FAFC);
    color: var(--ltn-gray-900, #111827);
}

.acf-modal-close.dark-header {
    color: var(--ltn-white, white);
    background: transparent;
}

.acf-modal-close.dark-header:hover {
    background: var(--ltn-overlay-white-20, rgba(255, 255, 255, 0.2));
    color: var(--ltn-white, white);
}

.acf-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--ltn-overlay-dark-60, rgba(0, 0, 0, 0.6));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.acf-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ===========================================
   ALIAS ADMIN (.ltn-allage-modal-* → .ltn-modal-*)
   Para templates de admin que usan prefijo ltn-allage-
   =========================================== */
.ltn-allage-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--ltn-overlay-dark-60, rgba(0, 0, 0, 0.6));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    overflow: hidden; /* v1.1.1: Evitar doble scroll */
}

.ltn-allage-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.ltn-allage-modal {
    display: flex;
    flex-direction: column;
    background: var(--ltn-white, white);
    border-radius: var(--ltn-border-radius-lg, 12px);
    box-shadow: 0 20px 60px var(--ltn-overlay-black-30, rgba(0, 0, 0, 0.3));
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden; /* v1.1.2: Container sin scroll */
}

.ltn-allage-modal-header {
    flex-shrink: 0; /* v1.1.2: Header fijo */
    background: linear-gradient(135deg,
        var(--ltn-green-dark, #3e5120) 0%,
        var(--ltn-green-primary, #506727) 50%,
        var(--ltn-green-light, #BACD70) 100%);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: var(--ltn-border-radius-lg, 12px) var(--ltn-border-radius-lg, 12px) 0 0;
    color: var(--ltn-white, white);
}

.ltn-allage-modal-header h3 {
    margin: 0;
    color: var(--ltn-white, white);
    font-size: 18px;
    font-weight: 600;
}

.ltn-allage-modal-body {
    flex: 1; /* v1.1.2: Body ocupa espacio restante */
    padding: 20px;
    overflow-y: auto;
    /* v1.1.2: Ocultar barra de scroll pero mantener funcionalidad */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

.ltn-allage-modal-body::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.ltn-allage-modal-footer {
    flex-shrink: 0; /* v1.1.2: Footer fijo */
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    background: var(--ltn-gray-100, #F8FAFC);
    border-top: 1px solid var(--ltn-gray-200, #E2E8F0);
    border-radius: 0 0 var(--ltn-border-radius-lg, 12px) var(--ltn-border-radius-lg, 12px);
    justify-content: flex-end;
}

/* Variante footer con acciones a ambos lados */
.ltn-allage-modal-footer.space-between {
    justify-content: space-between;
    align-items: center;
}

/* ===========================================
   RESPONSIVE
   =========================================== */
@media (max-width: 600px) {
    .ltn-modal-content {
        width: 95%;
        max-height: 95vh;
    }

    .ltn-modal-header {
        padding: 14px 18px;
    }

    .ltn-modal-header h3 {
        font-size: 1.05em;
    }

    .ltn-modal-body {
        padding: 18px;
    }

    .ltn-modal-footer {
        flex-direction: column-reverse;
        padding: 16px 18px;
    }

    .ltn-modal-footer .ltn-button,
    .ltn-modal-footer .ltn-btn,
    .ltn-modal-footer .acf-button,
    .ltn-modal-footer .acf-btn {
        width: 100%;
    }
}
