/* Variables CSS para colores y espaciado */
:root {
    --primary-color: #667eea;
    --primary-dark: #5a67d8;
    --secondary-color: #764ba2;
    --background-color: #f7fafc;
    --surface-color: #ffffff;
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --border-color: #e2e8f0;
    --success-color: #48bb78;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset y estilos base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    line-height: 1.6;
}

/* Container principal */
.container {
    width: 100%;
    max-width: 800px;
    height: 600px;
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Header del chat */
.chat-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.bot-avatar {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.header-text h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 2px;
}

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

.status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--success-color);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

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

/* Enlace de privacidad en header */
.privacy-link {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    color: white;
    text-decoration: none;
    font-size: 0.875rem;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    transition: var(--transition);
    opacity: 0.9;
}

.privacy-link:hover {
    background: rgba(255, 255, 255, 0.2);
    opacity: 1;
    transform: translateY(-1px);
}

.privacy-link svg {
    flex-shrink: 0;
}

.privacy-link span {
    font-weight: 500;
}

/* Responsive: ocultar texto en móviles */
@media (max-width: 480px) {
    .privacy-link span {
        display: none;
    }
    
    .privacy-link {
        padding: 8px;
    }
}

/* Container de mensajes */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

/* Scrollbar personalizada */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--background-color);
}

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

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Estilos de mensajes */
.message {
    display: flex;
    gap: 12px;
    max-width: 80%;
    animation: slideIn 0.3s ease-out;
}

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

.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.bot-message {
    align-self: flex-start;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 4px;
}

.bot-message .message-avatar {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
}

.user-message .message-avatar {
    background: var(--text-secondary);
    color: white;
}

.message-content {
    background: var(--background-color);
    padding: 12px 16px;
    border-radius: var(--border-radius);
    position: relative;
}

.user-message .message-content {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
}

.bot-message .message-content {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.message-content p {
    margin: 0;
    word-wrap: break-word;
}

.message-time {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 4px;
    display: block;
}

/* Indicador de escritura */
.typing-indicator {
    padding: 0 24px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

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

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

/* Input del chat */
.chat-input-container {
    padding: 20px 24px;
    background: var(--surface-color);
    border-top: 1px solid var(--border-color);
}

.chat-form {
    margin-bottom: 8px;
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

#messageInput {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: var(--transition);
    background: var(--background-color);
}

#messageInput:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#messageInput:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.send-button {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.send-button:active {
    transform: translateY(0);
}

.send-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.input-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
    margin: 0;
}

/* Estados de error */
.error-message {
    background: #fed7d7 !important;
    color: #c53030 !important;
    border-color: #feb2b2 !important;
}

/* Enlaces clicables en mensajes del bot */
.message-link {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid rgba(102, 126, 234, 0.3);
    transition: all 0.2s ease;
}

.message-link:hover {
    color: #5a67d8;
    border-bottom-color: #5a67d8;
}

/* Enlaces en mensajes del bot tienen color diferente */
.bot-message .message-link {
    color: #667eea;
}

.bot-message .message-link:hover {
    color: #5a67d8;
}

/* Enlaces en mensajes del usuario */
.user-message .message-link {
    color: rgba(255, 255, 255, 0.9);
    border-bottom-color: rgba(255, 255, 255, 0.5);
}

.user-message .message-link:hover {
    color: white;
    border-bottom-color: white;
}

/* Responsive design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        height: calc(100vh - 20px);
        max-height: none;
    }
    
    .chat-header {
        padding: 16px 20px;
    }
    
    .header-text h1 {
        font-size: 1.125rem;
    }
    
    .chat-messages {
        padding: 16px 20px;
    }
    
    .message {
        max-width: 90%;
    }
    
    .chat-input-container {
        padding: 16px 20px;
    }
    
    .input-wrapper {
        gap: 8px;
    }
    
    #messageInput {
        font-size: 16px; /* Evita zoom en iOS */
    }
}

@media (max-width: 480px) {
    .header-content {
        gap: 12px;
    }
    
    .bot-avatar {
        width: 40px;
        height: 40px;
    }
    
    .message-avatar {
        width: 28px;
        height: 28px;
    }
    
    .send-button {
        width: 44px;
        height: 44px;
    }
}

