/**
 * LMX Chatbase - Frontend Styles
 */

/* Widget Container */
.lmx-chatbase-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Posicionamento */
.lmx-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

.lmx-position-bottom-left {
    bottom: 20px;
    left: 20px;
}

.lmx-position-top-right {
    top: 20px;
    right: 20px;
}

.lmx-position-top-left {
    top: 20px;
    left: 20px;
}

/* Chat Bubble (botão flutuante) */
.lmx-chat-bubble {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--lmx-primary-color, #6366f1);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    font-size: 24px;
}

.lmx-chat-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.lmx-bubble-icon,
.lmx-bubble-close {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Chat Container */
.lmx-chat-container {
    width: 400px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 100px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: absolute;
    bottom: 80px;
    right: 0;
}

.lmx-position-bottom-left .lmx-chat-container,
.lmx-position-top-left .lmx-chat-container {
    right: auto;
    left: 0;
}

.lmx-position-top-right .lmx-chat-container,
.lmx-position-top-left .lmx-chat-container {
    bottom: auto;
    top: 80px;
}

/* Header */
.lmx-chat-header {
    background: var(--lmx-primary-color, #6366f1);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.lmx-chat-header-content {
    flex: 1;
}

.lmx-chat-title {
    margin: 0 0 4px 0;
    font-size: 18px;
    font-weight: 600;
}

.lmx-chat-subtitle {
    margin: 0;
    font-size: 13px;
    opacity: 0.9;
}

.lmx-chat-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.lmx-chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Messages */
.lmx-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f9fafb;
}

.lmx-message {
    display: flex;
    margin-bottom: 16px;
    animation: lmx-message-in 0.3s ease;
}

@keyframes lmx-message-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.lmx-message-assistant {
    flex-direction: row;
}

.lmx-message-user {
    flex-direction: row-reverse;
}

.lmx-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--lmx-primary-color, #6366f1);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-right: 12px;
}

.lmx-message-user .lmx-message-avatar {
    margin-right: 0;
    margin-left: 12px;
    background: #64748b;
}

.lmx-message-avatar svg {
    width: 20px;
    height: 20px;
}

.lmx-message-content {
    flex: 1;
    max-width: calc(100% - 44px);
}

.lmx-message-text {
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    color: #1f2937;
    word-wrap: break-word;
}

/* Formatação Markdown dentro das mensagens */
.lmx-message-text strong {
    font-weight: 600;
    color: #111827;
}

.lmx-message-text em {
    font-style: italic;
}

.lmx-message-text h1,
.lmx-message-text h2,
.lmx-message-text h3 {
    font-weight: 600;
    margin: 12px 0 8px 0;
    line-height: 1.3;
}

.lmx-message-text h1 {
    font-size: 18px;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 6px;
}

.lmx-message-text h2 {
    font-size: 16px;
}

.lmx-message-text h3 {
    font-size: 15px;
}

.lmx-message-text ul,
.lmx-message-text ol {
    margin: 8px 0;
    padding-left: 24px;
}

.lmx-message-text li {
    margin: 4px 0;
}

.lmx-message-text ul {
    list-style-type: disc;
}

.lmx-message-text ol {
    list-style-type: decimal;
}

.lmx-message-text a {
    color: var(--lmx-primary-color, #6366f1);
    text-decoration: underline;
    transition: opacity 0.2s;
}

.lmx-message-text a:hover {
    opacity: 0.8;
}

.lmx-message-text code {
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.lmx-message-text br {
    display: block;
    margin: 4px 0;
    content: "";
}

.lmx-message-user .lmx-message-text {
    background: var(--lmx-primary-color, #6366f1);
    color: white;
}

.lmx-message-user .lmx-message-text strong {
    color: white;
}

.lmx-message-user .lmx-message-text a {
    color: white;
    text-decoration: underline;
}

.lmx-message-sources {
    margin-top: 8px;
    padding: 8px 12px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.lmx-message-sources-title {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 6px;
    text-transform: uppercase;
}

.lmx-message-source {
    display: block;
    font-size: 12px;
    color: var(--lmx-primary-color, #6366f1);
    text-decoration: none;
    padding: 4px 0;
    border-bottom: 1px solid #f3f4f6;
}

.lmx-message-source:last-child {
    border-bottom: none;
}

.lmx-message-source:hover {
    text-decoration: underline;
}

/* Typing indicator */
.lmx-typing-indicator {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border-radius: 12px;
}

.lmx-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    margin-right: 4px;
    animation: lmx-typing 1.4s infinite;
}

.lmx-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.lmx-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
    margin-right: 0;
}

@keyframes lmx-typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Input Container */
.lmx-chat-input-container {
    background: white;
    border-top: 1px solid #e5e7eb;
    padding: 16px;
}

.lmx-chat-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.lmx-chat-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    transition: border-color 0.2s;
}

.lmx-chat-input:focus {
    outline: none;
    border-color: var(--lmx-primary-color, #6366f1);
}

.lmx-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--lmx-primary-color, #6366f1);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.lmx-chat-send:hover:not(:disabled) {
    transform: scale(1.1);
}

.lmx-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.lmx-chat-send svg {
    width: 20px;
    height: 20px;
}

/* Branding */
.lmx-chat-branding {
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
    margin-top: 8px;
}

/* Scrollbar */
.lmx-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.lmx-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.lmx-chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.lmx-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Mobile */
@media (max-width: 480px) {
    .lmx-chat-container {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        position: fixed;
    }
    
    .lmx-position-bottom-left .lmx-chat-container,
    .lmx-position-top-left .lmx-chat-container,
    .lmx-position-top-right .lmx-chat-container {
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
    }
}

