/**
 * ============================================================
 * SOC TOAST — Dynamic Island con SVG Gooey Filter
 * ============================================================
 * Inspirado en Sileo: dos <rect> SVG fusionados por un filtro
 * Gooey (feGaussianBlur + feColorMatrix). Píldora pequeña
 * arriba que se expande orgánicamente al cuerpo grande abajo.
 */

:root {
    --soc-spring-easing: linear(
        0, 0.002 0.6%, 0.007 1.2%, 0.015 1.8%, 0.026 2.4%,
        0.041 3.1%, 0.06 3.8%, 0.108 5.3%, 0.157 6.6%,
        0.214 8%, 0.467 13.7%, 0.577 16.3%, 0.631 17.7%,
        0.682 19.1%, 0.73 20.5%, 0.771 21.8%, 0.808 23.1%,
        0.844 24.5%, 0.874 25.8%, 0.903 27.2%, 0.928 28.6%,
        0.952 30.1%, 0.972 31.6%, 0.988 33.1%, 1.01 35.7%,
        1.025 38.5%, 1.034 41.6%, 1.038 45%, 1.035 50.1%,
        1.012 64.2%, 1.003 73%, 0.999 83.7%, 1
    );
    --soc-duration: 600ms;
    --soc-pill-height: 36px;
    --soc-body-width: 340px;
    --soc-roundness: 50;
}

/* ============================================================
   CONTENEDOR GLOBAL
   ============================================================ */
.soc-toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    pointer-events: none;
}

/* ============================================================
   TOAST — Wrapper
   ============================================================ */
.soc-toast {
    pointer-events: all;
    position: relative;
    box-sizing: border-box;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    overflow: visible;
    font-family: 'DM Sans', 'Inter', -apple-system, sans-serif;
    transform-origin: center top;
    cursor: pointer;
    /* Tamaño definido por JS */
    width: var(--soc-body-width);
    
    /* Animación de entrada */
    animation: soc-pop-in 0.5s var(--soc-spring-easing) forwards;
    opacity: 0;
}

@keyframes soc-pop-in {
    0% { transform: scale(0.85) translateY(-8px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

.soc-toast.soc-toast-out {
    animation: soc-pop-out 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes soc-pop-out {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0.9) translateY(-8px); opacity: 0; }
}

/* ============================================================
   SVG CANVAS — Posición absoluta detrás del contenido
   ============================================================ */
.soc-toast-canvas {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    pointer-events: none;
    overflow: visible;
}

.soc-toast-canvas svg {
    overflow: visible;
    display: block;
    filter: drop-shadow(0 4px 20px rgba(0, 0, 0, 0.08))
            drop-shadow(0 1px 4px rgba(0, 0, 0, 0.04));
}

/* Rects del SVG — transiciones suaves */
[data-soc-pill] {
    transition:
        x var(--soc-duration) var(--soc-spring-easing),
        width var(--soc-duration) var(--soc-spring-easing),
        height var(--soc-duration) var(--soc-spring-easing);
}

[data-soc-body] {
    transition:
        height var(--soc-duration) var(--soc-spring-easing),
        opacity calc(var(--soc-duration) * 0.5) ease;
}

/* ============================================================
   CONTENIDO — Sobre el SVG
   ============================================================ */
.soc-toast-content {
    position: relative;
    z-index: 1;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* ---- HEADER (Dentro de la pastilla — solo el ancho de su contenido) ---- */
.soc-toast-header {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-sizing: border-box;
    height: var(--soc-pill-height);
    cursor: pointer;
    color: inherit;
    padding: 0 14px;
    width: fit-content;
    max-width: 100%;
    flex-shrink: 0;
}

/* Icono badge */
.soc-toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border-radius: 9999px;
    line-height: 0;
    color: var(--soc-toast-icon-color);
    background-color: var(--soc-toast-icon-bg);
    padding: 2px;
    box-sizing: border-box;
}
.soc-toast-icon svg {
    width: 14px;
    height: 14px;
    stroke-width: 2.5;
}

/* Título */
.soc-toast-title {
    font-family: 'Bricolage Grotesque', 'Outfit', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    color: var(--soc-toast-title-color);
}

/* Hora en cabecera (sólo para píldora compacta) */
.soc-toast-header-time {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--soc-toast-title-color);
    opacity: 0.5;
    margin-left: 6px;
    white-space: nowrap;
    border-left: 1px solid rgba(0, 0, 0, 0.15);
    padding-left: 6px;
}
.soc-theme-dark .soc-toast-header-time {
    border-left-color: rgba(255, 255, 255, 0.15);
}

/* Botón cerrar */
.soc-toast-close {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease, transform 0.15s ease;
    outline: none;
    font-size: 14px;
}
.soc-toast:hover .soc-toast-close { opacity: 1; }
.soc-toast-close:hover { transform: scale(1.15); color: #555; }
.soc-toast-close:active { transform: scale(0.95); }

/* ---- BODY (Contenido expandido) ---- */
.soc-toast-body {
    overflow: hidden;
    width: var(--soc-body-width);
    box-sizing: border-box;
    padding: 10px 16px 14px 16px;
    margin: 0 auto;
}

/* Descripción */
.soc-toast-desc-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.soc-toast-desc {
    font-size: 13px;
    color: #374151;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    font-weight: 500;
    flex: 1;
    min-width: 0;
    text-align: left;
}

/* Hora */
.soc-toast-time {
    font-size: 11px;
    color: #9ca3af;
    white-space: nowrap;
    line-height: 1.5;
    flex-shrink: 0;
}

/* Botón de Acción */
.soc-toast-action-wrapper {
    margin-top: 10px;
}

.soc-toast-action {
    display: block;
    box-sizing: border-box;
    width: 100%;
    border: none;
    border-radius: 999px;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    outline: none;
    transition: background-color 0.15s ease, transform 0.15s ease;
    background: var(--soc-toast-action-bg);
    color: var(--soc-toast-action-color);
}
.soc-toast-action:hover { background: var(--soc-toast-action-hover-bg); }
.soc-toast-action:active { transform: scale(0.97); }

/* Barra de progreso */
.soc-toast-progress {
    margin-top: 10px;
    overflow: hidden;
    border-radius: 2px;
    height: 3px;
    background: var(--soc-toast-progress-bg);
}
.soc-toast-progress-bar {
    height: 100%;
    border-radius: 2px;
    transform-origin: left center;
    animation: soc-prog linear forwards;
    background: var(--soc-toast-progress-bar);
    animation-play-state: running;
}
.soc-toast-progress-paused .soc-toast-progress-bar {
    animation-play-state: paused;
}
@keyframes soc-prog {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

/* ---- Elementos Adicionales de la Alerta (Imágenes, Inputs, Switches) ---- */
.soc-toast-image-wrapper {
    margin-top: 10px;
    border-radius: 12px;
    overflow: hidden;
    max-height: 140px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
.soc-toast-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Inputs y Selects dentro del body */
.soc-toast-form-group {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
}
.soc-toast-label {
    font-size: 11px;
    font-weight: 600;
    color: #4b5563;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: left;
}
.soc-toast-input,
.soc-toast-select {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.6);
    font-family: inherit;
    font-size: 13px;
    color: #1f2937;
    outline: none;
    transition: border-color 0.15s, background-color 0.15s;
}
.soc-toast-input:focus,
.soc-toast-select:focus {
    border-color: var(--soc-toast-progress-bar);
    background: #fff;
}

/* Switch Toggle Premium */
.soc-toast-toggle-wrapper {
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 10px;
}
.soc-toast-toggle-label {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    text-align: left;
}
.soc-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}
.soc-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.soc-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(156, 163, 175, 0.3);
    transition: .3s;
    border-radius: 34px;
}
.soc-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.soc-switch input:checked + .soc-slider {
    background-color: var(--soc-toast-progress-bar);
}
.soc-switch input:checked + .soc-slider:before {
    transform: translateX(18px);
}

/* Soporte de temas oscuros para componentes interactivos */
.soc-theme-dark .soc-toast-label {
    color: #9ca3af;
}
.soc-theme-dark .soc-toast-input,
.soc-theme-dark .soc-toast-select {
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.3);
    color: #f3f4f6;
}
.soc-theme-dark .soc-toast-input:focus,
.soc-theme-dark .soc-toast-select:focus {
    border-color: var(--soc-toast-progress-bar);
    background: rgba(0, 0, 0, 0.5);
}
.soc-theme-dark .soc-toast-toggle-label {
    color: #e5e7eb;
}

/* ============================================================
   PALETAS DE COLORES
   ============================================================ */
.soc-toast {
    --soc-toast-fill: rgba(255, 255, 255, 0.97);
    --soc-toast-icon-bg: rgba(107, 114, 128, 0.12);
    --soc-toast-icon-color: #4b5563;
    --soc-toast-title-color: #1f2937;
    --soc-toast-action-bg: rgba(107, 114, 128, 0.08);
    --soc-toast-action-color: #4b5563;
    --soc-toast-action-hover-bg: rgba(107, 114, 128, 0.12);
    --soc-toast-progress-bg: rgba(107, 114, 128, 0.1);
    --soc-toast-progress-bar: #4b5563;
}

.soc-toast-success {
    --soc-toast-fill: rgba(255, 255, 255, 0.97);
    --soc-toast-icon-bg: rgba(22, 163, 74, 0.15);
    --soc-toast-icon-color: #16a34a;
    --soc-toast-title-color: #15803d;
    --soc-toast-action-bg: rgba(22, 163, 74, 0.1);
    --soc-toast-action-color: #16a34a;
    --soc-toast-action-hover-bg: rgba(22, 163, 74, 0.15);
    --soc-toast-progress-bg: rgba(22, 163, 74, 0.1);
    --soc-toast-progress-bar: #16a34a;
}

.soc-toast-error {
    --soc-toast-fill: rgba(255, 255, 255, 0.97);
    --soc-toast-icon-bg: rgba(220, 38, 38, 0.15);
    --soc-toast-icon-color: #dc2626;
    --soc-toast-title-color: #b91c1c;
    --soc-toast-action-bg: rgba(220, 38, 38, 0.1);
    --soc-toast-action-color: #dc2626;
    --soc-toast-action-hover-bg: rgba(220, 38, 38, 0.15);
    --soc-toast-progress-bg: rgba(220, 38, 38, 0.1);
    --soc-toast-progress-bar: #dc2626;
}

.soc-toast-warning {
    --soc-toast-fill: rgba(255, 255, 255, 0.97);
    --soc-toast-icon-bg: rgba(217, 119, 6, 0.15);
    --soc-toast-icon-color: #d97706;
    --soc-toast-title-color: #b45309;
    --soc-toast-action-bg: rgba(217, 119, 6, 0.1);
    --soc-toast-action-color: #d97706;
    --soc-toast-action-hover-bg: rgba(217, 119, 6, 0.15);
    --soc-toast-progress-bg: rgba(217, 119, 6, 0.1);
    --soc-toast-progress-bar: #d97706;
}

.soc-toast-info {
    --soc-toast-fill: rgba(255, 255, 255, 0.97);
    --soc-toast-icon-bg: rgba(37, 99, 235, 0.15);
    --soc-toast-icon-color: #2563eb;
    --soc-toast-title-color: #1d4ed8;
    --soc-toast-action-bg: rgba(37, 99, 235, 0.1);
    --soc-toast-action-color: #2563eb;
    --soc-toast-action-hover-bg: rgba(37, 99, 235, 0.15);
    --soc-toast-progress-bg: rgba(37, 99, 235, 0.1);
    --soc-toast-progress-bar: #2563eb;
}

/* Spinner */
.soc-spinner {
    width: 14px;
    height: 14px;
    animation: soc-spin 1s linear infinite;
}
@keyframes soc-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================================
   MODAL DE CONFIRMACIÓN GLASSMORPHIC
   ============================================================ */
.soc-confirm-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
}

@keyframes soc-confirm-fade-in {
    0% { background-color: rgba(0,0,0,0); backdrop-filter: blur(0px); -webkit-backdrop-filter: blur(0px); }
    100% { background-color: rgba(0,0,0,0.35); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
}
@keyframes soc-confirm-fade-out {
    0% { background-color: rgba(0,0,0,0.35); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
    100% { background-color: rgba(0,0,0,0); backdrop-filter: blur(0px); -webkit-backdrop-filter: blur(0px); }
}
.soc-confirm-overlay.soc-confirm-visible { animation: soc-confirm-fade-in 0.32s cubic-bezier(0.22,1,0.36,1) forwards; }
.soc-confirm-overlay.soc-confirm-closing { animation: soc-confirm-fade-out 0.32s cubic-bezier(0.22,1,0.36,1) forwards; }

.soc-confirm-box {
    box-sizing: border-box;
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(20px) saturate(190%);
    -webkit-backdrop-filter: blur(20px) saturate(190%);
    border: 1px solid rgba(255,255,255,0.5);
    border-radius: 24px;
    padding: 32px;
    max-width: 380px;
    width: 90%;
    text-align: center;
    opacity: 0;
    box-shadow: 0 10px 30px -10px rgba(0,0,0,0.08), 0 30px 70px -15px rgba(0,69,170,0.18), inset 0 1px 0 0 rgba(255,255,255,0.85);
}
@keyframes soc-confirm-zoom-in {
    0% { transform: scale(0.9) translateY(15px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}
@keyframes soc-confirm-zoom-out {
    0% { transform: scale(1) translateY(0); opacity: 1; }
    100% { transform: scale(0.93) translateY(10px); opacity: 0; }
}
.soc-confirm-visible .soc-confirm-box { animation: soc-confirm-zoom-in 0.42s cubic-bezier(0.34,1.76,0.55,1) forwards; }
.soc-confirm-closing .soc-confirm-box { animation: soc-confirm-zoom-out 0.3s cubic-bezier(0.22,1,0.36,1) forwards; }

.soc-confirm-icon { width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 18px; transform: scale(0.6) rotate(-20deg); opacity: 0; transition: transform 0.5s cubic-bezier(0.34,1.76,0.55,1) 0.1s, opacity 0.4s ease 0.1s; }
.soc-confirm-visible .soc-confirm-icon { transform: scale(1) rotate(0deg); opacity: 1; }
.soc-confirm-icon svg { width: 22px; height: 22px; stroke-width: 2.5; }

.soc-confirm-title { font-family: 'Bricolage Grotesque', 'Outfit', sans-serif; font-size: 18px; font-weight: 700; color: #111827; margin: 0 0 8px; opacity: 0; transform: translateY(10px); transition: opacity 0.4s ease 0.15s, transform 0.4s cubic-bezier(0.22,1,0.36,1) 0.15s; }
.soc-confirm-visible .soc-confirm-title { opacity: 1; transform: translateY(0); }

.soc-confirm-msg { font-size: 13.5px; color: #4b5563; margin: 0 0 24px; line-height: 1.5; opacity: 0; transform: translateY(10px); transition: opacity 0.4s ease 0.2s, transform 0.4s cubic-bezier(0.22,1,0.36,1) 0.2s; }
.soc-confirm-visible .soc-confirm-msg { opacity: 1; transform: translateY(0); }

.soc-confirm-buttons { display: flex; gap: 12px; opacity: 0; transform: translateY(12px); transition: opacity 0.4s ease 0.25s, transform 0.4s cubic-bezier(0.22,1,0.36,1) 0.25s; }
.soc-confirm-visible .soc-confirm-buttons { opacity: 1; transform: translateY(0); }

.soc-confirm-btn { flex: 1; padding: 11px 20px; border: 1px solid transparent; border-radius: 50px; font-size: 13.5px; font-weight: 700; cursor: pointer; transition: transform 0.15s ease, background-color 0.2s; }
.soc-confirm-btn:hover { transform: scale(0.97); }
.soc-confirm-btn:active { transform: scale(0.94); }
.soc-btn-cancel { background: rgba(107,114,128,0.08); color: #374151; border-color: rgba(107,114,128,0.15); }
.soc-btn-cancel:hover { background: rgba(107,114,128,0.12); }
.soc-btn-confirm { color: #fff; box-shadow: 0 4px 15px rgba(0,0,0,0.08); }
.soc-btn-confirm:hover { filter: brightness(1.08); }

/* ============================================================
   POSICIONAMIENTO
   ============================================================ */
.soc-pos-top-center { top: 20px; left: 50%; transform: translateX(-50%); }
.soc-pos-top-left { top: 20px; left: 20px; transform: none; align-items: flex-start; }
.soc-pos-top-right { top: 20px; right: 20px; left: auto; transform: none; align-items: flex-end; }
.soc-pos-bottom-center { top: auto; bottom: 20px; left: 50%; transform: translateX(-50%); }
.soc-pos-bottom-left { top: auto; bottom: 20px; left: 20px; transform: none; align-items: flex-start; }
.soc-pos-bottom-right { top: auto; bottom: 20px; right: 20px; left: auto; transform: none; align-items: flex-end; }

/* ============================================================
   TEMA OSCURO
   ============================================================ */
.soc-theme-dark.soc-toast {
    --soc-toast-fill: rgba(26, 26, 26, 0.97);
    --soc-toast-icon-bg: rgba(255,255,255,0.07);
    --soc-toast-icon-color: #9ca3af;
    --soc-toast-title-color: #f9fafb;
    --soc-toast-action-bg: rgba(255,255,255,0.05);
    --soc-toast-action-color: #9ca3af;
    --soc-toast-action-hover-bg: rgba(255,255,255,0.1);
    --soc-toast-progress-bg: rgba(255,255,255,0.05);
    --soc-toast-progress-bar: #9ca3af;
}
.soc-theme-dark .soc-toast-canvas svg {
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.25)) drop-shadow(0 1px 4px rgba(0,0,0,0.15));
}
.soc-theme-dark .soc-toast-desc { color: #e5e7eb; }
.soc-theme-dark .soc-toast-time { color: #9ca3af; }
.soc-theme-dark .soc-toast-close { color: #9ca3af; }
.soc-theme-dark .soc-toast-close:hover { color: #f9fafb; }

.soc-theme-dark.soc-toast-success {
    --soc-toast-fill: rgba(13,31,15,0.97);
    --soc-toast-icon-bg: rgba(74,222,128,0.15);
    --soc-toast-icon-color: #4ade80;
    --soc-toast-title-color: #4ade80;
    --soc-toast-action-bg: rgba(74,222,128,0.1);
    --soc-toast-action-color: #4ade80;
    --soc-toast-action-hover-bg: rgba(74,222,128,0.15);
    --soc-toast-progress-bar: #4ade80;
}
.soc-theme-dark.soc-toast-error {
    --soc-toast-fill: rgba(31,13,13,0.97);
    --soc-toast-icon-bg: rgba(248,113,113,0.15);
    --soc-toast-icon-color: #f87171;
    --soc-toast-title-color: #f87171;
    --soc-toast-action-bg: rgba(248,113,113,0.1);
    --soc-toast-action-color: #f87171;
    --soc-toast-action-hover-bg: rgba(248,113,113,0.15);
    --soc-toast-progress-bar: #f87171;
}
.soc-theme-dark.soc-toast-warning {
    --soc-toast-fill: rgba(31,24,10,0.97);
    --soc-toast-icon-bg: rgba(251,191,36,0.15);
    --soc-toast-icon-color: #fbbf24;
    --soc-toast-title-color: #fbbf24;
    --soc-toast-action-bg: rgba(251,191,36,0.1);
    --soc-toast-action-color: #fbbf24;
    --soc-toast-action-hover-bg: rgba(251,191,36,0.15);
    --soc-toast-progress-bar: #fbbf24;
}
.soc-theme-dark.soc-toast-info {
    --soc-toast-fill: rgba(13,20,32,0.97);
    --soc-toast-icon-bg: rgba(96,165,250,0.15);
    --soc-toast-icon-color: #60a5fa;
    --soc-toast-title-color: #60a5fa;
    --soc-toast-action-bg: rgba(96,165,250,0.1);
    --soc-toast-action-color: #60a5fa;
    --soc-toast-action-hover-bg: rgba(96,165,250,0.15);
    --soc-toast-progress-bar: #60a5fa;
}

/* Responsive */
@media (max-width: 480px) {
    .soc-toast-container { top: 15px; width: 100%; padding: 0 16px; }
    .soc-toast { max-width: 100%; }
}
