/* AI Assistant Bubble Component Styles */

/* Drawer del asistente */
.ai-drawer {
    position: fixed !important;
    right: 0;
    top: 64px !important;
    height: calc(100vh - 64px) !important;
    z-index: 1300;
}

.ai-drawer .mud-drawer-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: linear-gradient(180deg, var(--mud-palette-surface) 0%, var(--mud-palette-background) 100%);
}

.ai-header {
    border-bottom: 1px solid var(--mud-palette-divider);
    flex-shrink: 0;
    min-height: auto !important;
    padding: 8px 12px !important;
    background: var(--mud-palette-surface);
}

.ai-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* Área de mensajes */
.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Mensaje de bienvenida */
.ai-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 24px;
    text-align: center;
}

.ai-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    max-width: 320px;
}

.ai-suggestion-chip {
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-suggestion-chip:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Mensajes */
.ai-message {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.ai-message.user {
    flex-direction: row-reverse;
}

.ai-message.assistant {
    flex-direction: row;
}

.ai-avatar {
    flex-shrink: 0;
}

.ai-message-content {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

.ai-message.user .ai-message-content {
    align-items: flex-end;
}

.ai-message.assistant .ai-message-content {
    align-items: flex-start;
}

/* Burbujas de mensaje */
.ai-bubble {
    padding: 8px 12px;
    border-radius: 12px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    font-size: 0.9375rem; /* 15px */
}

.ai-bubble.user {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-bubble.user p {
    font-size: 0.9375rem; /* 15px */
    margin: 0;
}

.ai-bubble.assistant {
    background: var(--mud-palette-surface);
    border-bottom-left-radius: 4px;
}

.ai-bubble.typing {
    padding: 8px 14px;
}

/* Indicador de escritura */
.typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--mud-palette-text-secondary);
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
    0%, 80%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    40% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* Timestamp */
.ai-timestamp {
    font-size: 0.7rem;
    color: var(--mud-palette-text-secondary);
    margin-top: 4px;
    padding: 0 4px;
}

/* Input */
.ai-input-container {
    padding: 12px;
    border-top: 1px solid var(--mud-palette-divider);
    background: var(--mud-palette-surface);
}

.ai-input .mud-input-control {
    background: var(--mud-palette-background);
}

/* Markdown content styling */
.ai-bubble.assistant .mud-markdown-body {
    font-size: 0.9375rem; /* 15px */
    line-height: 1.5;
}

.ai-bubble.assistant .mud-markdown-body p {
    margin: 0.4em 0;
    font-size: 0.9375rem; /* 15px */
}

.ai-bubble.assistant .mud-markdown-body h1,
.ai-bubble.assistant .mud-markdown-body h2,
.ai-bubble.assistant .mud-markdown-body h3 {
    font-size: 1.05rem; /* 17px */
    margin-top: 0.5em;
    margin-bottom: 0.3em;
}

.ai-bubble.assistant .mud-markdown-body ul,
.ai-bubble.assistant .mud-markdown-body ol {
    margin: 0.4em 0;
    padding-left: 1.2em;
}

.ai-bubble.assistant .mud-markdown-body li {
    font-size: 0.9375rem; /* 15px */
    margin: 0.2em 0;
}

.ai-bubble.assistant .mud-markdown-body code {
    font-size: 0.875rem; /* 14px */
}

.ai-bubble.assistant .mud-markdown-body pre {
    font-size: 0.875rem; /* 14px */
    padding: 0.4em;
}

.ai-bubble.assistant .mud-markdown-body table {
    font-size: 0.875rem; /* 14px */
}

/* Texto del usuario */
.ai-bubble.user .mud-typography {
    font-size: 0.9375rem !important; /* 15px */
}


.ai-bubble.assistant .mud-markdown-body p {
    margin-bottom: 0.5rem;
}

.ai-bubble.assistant .mud-markdown-body p:last-child {
    margin-bottom: 0;
}

.ai-bubble.assistant .mud-markdown-body ul,
.ai-bubble.assistant .mud-markdown-body ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.ai-bubble.assistant .mud-markdown-body li {
    margin-bottom: 0.25rem;
}

.ai-bubble.assistant .mud-markdown-body code {
    background: var(--mud-palette-background-gray);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.ai-bubble.assistant .mud-markdown-body pre {
    background: var(--mud-palette-background-gray);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0.5rem 0;
}

.ai-bubble.assistant .mud-markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0;
    font-size: 0.875rem;
}

.ai-bubble.assistant .mud-markdown-body th,
.ai-bubble.assistant .mud-markdown-body td {
    border: 1px solid var(--mud-palette-divider);
    padding: 6px 10px;
    text-align: left;
}

.ai-bubble.assistant .mud-markdown-body th {
    background: var(--mud-palette-background-gray);
    font-weight: 600;
}

/* Scrollbar styling */
.ai-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-messages::-webkit-scrollbar-thumb {
    background: var(--mud-palette-divider);
    border-radius: 3px;
}

.ai-messages::-webkit-scrollbar-thumb:hover {
    background: var(--mud-palette-text-secondary);
}

/* Responsive */
@media (max-width: 600px) {
    .ai-fab-container {
        bottom: 16px;
        right: 80px;
    }
    
    .ai-drawer {
        width: 100% !important;
    }
    
    .ai-message-content {
        max-width: 90%;
    }
}
