/* =========================================================
   SP POPUP CORE - OVERLAY
========================================================= */
.sp-popup-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999998;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    backdrop-filter: blur(2px);
}

.sp-popup-overlay--visible {
    display: flex;
}

/* =========================================================
   SP POPUP CORE - POPUP CAJA PRINCIPAL
========================================================= */
.sp-popup {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 16px 48px -4px rgba(0,0,0,0.14);
    width: 100%;
    max-width: 560px;
    max-height: 88vh;
    overflow-y: auto;
    z-index: 999999;
    opacity: 0;
    transform: translateY(12px) scale(0.985);
    transition: opacity 0.2s ease, transform 0.2s ease;
    box-sizing: border-box;
}

.sp-popup--visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.sp-popup__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px 14px;
    border-bottom: 1px solid #f3f4f6;
}

.sp-popup__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.sp-popup__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: none;
    border: none;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    color: #9ca3af;
    border-radius: 6px;
    padding: 0;
    transition: color 0.15s, background 0.15s;
}

.sp-popup__close:hover {
    color: #111827;
    background: #f3f4f6;
}

.sp-popup__body {
    padding: 18px 22px 22px;
    transition: opacity 0.15s ease;
}

/* =========================================================
   SP POPUP CORE - ESTADO LOADING
========================================================= */
.sp-popup.sp_loading .sp-popup__body {
    opacity: 0.45;
    pointer-events: none;
}

/* =========================================================
   SP POPUP CORE - BANNER DE ERROR INLINE
========================================================= */
.sp-popup-error-banner {
    display: none;
    align-items: flex-start;
    gap: 8px;
    margin: 0 22px;
    padding: 10px 14px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 7px;
    font-size: 13px;
    color: #b91c1c;
    line-height: 1.45;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    margin-bottom: 0;
}

.sp-popup-error-banner + .sp-popup__body {
    padding-top: 14px;
}

.sp-popup-error-banner svg {
    flex-shrink: 0;
    margin-top: 1px;
    color: #ef4444;
}

.sp-popup-error-banner--visible {
    opacity: 1;
    transform: translateY(0);
    display: flex !important;
}

/* =========================================================
   SP POPUP CORE - FOOTER GENÉRICO (Contenedor de botones)
========================================================= */
.sp-popup-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 16px;
}

/* =========================================================
   RESPONSIVE
========================================================= */
@media screen and (max-width: 600px) {
    .sp-popup {
        max-height: 95vh;
        border-radius: 10px;
    }

    .sp-popup-footer {
        flex-direction: column;
        gap: 8px;
    }

    .sp-popup-footer button {
        width: 100%;
        justify-content: center;
    }
}

/* =========================================================
   DARK THEME
========================================================= */
body.sp-wsv-theme-dark .sp-popup-overlay {
    background: rgba(0, 0, 0, 0.6);
}

body.sp-wsv-theme-dark .sp-popup {
    background: #1f2937;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.3), 0 16px 48px -4px rgba(0,0,0,0.5);
}

body.sp-wsv-theme-dark .sp-popup__head {
    border-bottom-color: #374151;
}

body.sp-wsv-theme-dark .sp-popup__title {
    color: #f9fafb;
}

body.sp-wsv-theme-dark .sp-popup__close {
    color: #9ca3af;
}

body.sp-wsv-theme-dark .sp-popup__close:hover {
    color: #f9fafb;
    background: #374151;
}

body.sp-wsv-theme-dark .sp-popup-error-banner {
    background: #450a0a;
    border-color: #7f1d1d;
    color: #fca5a5;
}