/* =====================================================================================
   WINX UNIFICADO - PC + MÓVIL + TEMA COLD.CSS
   ===================================================================================== */

/* --------------------------------------------------
   BASE GENERAL
-------------------------------------------------- */

.winx {
    position: fixed;
    inset: 0;
    display: none;
    width: 100%;
    height: 100%;
    overflow: hidden;
    outline: 0;
    z-index: 1050;
}

.winx.window-show {
    display: block;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(6px);
}

/* --------------------------------------------------
   CONTENEDOR PRINCIPAL (centrado absoluto)
-------------------------------------------------- */

.winx-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    width: min(600px, 92vw);
    max-height: 90vh;
    border-radius: var(--radius, 0.5rem);
    background: var(--bg, #ffffff);
    color: var(--text, #212529);
    border: 1px solid var(--border, #dee2e6);
    box-shadow: var(--shadow, 0 0.5rem 1rem rgba(0, 0, 0, 0.15));
    overflow: hidden;
}

/* --------------------------------------------------
   BOTÓN DE CIERRE
-------------------------------------------------- */

button.winx-close.window-close {
    border: none;
    background: none;
    font-size: 28px;
    position: absolute;
    right: 10px;
    color: var(--text, #212529);
    cursor: pointer;
    z-index: 10;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

button.winx-close.window-close:hover {
    opacity: 1;
}

/* --------------------------------------------------
   ANIMACIÓN SUAVE DESDE ARRIBA
-------------------------------------------------- */

.winx.window-fade .winx-content {
    opacity: 0;
    transform: translate(-50%, -60%);
}

.winx.window-show .winx-content {
    opacity: 1;
    transform: translate(-50%, -50%);
    transition: transform 0.25s ease, opacity 0.25s ease;
}

/* --------------------------------------------------
   HEADER
-------------------------------------------------- */

[class*="winx-header"] {
    padding: 16px 20px;
    background: linear-gradient(180deg, var(--card2, #f8f9fa), transparent);
    border-bottom: 1px solid var(--border, #dee2e6);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    cursor: move;
    flex-shrink: 0;
}

[class*="winx-header"] h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 500;
}

/* --------------------------------------------------
   BODY
-------------------------------------------------- */

[class*="winx-body"] {
    padding: 20px;
    overflow-y: auto;
    background: transparent;
    flex: 1 1 auto;
}

/* --------------------------------------------------
   FOOTER
-------------------------------------------------- */

[class*="winx-footer"] {
    padding: 12px 16px;
    border-top: 1px solid var(--border, #dee2e6);
    display: flex;
    gap: 10px;
    background: linear-gradient(0deg, var(--card2, #f8f9fa), transparent);
    flex-shrink: 0;
    flex-wrap: wrap;
}

/* --------------------------------------------------
   FOOTER ESPECÍFICO PARA ALERT (centrado)
-------------------------------------------------- */

.winx-alert [class*="winx-footer"] { 
    justify-content: center;
}

/* --------------------------------------------------
   BOTONES
-------------------------------------------------- */

.buttons-container {
    display: flex;
    width: 100%;
    gap: 10px;
    flex-wrap: wrap;
}

.buttons-container.space-between-buttons {
    justify-content: space-between;
}

.buttons-container.center-buttons {
    justify-content: center;
}

/* --------------------------------------------------
   ==================================================
   VERSIÓN MÓVIL (max-width: 768px)
   ==================================================
-------------------------------------------------- */

@media (max-width: 768px) {

    /* --------------------------------------------------
       DIALOG: OCUPA TODA LA PANTALLA (100% ancho y alto)
    --------------------------------------------------- */

    .winx-dialog .winx-content,
    .winx-content.dialog {
        width: 100vw !important;
        height: 100dvh !important;
        max-width: none !important;
        max-height: none !important;
        border-radius: 0 !important;
        top: 0 !important;
        left: 0 !important;
        transform: none !important;
        border-left: none !important;
        border-right: none !important;
        border-top: none !important;
    }

    /* --------------------------------------------------
       WARN Y ALERT: CENTRADOS AL 95% (como en PC)
    --------------------------------------------------- */

    .winx-alert .winx-content,
    .winx-warn .winx-content,
    .winx-content.alert,
    .winx-content.warn {
        width: 95vw !important;
        height: auto !important;
        max-height: 90vh !important;
        max-width: 500px !important;
        border-radius: var(--radius, 0.5rem) !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        border: 1px solid var(--border, #dee2e6) !important;
    }

    /* --------------------------------------------------
       AJUSTE DE ANIMACIÓN PARA MÓVIL
    --------------------------------------------------- */

    .winx.window-fade .winx-content.dialog,
    .winx.window-fade .winx-content {
        opacity: 0;
    }

    .winx.window-fade .winx-dialog .winx-content {
        transform: translateY(-40px) !important;
    }

    .winx.window-fade .winx-alert .winx-content,
    .winx.window-fade .winx-warn .winx-content {
        transform: translate(-50%, -60%) !important;
    }

    .winx.window-show .winx-dialog .winx-content {
        opacity: 1;
        transform: translateY(0) !important;
        transition: transform 0.25s ease, opacity 0.25s ease;
    }

    .winx.window-show .winx-alert .winx-content,
    .winx.window-show .winx-warn .winx-content {
        opacity: 1;
        transform: translate(-50%, -50%) !important;
        transition: transform 0.25s ease, opacity 0.25s ease;
    }

    /* --------------------------------------------------
       AJUSTES INTERNOS PARA MÓVIL
    --------------------------------------------------- */

    .winx-dialog [class*="winx-body"] {
        flex: 1 1 auto;
        max-height: none;
    }

    .winx-alert [class*="winx-body"],
    .winx-warn [class*="winx-body"] {
        max-height: 60vh;
    }

    [class*="winx-footer"] {
        justify-content: center;
        padding: 12px;
    }

    .winx-dialog [class*="winx-footer"] {
        justify-content: flex-end;
    }
}

/* --------------------------------------------------
   ACCESIBILIDAD (reducir movimiento)
-------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .winx-content,
    .winx.window-show .winx-content,
    .winx.window-fade .winx-content {
        transition: none !important;
        animation: none !important;
    }
}

/* --------------------------------------------------
   SOPORTE PARA NOTCH (safe areas)
-------------------------------------------------- */

@supports (padding: max(0px)) {
    .winx-dialog .winx-content {
        padding-top: env(safe-area-inset-top, 0);
        padding-bottom: env(safe-area-inset-bottom, 0);
        padding-left: env(safe-area-inset-left, 0);
        padding-right: env(safe-area-inset-right, 0);
    }
    
    .winx-dialog [class*="winx-header"] {
        padding-top: max(16px, env(safe-area-inset-top));
    }
    
    .winx-dialog [class*="winx-footer"] {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
}