/* ========================================
   BRODER AI CHAT WIDGET - STYLES
   ======================================== */

/* Chat Button (Floating) */
.broder-ai-chat-button {
    position: fixed;
    bottom: 90px; /* Above WhatsApp button */
    right: 20px;
    width: 220px;
    height: 60px;
    background: linear-gradient(135deg, #00d9d9 0%, #6633ff 100%);
    border: none;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 217, 217, 0.4);
    z-index: 999;
    transition: all 0.3s ease;
    overflow: hidden;
}

.broder-ai-chat-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(0, 217, 217, 0.6);
}

.broder-ai-btn-content {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0 20px;
    z-index: 2;
}

.broder-ai-icon {
    font-size: 24px;
    color: white;
    animation: robotPulse 2s ease-in-out infinite;
}

@keyframes robotPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.broder-ai-btn-text {
    font-size: 16px;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.broder-ai-btn-pulse {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
    opacity: 0;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.05); }
}

/* Chat Window */
.broder-ai-chat-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 400px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: linear-gradient(180deg, #0a0a0a 0%, #1a1a2e 100%);
    border: 2px solid rgba(0, 217, 217, 0.3);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Chat Header */
.broder-ai-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, #00d9d9 0%, #6633ff 100%);
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.broder-ai-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.broder-ai-avatar {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.broder-ai-header-info {
    flex: 1;
}

.broder-ai-bot-name {
    font-size: 18px;
    font-weight: 700;
    color: white;
    margin: 0;
    line-height: 1.2;
}

.broder-ai-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.9);
    margin: 4px 0 0 0;
}

.broder-ai-status-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: statusBlink 2s ease-in-out infinite;
}

@keyframes statusBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.broder-ai-close-button {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.broder-ai-close-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Messages Container */
.broder-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #0a0a0a;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Custom Scrollbar */
.broder-ai-messages::-webkit-scrollbar {
    width: 6px;
}

.broder-ai-messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.broder-ai-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 217, 217, 0.5);
    border-radius: 3px;
}

.broder-ai-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 217, 217, 0.7);
}

/* Message Bubble */
.broder-ai-message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: messageSlide 0.3s ease-out;
}

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

.broder-ai-message.bot {
    align-self: flex-start;
}

.broder-ai-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.broder-ai-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.broder-ai-message.bot .broder-ai-message-avatar {
    background: linear-gradient(135deg, #00d9d9 0%, #6633ff 100%);
    color: white;
}

.broder-ai-message.user .broder-ai-message-avatar {
    background: #6633ff;
    color: white;
}

.broder-ai-message-content {
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
    font-size: 14px;
}

.broder-ai-message.bot .broder-ai-message-content {
    background: linear-gradient(135deg, rgba(0, 217, 217, 0.1) 0%, rgba(102, 51, 255, 0.1) 100%);
    border: 1px solid rgba(0, 217, 217, 0.3);
    color: #e5e5e5;
    border-radius: 16px 16px 16px 4px;
}

.broder-ai-message.user .broder-ai-message-content {
    background: #6633ff;
    color: white;
    border-radius: 16px 16px 4px 16px;
}

/* Bold text in bot messages */
.broder-ai-message.bot .broder-ai-message-content strong {
    color: #00d9d9;
    font-weight: 700;
}

/* Typing Indicator */
.broder-ai-typing-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: rgba(0, 217, 217, 0.05);
    border-top: 1px solid rgba(0, 217, 217, 0.1);
}

.broder-ai-typing-dots {
    display: flex;
    gap: 4px;
}

.broder-ai-typing-dots span {
    width: 8px;
    height: 8px;
    background: #00d9d9;
    border-radius: 50%;
    animation: typingDot 1.4s ease-in-out infinite;
}

.broder-ai-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.broder-ai-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

.broder-ai-typing-text {
    font-size: 12px;
    color: #9ca3af;
    font-style: italic;
}

/* Chat Input */
.broder-ai-chat-input-container {
    background: #1a1a2e;
    border-top: 2px solid rgba(0, 217, 217, 0.2);
    padding: 16px;
}

.broder-ai-input-wrapper {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.broder-ai-input {
    flex: 1;
    padding: 12px 16px;
    background: rgba(0, 217, 217, 0.05);
    border: 1px solid rgba(0, 217, 217, 0.3);
    border-radius: 12px;
    color: white;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

.broder-ai-input:focus {
    border-color: #00d9d9;
    background: rgba(0, 217, 217, 0.1);
    box-shadow: 0 0 0 3px rgba(0, 217, 217, 0.1);
}

.broder-ai-input::placeholder {
    color: #6b7280;
}

.broder-ai-send-button {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #00d9d9 0%, #6633ff 100%);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.broder-ai-send-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 217, 217, 0.4);
}

.broder-ai-send-button:active {
    transform: scale(0.95);
}

.broder-ai-input-footer {
    display: flex;
    justify-content: center;
}

.broder-ai-powered-by {
    font-size: 10px;
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 4px;
}

.broder-ai-powered-by i {
    color: #00d9d9;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .broder-ai-chat-button {
        width: 60px;
        height: 60px;
        border-radius: 50%;
        bottom: 90px;
        right: 16px;
    }

    .broder-ai-btn-text {
        display: none;
    }

    .broder-ai-btn-content {
        padding: 0;
    }

    .broder-ai-icon {
        font-size: 28px;
    }

    .broder-ai-chat-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height */
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
        border: none;
        position: fixed;
    }

    .broder-ai-messages {
        /* Aumentar padding inferior para garantir espaço para o input */
        padding-bottom: 20px;
    }

    .broder-ai-chat-input-container {
        /* Fixar no bottom e adicionar safe-area para iOS */
        position: sticky;
        bottom: 0;
        padding: 12px;
        padding-bottom: max(12px, env(safe-area-inset-bottom, 0));
        background: linear-gradient(180deg, rgba(10, 10, 10, 0.95) 0%, #0a0a0a 20%);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        z-index: 10;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
    }

    .broder-ai-input {
        font-size: 16px; /* Previne zoom no iOS */
        -webkit-appearance: none;
        appearance: none;
    }

    .broder-ai-send-button {
        width: 48px;
        height: 48px;
        flex-shrink: 0;
    }

    .broder-ai-message {
        max-width: 90%;
    }

    /* Ajuste quando input está focado */
    .broder-ai-input:focus {
        position: relative;
        z-index: 11;
    }

    /* Fix para quando o teclado aparece */
    body.keyboard-open .broder-ai-chat-window {
        height: calc(100vh - 300px); /* Ajusta quando teclado mobile aparece */
    }
    
    /* Melhor scroll no mobile */
    .broder-ai-messages {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
}

/* Print - hide chat */
@media print {
    .broder-ai-chat-button,
    .broder-ai-chat-window {
        display: none !important;
    }
}
