/* Estilos do Frontend do Chat IA WP */

/* Variáveis (serão definidas inline pela classe PHP) */
:root {
    --ciawp-primary-color: #667eea;
    --ciawp-secondary-color: #764ba2;
}

/* Animações (estáticas) */
@keyframes ciawpFadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes ciawpSlideUp { from { opacity: 0; transform: translateY(100px) scale(0.3); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes ciawpPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes ciawpRipple { to { transform: scale(4); opacity: 0; } }
@keyframes ciawpTypingDots { 0%, 80%, 100% { transform: scale(1); opacity: 0.5; } 40% { transform: scale(1.3); opacity: 1; } }
@keyframes ciawpFadeInMessage { 0% { opacity: 0; transform: translateY(20px); } 100% { opacity: 1; transform: translateY(0); } }

/* Classes de Animação */
.ciawp-message-animation { animation: ciawpFadeIn 0.4s ease-out; }
.ciawp-fade-in-message { animation: ciawpFadeInMessage 0.5s ease-out forwards; }
.ciawp-pulse { animation: ciawpPulse 2s infinite; }

/* Indicador de Digitação (usa cores dinâmicas) */
.ciawp-typing-dots { display: inline-flex; align-items: center; gap: 4px; }
.ciawp-typing-dots span {
    width: 8px; height: 8px; background: var(--ciawp-primary-color); border-radius: 50%;
    display: inline-block; animation: ciawpTypingDots 1.4s infinite ease-in-out both;
}
.ciawp-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.ciawp-typing-dots span:nth-child(2) { animation-delay: -0.16s; }
.ciawp-typing-indicator-wrapper { margin-bottom: 8px; }
#ciawpChatMessages > div:last-child { margin-bottom: 4px; }

/* Scrollbar (usa cores dinâmicas) */
.ciawp-custom-scrollbar { scroll-behavior: smooth; scrollbar-width: thin; scrollbar-color: var(--ciawp-primary-color) #f1f1f1; }
.ciawp-custom-scrollbar::-webkit-scrollbar { width: 8px; }
.ciawp-custom-scrollbar::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 10px; }
.ciawp-custom-scrollbar::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--ciawp-primary-color) 0%, var(--ciawp-secondary-color) 100%);
    border-radius: 10px; transition: all 0.3s ease;
}
.ciawp-custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--ciawp-secondary-color) 0%, var(--ciawp-primary-color) 100%);
    box-shadow: 0 0 5px rgba(102, 126, 234, 0.5);
}

/* Botão Flutuante (usa cores dinâmicas) */
.ciawp-chat-button {
    position: fixed; bottom: 30px;
    width: 65px; height: 65px; border-radius: 50%;
    background: linear-gradient(135deg, var(--ciawp-primary-color) 0%, var(--ciawp-secondary-color) 100%);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4); cursor: pointer;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55); z-index: 9998;
    display: flex; align-items: center; justify-content: center;
}
.ciawp-chat-button svg { width: 32px; height: 32px; }
.ciawp-chat-button:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 15px 35px rgba(102, 126, 234, 0.5);
}
.ciawp-chat-button.active {
    transform: scale(0.9);
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}
.ciawp-notification-badge {
    position: absolute; top: -5px; right: -5px; width: 20px; height: 20px;
    background: #f5576c; border-radius: 50%; display: flex; align-items: center;
    justify-content: center; color: white; font-size: 11px; font-weight: bold;
    animation: ciawpPulse 2s infinite;
}

/* Janela do Chat (base) */
.ciawp-chat-window {
    position: fixed; bottom: 110px;
    width: 400px; height: 600px; max-height: 80vh; background: white;
    border-radius: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    display: none; flex-direction: column; z-index: 9999; overflow: hidden;
    transition: all 0.3s ease;
}
.ciawp-chat-window.show { display: flex; animation: ciawpSlideUp 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55); }
#ciawpChatContent { height: 100%; min-height: 0; display: flex; flex-direction: column; }
#ciawpChatMessages { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 16px; }
.ciawp-glass-header {
    background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05); padding: 16px;
}

/* Mensagens (usam cores dinâmicas) */
.ciawp-message-user {
    background: linear-gradient(135deg, var(--ciawp-primary-color) 0%, var(--ciawp-secondary-color) 100%);
    color: white; padding: 12px 16px; border-radius: 18px;
    border-top-right-radius: 4px; box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.ciawp-message-bot {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    color: #1f2937; padding: 12px 16px; border-radius: 18px;
    border-top-left-radius: 4px; box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Área de Input (usa cores dinâmicas) */
.ciawp-send-button {
    background: linear-gradient(135deg, var(--ciawp-primary-color) 0%, var(--ciawp-secondary-color) 100%);
    transition: all 0.3s ease; border-radius: 50%; border: none; color: white;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    width: 42px; height: 42px; min-width: 42px; min-height: 42px;
    max-width: 42px; max-height: 42px; aspect-ratio: 1; padding: 0;
    flex-shrink: 0; box-sizing: content-box;
}
.ciawp-send-button:hover:not(:disabled) {
    transform: scale(1.05); box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}
.ciawp-send-button:active:not(:disabled) { transform: scale(0.95); }
.ciawp-send-button:disabled { opacity: 0.5; cursor: not-allowed; }
.ciawp-send-button svg { width: 20px; height: 20px; flex-shrink: 0; }
.ciawp-scroll-down-button {
    position: absolute; bottom: 10px; right: 20px; width: 36px; height: 36px;
    background: white; border-radius: 50%; box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    display: flex; align-items: center; justify-content: center; cursor: pointer;
    transition: all 0.3s ease; z-index: 10;
}
.ciawp-scroll-down-button:hover { transform: translateY(2px); box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.ciawp-scroll-down-button.hidden { opacity: 0; visibility: hidden; transform: translateY(10px); }
.ciawp-ripple {
    position: absolute; border-radius: 50%; width: 5px; height: 5px;
    background: rgba(255, 255, 255, 0.6); animation: ciawpRipple 0.6s linear;
}
.ciawp-message-input {
    flex: 1; padding: 10px 16px; border: 1px solid #d1d5db;
    border-radius: 24px; font-size: 14px; outline: none;
    transition: border-color 0.2s; line-height: 1.4; height: 42px;
    box-sizing: border-box;
}
.ciawp-message-input:focus {
    border-color: var(--ciawp-primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Chat Inline (base) */
.ciawp-chat-inline {
    width: 100%; height: 600px; background: white; border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1); display: flex;
    flex-direction: column; overflow: hidden;
}

/* Overlay Mobile */
.ciawp-mobile-overlay {
    display: block; visibility: hidden; position: fixed; top: 0; left: 0;
    right: 0; bottom: 0; background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
    z-index: 9998; opacity: 0; transition: opacity 0.3s ease, visibility 0.3s ease;
}
.ciawp-mobile-overlay.show { visibility: visible; opacity: 1; }

/* Media Queries (Mobile) */
@media (max-width: 640px) {
    .ciawp-message-input { font-size: 16px; }
    .ciawp-chat-window {
        position: fixed; top: 50%; left: 50%;
        transform: translate(-50%, -50%) scale(0.9);
        width: calc(100% - 20px); max-width: 400px;
        height: calc(100vh - 30px); height: calc(100dvh - 30px);
        max-height: calc(100vh - 30px); max-height: calc(100dvh - 30px);
        border-radius: 20px; bottom: auto; right: auto;
        opacity: 0; transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    }
    .ciawp-chat-window.show { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    @keyframes ciawpMobileSlideUp {
        from { opacity: 0; transform: translate(-50%, -50%) scale(0.8) translateY(50px); }
        to { opacity: 1; transform: translate(-50%, -50%) scale(1) translateY(0); }
    }
    .ciawp-chat-window.show { animation: ciawpMobileSlideUp 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55); }
    .ciawp-chat-button {
        bottom: 20px;
        width: 56px; height: 56px; box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    }
    #ciawpChatContent { height: 100%; max-height: 100%; }
    .ciawp-glass-header {
        border-top-left-radius: 20px; border-top-right-radius: 20px;
        padding: 12px 16px;
        background: linear-gradient(135deg, var(--ciawp-primary-color) 0%, var(--ciawp-secondary-color) 100%);
    }
    .ciawp-glass-header .ciawp-header-title { color: white !important; }
    .ciawp-glass-header .ciawp-header-subtitle { color: rgba(255, 255, 255, 0.9) !important; }
    .ciawp-glass-header .ciawp-header-subtitle span { background: white !important; }
    .ciawp-glass-header .ciawp-close-chat { background: rgba(128, 128, 128, 0.2); }
    .ciawp-glass-header .ciawp-close-chat:hover { background: rgba(255, 255, 255, 0.3); }
    .ciawp-glass-header .ciawp-close-icon { color: white !important; }
    #ciawpChatMessages { padding: 12px; -webkit-overflow-scrolling: touch; }
    .ciawp-message-user, .ciawp-message-bot { font-size: 14px; padding: 10px 14px; }
    .ciawp-chat-window::before {
        content: ''; position: absolute; top: -35px; left: 50%;
        transform: translateX(-50%); width: 40px; height: 4px;
        background: rgba(255, 255, 255, 0.8); border-radius: 2px;
    }
    .ciawp-chat-window::after {
        content: ''; position: absolute; top: 8px; left: 50%;
        transform: translateX(-50%); width: 36px; height: 4px;
        background: rgba(255, 255, 255, 0.3); border-radius: 2px;
        z-index: 10001; pointer-events: none;
    }
}
/* Media Query (Tablet) */
@media (min-width: 641px) and (max-width: 1024px) {
    .ciawp-chat-window {
        width: 380px; height: 550px;
        bottom: 90px;
    }
}
@media (min-width: 1025px) { .ciawp-mobile-overlay { display: none !important; } }


/* NOVAS CLASSES DE POSIÇÃO */
.ciawp-chat-button.position-right,
.ciawp-chat-window.position-right {
    right: 30px;
}
.ciawp-chat-button.position-left,
.ciawp-chat-window.position-left {
    left: 30px;
}
/* Ajuste de posição mobile */
@media (max-width: 640px) {
    .ciawp-chat-button.position-right { right: 20px; }
    .ciawp-chat-button.position-left { left: 20px; }
    .ciawp-chat-window.position-right,
    .ciawp-chat-window.position-left {
        left: 50%; /* Centralizado no mobile */
        right: auto;
    }
}
/* Ajuste de posição tablet */
@media (min-width: 641px) and (max-width: 1024px) {
    .ciawp-chat-window.position-right { right: 20px; }
    .ciawp-chat-window.position-left { left: 20px; }
}