/**
 * Estilos do Chatbot
 * Simple AI Engine
 */

/* ========================================
   VARIÁVEIS CSS
   ======================================== */
.sai-chatbot-container {
    --sai-primary-color: #0073aa;
    --sai-secondary-color: #005177;
    --sai-bg-color: #ffffff;
    --sai-text-color: #333333;
    --sai-border-color: #e0e0e0;
    --sai-user-bg: #0073aa;
    --sai-user-text: #ffffff;
    --sai-bot-bg: #f5f5f5;
    --sai-bot-text: #333333;
    --sai-width: 400px;
    --sai-height: 600px;
}

/* ========================================
   CONTAINER BASE
   ======================================== */
.sai-chatbot-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    box-sizing: border-box;
}

.sai-chatbot-container *,
.sai-chatbot-container *::before,
.sai-chatbot-container *::after {
    box-sizing: border-box;
}

/* ========================================
   POSICIONAMENTO
   ======================================== */
.sai-chatbot-position-inline {
    position: relative;
    width: var(--sai-width);
    max-width: 100%;
    margin: 20px auto;
}

.sai-chatbot-position-bottom-right,
.sai-chatbot-position-bottom-left,
.sai-chatbot-position-top-right,
.sai-chatbot-position-top-left {
    position: fixed;
    z-index: 9999;
}

.sai-chatbot-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

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

.sai-chatbot-position-top-right {
    top: 20px;
    right: 20px;
}

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

/* ========================================
   BOTÃO DE TOGGLE
   ======================================== */
.sai-chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--sai-primary-color);
    color: white;
    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;
}

.sai-chatbot-toggle:hover {
    background: var(--sai-secondary-color);
    transform: scale(1.1);
}

.sai-chatbot-toggle svg {
    width: 28px;
    height: 28px;
}

/* ========================================
   JANELA DO CHATBOT
   ======================================== */
.sai-chatbot-window {
    width: var(--sai-width);
    max-width: calc(100vw - 40px);
    height: var(--sai-height);
    max-height: calc(100vh - 100px);
    background: var(--sai-bg-color);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sai-chatbot-position-bottom-right .sai-chatbot-window,
.sai-chatbot-position-bottom-left .sai-chatbot-window {
    position: absolute;
    bottom: 80px;
}

.sai-chatbot-position-top-right .sai-chatbot-window,
.sai-chatbot-position-top-left .sai-chatbot-window {
    position: absolute;
    top: 80px;
}

.sai-chatbot-position-bottom-right .sai-chatbot-window,
.sai-chatbot-position-top-right .sai-chatbot-window {
    right: 0;
}

.sai-chatbot-position-bottom-left .sai-chatbot-window,
.sai-chatbot-position-top-left .sai-chatbot-window {
    left: 0;
}

/* ========================================
   HEADER
   ======================================== */
.sai-chatbot-header {
    background: var(--sai-primary-color);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.sai-chatbot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.sai-chatbot-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    flex: 1;
}

.sai-chatbot-close {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.sai-chatbot-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ========================================
   ÁREA DE MENSAGENS
   ======================================== */
.sai-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

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

.sai-chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--sai-border-color);
    border-radius: 3px;
}

.sai-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #ccc;
}

/* ========================================
   MENSAGENS
   ======================================== */
.sai-message {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    animation: slideIn 0.3s ease;
}

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

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

.sai-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.sai-message-content {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 12px;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.sai-message-user .sai-message-content {
    background: var(--sai-user-bg);
    color: var(--sai-user-text);
    border-bottom-right-radius: 4px;
}

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

.sai-message-error {
    background: #fee !important;
    color: #c33 !important;
    border: 1px solid #fcc;
}

/* Markdown em mensagens */
.sai-message-content strong {
    font-weight: 600;
}

.sai-message-content em {
    font-style: italic;
}

.sai-message-content code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.sai-message-content a {
    color: inherit;
    text-decoration: underline;
}

/* ========================================
   BOTÕES DE SUGESTÃO
   ======================================== */
.sai-chatbot-suggestions {
    padding: 0 20px 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.sai-suggestion-button {
    background: var(--sai-bg-color);
    border: 1px solid var(--sai-border-color);
    color: var(--sai-text-color);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.sai-suggestion-button:hover {
    background: var(--sai-primary-color);
    color: white;
    border-color: var(--sai-primary-color);
}

/* ========================================
   ÁREA DE INPUT
   ======================================== */
.sai-chatbot-input-area {
    padding: 16px 20px;
    border-top: 1px solid var(--sai-border-color);
    display: flex;
    gap: 10px;
    align-items: flex-end;
    background: var(--sai-bg-color);
    flex-shrink: 0;
}

.sai-chatbot-input {
    flex: 1;
    border: 1px solid var(--sai-border-color);
    border-radius: 20px;
    padding: 10px 16px;
    font-family: inherit;
    font-size: 14px;
    resize: none;
    max-height: 150px;
    overflow-y: auto;
    line-height: 1.4;
}

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

.sai-chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--sai-primary-color);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.sai-chatbot-send:hover:not(:disabled) {
    background: var(--sai-secondary-color);
    transform: scale(1.05);
}

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

/* ========================================
   LOADING
   ======================================== */
.sai-chatbot-loading {
    display: flex;
    gap: 6px;
    padding: 10px 20px;
    align-items: center;
}

.sai-chatbot-loading span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--sai-primary-color);
    animation: bounce 1.4s infinite ease-in-out both;
}

.sai-chatbot-loading span:nth-child(1) {
    animation-delay: -0.32s;
}

.sai-chatbot-loading span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ========================================
   TEMA: MODERN
   ======================================== */
.sai-chatbot-theme-modern {
    --sai-primary-color: #667eea;
    --sai-secondary-color: #764ba2;
    --sai-user-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --sai-bot-bg: #f8f9fa;
}

.sai-chatbot-theme-modern .sai-chatbot-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.sai-chatbot-theme-modern .sai-chatbot-toggle {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.sai-chatbot-theme-modern .sai-chatbot-send {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.sai-chatbot-theme-modern .sai-message-user .sai-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* ========================================
   TEMA: MINIMAL
   ======================================== */
.sai-chatbot-theme-minimal {
    --sai-primary-color: #000000;
    --sai-secondary-color: #333333;
    --sai-border-color: #e0e0e0;
    --sai-user-bg: #000000;
    --sai-bot-bg: #f9f9f9;
}

.sai-chatbot-theme-minimal .sai-chatbot-window {
    border: 1px solid var(--sai-border-color);
    border-radius: 0;
}

.sai-chatbot-theme-minimal .sai-chatbot-header {
    border-bottom: 1px solid var(--sai-border-color);
}

.sai-chatbot-theme-minimal .sai-chatbot-input {
    border-radius: 0;
}

.sai-chatbot-theme-minimal .sai-chatbot-send {
    border-radius: 0;
}

.sai-chatbot-theme-minimal .sai-message-content {
    border-radius: 0;
}

/* ========================================
   TEMA: DARK
   ======================================== */
.sai-chatbot-theme-dark {
    --sai-primary-color: #1e88e5;
    --sai-secondary-color: #1565c0;
    --sai-bg-color: #1e1e1e;
    --sai-text-color: #e0e0e0;
    --sai-border-color: #333333;
    --sai-user-bg: #1e88e5;
    --sai-user-text: #ffffff;
    --sai-bot-bg: #2d2d2d;
    --sai-bot-text: #e0e0e0;
}

.sai-chatbot-theme-dark .sai-chatbot-input {
    background: #2d2d2d;
    color: #e0e0e0;
}

.sai-chatbot-theme-dark .sai-suggestion-button {
    background: #2d2d2d;
    border-color: #444;
    color: #e0e0e0;
}

.sai-chatbot-theme-dark .sai-suggestion-button:hover {
    background: var(--sai-primary-color);
    color: white;
}

/* ========================================
   RESPONSIVO
   ======================================== */
@media (max-width: 768px) {
    .sai-chatbot-window {
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
    }
    
    .sai-chatbot-position-bottom-right .sai-chatbot-window,
    .sai-chatbot-position-bottom-left .sai-chatbot-window,
    .sai-chatbot-position-top-right .sai-chatbot-window,
    .sai-chatbot-position-top-left .sai-chatbot-window {
        position: fixed;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
    }
    
    .sai-message-content {
        max-width: 85%;
    }
}
