/* =========================================
   WP AI GLASS CHAT - PREMIUM STYLE (SOFT USER)
   ========================================= */

:root {
    /* Color principal (se sobrescribe por JS si se configura en admin) */
    --wgcg-main-color: #007aff;
    --wgcg-bg-glass: rgba(255, 255, 255, 0.50);
    --wgcg-border-glass: rgba(255, 255, 255, 0.7);
    --wgcg-shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(255,255,255,0.25);
    --wgcg-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Reseteo y caja base */
#wgcg-container, #wgcg-container * {
    box-sizing: border-box;
    outline: none;
}

/* ---------------------------------------------------------
   1. BOTÓN FLOTANTE (LAUNCHER)
--------------------------------------------------------- */
#wgcg-launcher {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    /* Gradiente sutil para darle volumen */
    background: linear-gradient(135deg, #ffffff 0%, #f3f4f6 100%);
    color: var(--wgcg-main-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 999999;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18), 0 2px 10px rgba(0,0,0,0.06);
    border: 1px solid rgba(255, 255, 255, 0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease, background 0.2s ease;
}

/* Efecto Hover */
#wgcg-launcher:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 14px 38px rgba(0, 0, 0, 0.24);
    background: linear-gradient(135deg, #ffffff 0%, #e5e7eb 100%);
}

/* Icono SVG interior */
#wgcg-launcher svg {
    width: 28px;
    height: 28px;
    stroke-width: 2px;
}

/* Animación sutil de "respiración" para llamar la atención */
@keyframes wgcg-pulse {
    0%    { box-shadow: 0 0 0 0 rgba(0, 122, 255, 0.45); }
    70%   { box-shadow: 0 0 0 12px rgba(0, 122, 255, 0); }
    100%  { box-shadow: 0 0 0 0 rgba(0, 122, 255, 0); }
}
#wgcg-launcher {
    animation: wgcg-pulse 3s infinite;
}

/* Posición Izquierda */
body.wgcg-left #wgcg-launcher { left: 24px; right: auto; }

/* ---------------------------------------------------------
   2. CONTENEDOR PRINCIPAL (VENTANA)
--------------------------------------------------------- */
#wgcg-container {
    position: fixed;
    right: 24px;
    bottom: 90px;
    width: 380px;
    max-width: calc(100% - 48px);
    height: 600px;
    max-height: calc(100vh - 120px);
    display: none; /* JS lo cambia a flex */
    flex-direction: column;
    z-index: 999999;

    /* EFECTO CRISTAL (GLASSMORPHISM) */
    background: var(--wgcg-bg-glass);
    backdrop-filter: blur(18px) saturate(170%);
    -webkit-backdrop-filter: blur(18px) saturate(170%);

    border-radius: 24px;
    border: 1px solid var(--wgcg-border-glass);
    box-shadow: var(--wgcg-shadow-lg);
    font-family: var(--wgcg-font-family);
    overflow: hidden;

    /* Animación de entrada */
    opacity: 0;
    transform: translateY(20px) scale(0.95);
}

/* Clase activa añadida por JS */
#wgcg-container.wgcg-open {
    display: flex;
    animation: wgcg-slide-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes wgcg-slide-in {
    to { opacity: 1; transform: translateY(0) scale(1); }
}

body.wgcg-left #wgcg-container { left: 24px; right: auto; }

/* ---------------------------------------------------------
   3. CABECERA (HEADER)
--------------------------------------------------------- */
#wgcg-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    background: rgba(255, 255, 255, 0.65); /* un poco más sólido para legibilidad */
    backdrop-filter: blur(12px);
}

#wgcg-header .wgcg-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.02em;
}

/* Punto de estado */
#wgcg-header .wgcg-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #34c759; /* Verde online */
    box-shadow: 0 0 0 2px rgba(52, 199, 89, 0.25);
}

/* Botones de acción */
#wgcg-header button {
    border: none;
    background: transparent;
    cursor: pointer;
    color: #9ca3af;
    padding: 6px;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
#wgcg-header button:hover {
    background: rgba(0,0,0,0.05);
    color: #111827;
}

/* ---------------------------------------------------------
   4. ÁREA DE MENSAJES
--------------------------------------------------------- */
#wgcg-messages {
    flex: 1;
    padding: 18px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

/* Scrollbar */
#wgcg-messages::-webkit-scrollbar { width: 5px; }
#wgcg-messages::-webkit-scrollbar-track { background: transparent; }
#wgcg-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.18); border-radius: 4px; }

/* Estilos de Burbujas */
.wgcg-msg {
    padding: 11px 16px;
    border-radius: 18px;
    max-width: 85%;
    font-size: 15px;
    line-height: 1.6;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04); /* Sombra genérica más suave */
}

/* Mensaje IA */
.wgcg-ai {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.9);
    color: #111827;
    border-bottom-left-radius: 6px;
    border: 1px solid rgba(229, 231, 235, 0.8);
}
.wgcg-ai p { margin: 0 0 8px; }
.wgcg-ai p:last-child { margin: 0; }
.wgcg-ai ul, .wgcg-ai ol {
    margin: 6px 0 6px 20px;
    padding: 0;
}
.wgcg-ai strong {
    font-weight: 600;
    color: #000;
}

/* Enlaces en respuestas IA — clicables y visibles */
.wgcg-ai a {
    color: var(--wgcg-main-color);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid rgba(79, 70, 229, 0.3);
    transition: all 0.2s ease;
    word-break: break-word;
}
.wgcg-ai a:hover {
    border-bottom-color: var(--wgcg-main-color);
    filter: brightness(1.15);
}
/* Icono sutil de enlace externo */
.wgcg-ai a[target="_blank"]::after {
    content: ' ↗';
    font-size: 0.75em;
    opacity: 0.6;
}

/* Código inline en respuestas */
.wgcg-ai code {
    background: rgba(0, 0, 0, 0.06);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: 'SF Mono', 'Fira Code', monospace;
}
.wgcg-ai pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 10px 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}
.wgcg-ai pre code {
    background: none;
    padding: 0;
}

/* Mensaje Usuario - MÁS SUAVE Y PLANO */
.wgcg-user {
    align-self: flex-end;
    /* Usamos solo el color principal, sin gradiente oscuro */
    background: var(--wgcg-main-color);
    color: #ffffff;
    border-bottom-right-radius: 6px;
    /* Sombra reducida para quitar intensidad */
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

/* ---------------------------------------------------------
   5. ANIMACIÓN "ESCRIBIENDO..." (Loading)
--------------------------------------------------------- */
.wgcg-loading {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    width: fit-content;
    background: rgba(255,255,255,0.75);
    border-radius: 16px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.05);
}

.wgcg-loading span {
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: #6b7280;
    border-radius: 50%;
    animation: wgcg-bounce 1.4s infinite ease-in-out both;
    font-size: 0;
}

.wgcg-loading span:nth-child(1) { animation-delay: -0.32s; }
.wgcg-loading span:nth-child(2) { animation-delay: -0.16s; }

@keyframes wgcg-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* ---------------------------------------------------------
   6. FORMULARIO (INPUT AREA)
--------------------------------------------------------- */
#wgcg-form {
    padding: 14px 16px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.04);
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
}

#wgcg-input {
    flex: 1;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: rgba(255, 255, 255, 0.96);
    border-radius: 24px;
    padding: 11px 16px;
    font-size: 15px;
    color: #111827;
    transition: all 0.2s ease;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.03);
}

#wgcg-input:focus {
    background: #ffffff;
    border-color: var(--wgcg-main-color);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.16);
}

#wgcg-input::placeholder {
    color: #9ca3af;
}

#wgcg-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: var(--wgcg-main-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 3px 8px rgba(0,0,0,0.15); /* Sombra botón también reducida un poco */
}

#wgcg-send:hover:not(:disabled) {
    transform: scale(1.05) translateY(-1px);
    filter: brightness(1.08);
}
#wgcg-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #d1d5db;
    box-shadow: none;
}

/* ---------------------------------------------------------
   7. RESPONSIVE (MÓVILES)
--------------------------------------------------------- */
@media (max-width: 480px) {
    #wgcg-container {
        width: 100%;
        height: 100%;
        max-height: 100%;
        bottom: 0;
        right: 0;
        left: 0;
        border-radius: 0;
        border: none;
        background: #ffffff; /* En móvil fondo sólido por rendimiento y lectura */
        box-shadow: none;
    }

    #wgcg-header {
        padding-top: env(safe-area-inset-top, 20px);
    }

    #wgcg-form {
        padding-bottom: max(16px, env(safe-area-inset-bottom, 16px));
    }

    #wgcg-launcher {
        bottom: 20px;
        right: 20px;
    }
}