/* ========================================
   WP CUSTOM CHAT - ESTILOS AISLADOS
   ======================================== */

/* Reset para evitar conflictos con temas */
.wpcb-chat-container *,
.wpcb-chat-container *::before,
.wpcb-chat-container *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ============================
   2. BURBUJA FLOTANTE - MODERNA
   ============================ */
.wpcb-chat-bubble {
    position: fixed;
    bottom: 75px;
    right: 24px;
    width: 64px;
    height: 64px;
    background: #1a2b3f;
    border-radius: 50%;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    z-index: 999998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: wpcb-float 3s ease-in-out infinite;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.wpcb-chat-bubble:hover {
    background: #0a1929;
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
    border-color: rgba(255, 255, 255, 0.2);
}

.wpcb-chat-bubble:active {
    transform: scale(0.95);
}

.wpcb-chat-bubble svg {
    width: 32px;
    height: 32px;
    fill: #fff;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    transition: transform 0.3s ease;
 
}

.wpcb-chat-bubble:hover svg {
    transform: scale(1.1);
 
}

/* Animación de flotación sutil */
@keyframes wpcb-float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-8px);
    }
}

/* Efecto de pulso para llamar la atención */
.wpcb-chat-bubble::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgb(61 140 233 / 50%);
    animation: wpcb-pulse-ring 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes wpcb-pulse-ring {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .wpcb-chat-bubble {
        width: 60px;
        height: 60px;
        bottom: 20px;
        right: 20px;
    }
    
    .wpcb-chat-bubble svg {
        width: 28px;
        height: 28px;
    }
}

/* ============================
   3. PANEL DEL CHAT - MODO NORMAL
   ============================ */
.wpcb-chat-panel {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: min(380px, calc(100vw - 48px));    
    height: min(600px, calc(100vh - 150px));  
    max-width: 380px;
    max-height: 600px;
    background: #0a1929;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Estado: Abierto Normal */
.wpcb-chat-panel.wpcb-open-normal {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ============================
   PANEL DEL CHAT - MODO EXPANDIDO
   ============================ */
.wpcb-chat-panel.wpcb-open-expanded {
    bottom: 0;
    right: 0;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    opacity: 1;
    visibility: visible;
    transform: none;
}

/* ============================
   HEADER DEL CHAT
   ============================ */
.wpcb-chat-header {
    background: #1a2b3f;
    color: white;
    padding: 16px 20px;
    border-radius: 12px 12px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.wpcb-open-expanded .wpcb-chat-header {
    border-radius: 0;
}

.wpcb-chat-title {
    font-size: 18px;
    font-weight: 600;
    color: white;
    margin: 0;
}

.wpcb-chat-actions {
    display: flex;
    gap: 8px;
}

.wpcb-btn-header {
    background: #0a1929;
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.wpcb-btn-header:hover {
    background: #0693e3;
}

.wpcb-btn-header svg {
    width: 18px;
    height: 18px;
    fill: white;
}

/* ============================
   ÁREA DE MENSAJES
   ============================ */
.wpcb-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #0f1e2f;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wpcb-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.wpcb-chat-messages::-webkit-scrollbar-track {
    background: #1a2b3f;
}

.wpcb-chat-messages::-webkit-scrollbar-thumb {
    background: #3a4a5f;
    border-radius: 3px;
}

.wpcb-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #4a5a6f;
}

.wpcb-message {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: wpcb-slideIn 0.3s ease-out;
}

@keyframes wpcb-slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wpcb-message.wpcb-user {
    background: #0693e3;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.wpcb-message.wpcb-bot {
    background: #1a2b3f;
    color: rgba(255, 255, 255, 0.9);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.wpcb-empty-state {
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    padding: 40px 20px;
    font-size: 14px;
}


/* ============================
   INPUT Y BOTÓN DE ENVÍO
   ============================ */
.wpcb-chat-input-container {
    padding: 16px;
    background: #0a1929;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.wpcb-chat-input {
    flex: 1;
    padding: 12px 20px;
    background: #1a2b3f !important;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: all 0.2s;
    color: #ffffff !important; /* Forzamos blanco puro */
    caret-color: #ffffff; /* Color del cursor de escritura */
    font-weight: 400;
    -webkit-text-fill-color: #ffffff; /* Para Safari */
    opacity: 1; /* Evita que algunos temas apliquen opacidad */
}

/* Estilo para cuando se está escribiendo */
.wpcb-chat-input:focus {
    border-color: #0693e3;
    background: #1a2b3f !important;
    box-shadow: 0 0 0 3px rgba(6, 147, 227, 0.2);
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
}

/* Estilo específico para el texto mientras se escribe */
.wpcb-chat-input:active,
.wpcb-chat-input:focus-within,
.wpcb-chat-input:not(:placeholder-shown) {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    background: #1a2b3f !important;
}

/* Aseguramos que el texto ingresado sea blanco */
.wpcb-chat-input::-webkit-input-placeholder {
    color: rgba(255, 255, 255, 0.5);
    -webkit-text-fill-color: rgba(255, 255, 255, 0.5);
    opacity: 1;
}

.wpcb-chat-input:-moz-placeholder {
    color: rgba(255, 255, 255, 0.5);
    opacity: 1;
}

.wpcb-chat-input::-moz-placeholder {
    color: rgba(255, 255, 255, 0.5);
    opacity: 1;
}

.wpcb-chat-input:-ms-input-placeholder {
    color: rgba(255, 255, 255, 0.5);
    opacity: 1;
}

.wpcb-chat-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
    opacity: 1;
}

/* Para cualquier estado del input, el texto debe ser blanco */
.wpcb-chat-input,
.wpcb-chat-input:focus,
.wpcb-chat-input:hover,
.wpcb-chat-input:active,
.wpcb-chat-input:visited,
.wpcb-chat-input:target {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    background: #1a2b3f !important;
}

.wpcb-chat-input:not(:focus) {
    background: #1a2b3f !important;
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.1);
}

.wpcb-btn-send {
    width: 44px;
    height: 44px;
    background: #0693e3;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.wpcb-btn-send:hover {
    background: #9b51e0;
    transform: scale(1.05);
}

.wpcb-btn-send:disabled {
    background: #2a3b4f;
    cursor: not-allowed;
    transform: none;
}

.wpcb-btn-send svg {
    width: 20px;
    height: 20px;
    fill: white;
}




/* ============================
   8. RESPONSIVE - MÚLTIPLES BREAKPOINTS
   ============================ */

/* Pantallas medianas (tablets y laptops pequeñas) */
@media (max-width: 1024px) {
    .wpcb-chat-panel {
        width: min(360px, calc(100vw - 40px));
        height: min(550px, calc(100vh - 140px));
        bottom: 90px;
        right: 20px;
    }
}

/* Pantallas pequeñas (tablets portrait) */
@media (max-width: 768px) {
    .wpcb-chat-bubble {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }
    
    .wpcb-chat-panel {
        width: calc(100vw - 32px);
        height: calc(100vh - 120px);
        bottom: 80px;
        right: 16px;
        max-width: 340px;
        max-height: 500px;
    }
    
    .wpcb-chat-title {
        font-size: 16px;
    }
    
    .wpcb-message {
        max-width: 80%;
        font-size: 13px;
    }
}

/* Móviles (portrait) */
@media (max-width: 480px) {
    .wpcb-chat-bubble {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }
    
    /* En móviles, el modo normal ocupa casi toda la pantalla */
    .wpcb-chat-panel.wpcb-open-normal {
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    
    .wpcb-chat-panel.wpcb-open-normal .wpcb-chat-header {
        border-radius: 0;
    }
    
    .wpcb-message {
        max-width: 85%;
        font-size: 14px;
    }
    
    .wpcb-chat-input {
        font-size: 16px; /* Evita zoom en iOS */
    }
}

/* Pantallas muy pequeñas o con zoom */
@media (max-width: 380px) {
    .wpcb-chat-title {
        font-size: 15px;
    }
    
    .wpcb-btn-header {
        width: 28px;
        height: 28px;
    }
    
    .wpcb-btn-header svg {
        width: 16px;
        height: 16px;
    }
}

/* Ajustes para pantallas con altura limitada (ej: laptops pequeñas en horizontal) */
@media (max-height: 700px) {
    .wpcb-chat-panel {
        height: calc(100vh - 100px);
        max-height: calc(100vh - 100px);
        bottom: 70px;
    }
    
    .wpcb-chat-messages {
        padding: 15px;
    }
}

@media (max-height: 600px) {
    .wpcb-chat-panel {
        height: calc(100vh - 80px);
        max-height: calc(100vh - 80px);
        bottom: 60px;
    }
    
    .wpcb-chat-header {
        padding: 12px 16px;
    }
    
    .wpcb-chat-input-container {
        padding: 12px;
    }
}

/* ============================
   9. INDICADOR DE "PENSANDO"
   ============================ */
.wpcb-message.wpcb-thinking {
    opacity: 0.7;
    animation: wpcb-pulse 1.5s ease-in-out infinite;
}

@keyframes wpcb-pulse {
    0%, 100% {
        opacity: 0.7;
    }
    50% {
        opacity: 1;
    }
}