/* Chat Widget Styles */

#chat-widget-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Botón flotante */
.chat-widget-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-500, #2563eb) 0%, var(--primary-600, #1d4ed8) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
    transition: all 0.3s ease;
    font-size: 24px;
}

.chat-widget-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.6);
}

/* Ventana del chat */
.chat-widget-window {
    display: flex;
    flex-direction: column;
    width: 380px;
    height: 600px;
    max-height: 80vh;
    background: var(--bg-white, #ffffff);
    border-radius: 16px;
    box-shadow: var(--shadow-xl, 0 20px 25px -5px rgba(0, 0, 0, 0.1));
    overflow: hidden;
    border: 1px solid var(--bg-gray-200, #e5e7eb);
}

[data-theme="dark"] .chat-widget-window {
    background: var(--bg-gray-50, #2d2d2d);
    border-color: var(--bg-gray-200, #4a4a4a);
}

/* Header del chat */
.chat-widget-header {
    background: linear-gradient(135deg, var(--primary-500, #2563eb) 0%, var(--primary-600, #1d4ed8) 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-widget-header-content {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 16px;
}

.chat-widget-header-content i {
    font-size: 20px;
}

.chat-widget-close {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 18px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.chat-widget-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Área de mensajes */
.chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg-gray-50, #f9fafb);
}

[data-theme="dark"] .chat-widget-messages {
    background: var(--bg-gray-50, #2d2d2d);
}

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

.chat-widget-messages::-webkit-scrollbar-track {
    background: var(--bg-gray-100, #f3f4f6);
}

[data-theme="dark"] .chat-widget-messages::-webkit-scrollbar-track {
    background: var(--bg-gray-100, #3a3a3a);
}

.chat-widget-messages::-webkit-scrollbar-thumb {
    background: var(--bg-gray-400, #9ca3af);
    border-radius: 3px;
}

.chat-widget-messages::-webkit-scrollbar-thumb:hover {
    background: var(--bg-gray-300, #d1d5db);
}

/* Mensajes */
.chat-message {
    display: flex;
    margin-bottom: 8px;
    animation: fadeIn 0.3s ease;
}

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

.chat-message-user {
    justify-content: flex-end;
}

.chat-message-assistant {
    justify-content: flex-start;
}

.chat-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 14px;
}

.chat-message-user .chat-message-content {
    background: linear-gradient(135deg, var(--primary-500, #2563eb) 0%, var(--primary-600, #1d4ed8) 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message-assistant .chat-message-content {
    background: var(--bg-white, #ffffff);
    color: var(--text-primary, #111827);
    border: 1px solid var(--bg-gray-200, #e5e7eb);
    border-bottom-left-radius: 4px;
    line-height: 1.6;
}

[data-theme="dark"] .chat-message-assistant .chat-message-content {
    background: var(--bg-gray-100, #3a3a3a);
    color: var(--text-primary, #f9fafb);
    border-color: var(--bg-gray-200, #4a4a4a);
}

/* Formato de títulos en mensajes */
.chat-message-content .chat-title {
    display: block;
    font-size: 15px;
    font-weight: 700;
    color: var(--primary-600, #1d4ed8);
    margin-bottom: 8px;
    margin-top: 12px;
}

[data-theme="dark"] .chat-message-content .chat-title {
    color: var(--primary-200, #bfdbfe);
}

.chat-message-content .chat-title:first-child {
    margin-top: 0;
}

/* Formato de secciones */
.chat-section-header {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: var(--primary-600, #1d4ed8);
    margin-top: 16px;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--bg-gray-200, #e5e7eb);
}

.chat-note-header {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: var(--accent-500, #f59e0b);
    margin-top: 16px;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--bg-gray-200, #e5e7eb);
}

[data-theme="dark"] .chat-section-header {
    color: var(--primary-200, #bfdbfe);
    border-bottom-color: var(--bg-gray-200, #4a4a4a);
}

[data-theme="dark"] .chat-note-header {
    border-bottom-color: var(--bg-gray-200, #4a4a4a);
}

/* Formato de listas */
.chat-list-item {
    display: flex;
    gap: 8px;
    margin: 6px 0;
    padding-left: 4px;
}

.chat-list-number {
    color: var(--primary-600, #1d4ed8);
    font-weight: 600;
    min-width: 20px;
    flex-shrink: 0;
}

.chat-bullet {
    color: var(--primary-600, #1d4ed8);
    font-weight: 600;
    min-width: 12px;
    flex-shrink: 0;
}

[data-theme="dark"] .chat-list-number,
[data-theme="dark"] .chat-bullet {
    color: var(--primary-200, #bfdbfe);
}

.chat-list-text {
    flex: 1;
    line-height: 1.5;
}

/* Mejorar espaciado general */
.chat-message-content {
    white-space: pre-wrap;
    word-wrap: break-word;
}

.chat-message-content strong {
    color: var(--text-primary, #111827);
    font-weight: 600;
}

[data-theme="dark"] .chat-message-content strong {
    color: var(--text-primary, #f9fafb);
}

.chat-message-content em {
    font-style: italic;
    color: var(--text-secondary, #6b7280);
}

[data-theme="dark"] .chat-message-content em {
    color: var(--text-secondary, #d1d5db);
}

/* Indicador de escritura */
.typing-dots {
    display: inline-flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary, #6b7280);
    animation: typing 1.4s infinite;
}

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

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

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

/* Input container */
.chat-widget-input-container {
    display: flex;
    gap: 8px;
    padding: 16px;
    background: var(--bg-white, #ffffff);
    border-top: 1px solid var(--bg-gray-200, #e5e7eb);
}

[data-theme="dark"] .chat-widget-input-container {
    background: var(--bg-gray-50, #2d2d2d);
    border-top-color: var(--bg-gray-200, #4a4a4a);
}

.chat-widget-input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-gray-50, #f9fafb);
    border: 1px solid var(--bg-gray-200, #e5e7eb);
    border-radius: 8px;
    color: var(--text-primary, #111827);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

[data-theme="dark"] .chat-widget-input {
    background: var(--bg-gray-100, #3a3a3a);
    border-color: var(--bg-gray-200, #4a4a4a);
    color: var(--text-primary, #f9fafb);
}

.chat-widget-input:focus {
    border-color: var(--primary-500, #2563eb);
}

.chat-widget-input::placeholder {
    color: var(--text-secondary, #6b7280);
}

.chat-widget-send {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary-500, #2563eb) 0%, var(--primary-600, #1d4ed8) 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 16px;
}

.chat-widget-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.chat-widget-send:active {
    transform: scale(0.95);
}

/* Responsive */
@media (max-width: 480px) {
    .chat-widget-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 40px);
        max-height: calc(100vh - 40px);
        bottom: 20px;
        right: 20px;
        left: 20px;
    }

    #chat-widget-container {
        bottom: 20px;
        right: 20px;
    }
}

