/* ChatBot IA - Frontend Styles */

.chatbot-ia-widget {
    position: fixed;
    bottom: 20px;
    z-index: 9999;
    font-family: var(--chatbot-font);
}

/* Posicionamento */
.chatbot-position-right {
    right: 20px;
}

.chatbot-position-left {
    left: 20px;
}

/* Botão de Toggle */
.chatbot-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--chatbot-primary);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.chatbot-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.chatbot-toggle-btn:active {
    transform: scale(0.95);
}

.chatbot-toggle-btn .chatbot-icon,
.chatbot-toggle-btn .chatbot-close-icon {
    width: 28px;
    height: 28px;
    color: #fff;
    transition: all 0.3s ease;
}

.chatbot-toggle-btn .chatbot-icon {
    opacity: 1;
    transform: rotate(0deg);
}

.chatbot-toggle-btn .chatbot-close-icon {
    position: absolute;
    opacity: 0;
    transform: rotate(90deg);
}

.chatbot-ia-widget.open .chatbot-toggle-btn .chatbot-icon {
    opacity: 0;
    transform: rotate(-90deg);
}

.chatbot-ia-widget.open .chatbot-toggle-btn .chatbot-close-icon {
    opacity: 1;
    transform: rotate(0deg);
}

.chatbot-toggle-btn img.chatbot-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

/* Tooltip / Balão de Convite */
.chatbot-tooltip {
    position: absolute;
    bottom: 75px;
    background: #fff;
    padding: 14px 40px 14px 18px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    max-width: 250px;
    min-width: 180px;
    animation: tooltipBounce 0.6s ease;
    z-index: 10;
    display: block !important;
}

.chatbot-position-right .chatbot-tooltip {
    right: 75px;
}

.chatbot-position-left .chatbot-tooltip {
    left: 75px;
}

@keyframes tooltipBounce {
    0% {
        opacity: 0;
        transform: translateY(10px) scale(0.9);
    }
    50% {
        transform: translateY(-5px) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.chatbot-tooltip::after {
    content: '';
    position: absolute;
    bottom: -10px;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid #fff;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.1));
}

.chatbot-position-right .chatbot-tooltip::after {
    right: 15px;
}

.chatbot-position-left .chatbot-tooltip::after {
    left: 15px;
}

.chatbot-tooltip-content {
    color: #333;
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
    font-weight: 500;
}

.chatbot-tooltip-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    font-size: 18px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
    font-weight: bold;
}

.chatbot-tooltip-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #333;
    transform: scale(1.1);
}

.chatbot-ia-widget.open .chatbot-tooltip,
.chatbot-tooltip.hidden {
    display: none !important;
}

/* Container do Chat */
.chatbot-container {
    position: absolute;
    bottom: 80px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--chatbot-secondary);
    border-radius: var(--chatbot-radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s ease;
}

.chatbot-position-right .chatbot-container {
    right: 0;
}

.chatbot-position-left .chatbot-container {
    left: 0;
}

.chatbot-ia-widget.open .chatbot-container {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Cabeçalho */
.chatbot-header {
    background: var(--chatbot-primary);
    color: #fff;
    padding: 20px;
    border-radius: var(--chatbot-radius) var(--chatbot-radius) 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

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

.chatbot-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.chatbot-avatar svg {
    width: 24px;
    height: 24px;
    color: #fff;
}

.chatbot-avatar img.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chatbot-header-text h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
}

.chatbot-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.9;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #4caf50;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

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

.chatbot-minimize-btn {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.chatbot-minimize-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chatbot-minimize-btn svg {
    width: 20px;
    height: 20px;
    color: #fff;
}

/* Área de Mensagens */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

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

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Mensagens */
.chatbot-message {
    display: flex;
    gap: 10px;
    animation: messageSlideIn 0.3s ease;
}

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

.chatbot-message.user-message {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    background: var(--chatbot-bot-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.message-avatar svg {
    width: 18px;
    height: 18px;
    color: var(--chatbot-text);
}

.message-avatar img.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-message .message-avatar {
    background: var(--chatbot-user-bg);
}

.user-message .message-avatar svg {
    color: #fff;
}

.message-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-message .message-content {
    align-items: flex-end;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: var(--chatbot-radius);
    font-size: var(--chatbot-font-size);
    line-height: 1.5;
    word-wrap: break-word;
    max-width: 100%;
}

.bot-message .message-bubble {
    background: var(--chatbot-bot-bg);
    color: var(--chatbot-text);
    border-bottom-left-radius: 4px;
}

.user-message .message-bubble {
    background: var(--chatbot-user-bg);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: #999;
    padding: 0 4px;
}

/* Indicador de Digitação */
.chatbot-typing {
    padding: 0 20px 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--chatbot-bot-bg);
    border-radius: var(--chatbot-radius);
    border-bottom-left-radius: 4px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--chatbot-text);
    border-radius: 50%;
    opacity: 0.4;
    animation: typing 1.4s infinite;
}

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

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

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

.typing-text {
    font-size: 12px;
    color: #999;
}

/* Área de Input */
.chatbot-input-area {
    padding: 15px 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    background: var(--chatbot-secondary);
    border-radius: 0 0 var(--chatbot-radius) var(--chatbot-radius);
}

.chatbot-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--chatbot-radius);
    font-size: var(--chatbot-font-size);
    font-family: var(--chatbot-font);
    outline: none;
    transition: border-color 0.3s ease;
}

.chatbot-input:focus {
    border-color: var(--chatbot-primary);
}

.chatbot-send-btn {
    width: 44px;
    height: 44px;
    background: var(--chatbot-primary);
    border: none;
    border-radius: var(--chatbot-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.chatbot-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.chatbot-send-btn:active {
    transform: scale(0.95);
}

.chatbot-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chatbot-send-btn svg {
    width: 20px;
    height: 20px;
    color: #fff;
}

/* Footer */
.chatbot-footer {
    padding: 10px 20px;
    text-align: center;
    font-size: 12px;
    color: #666;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    background: var(--chatbot-secondary);
    border-radius: 0 0 var(--chatbot-radius) var(--chatbot-radius);
}

.chatbot-footer span {
    display: inline-block;
}

.chatbot-footer a {
    color: var(--chatbot-primary) !important;
    text-decoration: none !important;
    font-weight: 600 !important;
    transition: all 0.3s ease;
}

.chatbot-footer a:hover {
    opacity: 0.7;
    text-decoration: underline !important;
}

/* Mensagem de Erro */
.error-message {
    background: #f44336;
    color: #fff;
    padding: 12px 16px;
    border-radius: var(--chatbot-radius);
    font-size: var(--chatbot-font-size);
    text-align: center;
    margin: 10px 20px;
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-10px);
    }
    75% {
        transform: translateX(10px);
    }
}

/* Responsivo Mobile */
@media (max-width: 480px) {
    .chatbot-ia-widget {
        bottom: 10px;
        right: 10px;
    }
    
    .chatbot-toggle-btn {
        width: 56px;
        height: 56px;
    }
    
    .chatbot-container {
        width: calc(100vw - 20px);
        height: calc(100vh - 80px);
        bottom: 70px;
        right: -10px;
    }
    
    .chatbot-header {
        padding: 15px;
    }
    
    .chatbot-messages {
        padding: 15px;
    }
    
    .chatbot-input-area {
        padding: 12px 15px;
    }
}

/* Acessibilidade */
@media (prefers-reduced-motion: reduce) {
    .chatbot-toggle-btn,
    .chatbot-container,
    .chatbot-message,
    .chatbot-send-btn {
        animation: none;
        transition: none;
    }
    
    .status-dot {
        animation: none;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .chatbot-container {
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    }
}
