:root {
    /* Paleta de colores basada en la imagen de IPS DATAX */
    --primary-blue: #0b0273;     /* Azul oscuro del botón "Mis cursos" */
    --primary-orange: #f59e0b;   /* Naranja del botón "Inicio" */
    --primary-orange-hover: #d98604;
    
    --bg-color: #f0f4f8;         /* Fondo gris azulado muy suave */
    --chat-bg: #ffffff;
    
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --text-light: #ffffff;
    
    --bot-msg-bg: #f3f4f6;
    --bot-msg-text: #1f2937;
    --user-msg-bg: var(--primary-blue);
    --user-msg-text: #ffffff;
    
    --shadow-soft: 0 10px 40px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 15px 50px rgba(11, 2, 115, 0.15);
    
    --radius-lg: 20px;
    --radius-md: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    background-image: radial-gradient(circle at 10% 20%, rgba(245, 158, 11, 0.05) 0%, transparent 40%),
                      radial-gradient(circle at 90% 80%, rgba(11, 2, 115, 0.05) 0%, transparent 40%);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

/* App Container */
.app-container {
    width: 100%;
    max-width: 450px;
    height: 90vh;
    max-height: 800px;
    position: relative;
    animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Chat Wrapper */
.chat-wrapper {
    background-color: var(--chat-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: box-shadow 0.3s ease;
    border: 1px solid rgba(0,0,0,0.05);
}

.chat-wrapper:hover {
    box-shadow: var(--shadow-hover);
}

/* Header */
.chat-header {
    background: linear-gradient(135deg, var(--primary-blue), #1e139c);
    color: var(--text-light);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid var(--primary-orange);
    position: relative;
    z-index: 10;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.bot-avatar {
    width: 45px;
    height: 45px;
    background-color: white;
    color: var(--primary-blue);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    position: relative;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.status-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background-color: #10b981; /* Verde esmeralda indicando conexión */
    border: 2px solid white;
    border-radius: 50%;
}

.chat-header h1 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.status-text {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 300;
}

.icon-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

.icon-btn:hover {
    background: rgba(255,255,255,0.25);
    transform: rotate(90deg);
}

/* Messages Area */
.chat-messages {
    flex: 1;
    padding: 25px 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
    background-color: var(--chat-bg);
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
    background-color: rgba(0,0,0,0.1);
    border-radius: 10px;
}

/* Let messages animate in */
.message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.bot {
    align-self: flex-start;
}

.message.user {
    align-self: flex-end;
}

.message-content {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
}

.message-content p {
    margin-bottom: 8px;
}
.message-content p:last-child {
    margin-bottom: 0;
}

.message.bot .message-content {
    background-color: var(--bot-msg-bg);
    color: var(--bot-msg-text);
    border-bottom-left-radius: 4px;
}

.message.user .message-content {
    background-color: var(--user-msg-bg);
    color: var(--user-msg-text);
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(11, 2, 115, 0.2);
}

.message-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 6px;
    padding: 0 4px;
}

.message.bot .message-time {
    text-align: left;
}

.message.user .message-time {
    text-align: right;
}

/* Input Area */
.chat-input-container {
    padding: 15px 20px 20px;
    background-color: white;
    border-top: 1px solid rgba(0,0,0,0.05);
}

.chat-form {
    display: flex;
    gap: 10px;
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 30px;
    padding: 6px 6px 6px 20px;
    transition: all 0.3s ease;
}

.chat-form:focus-within {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(11, 2, 115, 0.1);
}

#message-input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    color: var(--text-main);
}

#message-input::placeholder {
    color: #9ca3af;
}

.send-btn {
    background-color: var(--primary-orange);
    color: white;
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
    font-size: 1rem;
}

.send-btn:hover {
    background-color: var(--primary-orange-hover);
    transform: scale(1.05);
}

.send-btn:active {
    transform: scale(0.95);
}

.send-btn i {
    transition: transform 0.2s;
}

.send-btn:hover i {
    transform: translateX(2px) translateY(-2px);
}

.footer-text {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 12px;
}

.footer-text a {
    color: var(--primary-blue);
    text-decoration: none;
    font-weight: 600;
}

.footer-text a:hover {
    text-decoration: underline;
}

/* Typing Indicator */
.typing-indicator {
    display: none; /* Oculto por defecto */
    align-self: flex-start;
    background-color: var(--bot-msg-bg);
    padding: 12px 18px;
    border-radius: var(--radius-md);
    border-bottom-left-radius: 4px;
    margin-bottom: 10px;
    gap: 5px;
    align-items: center;
}

.typing-indicator.active {
    display: flex;
    animation: messageSlideIn 0.3s ease-out;
}

.typing-indicator .dot {
    width: 8px;
    height: 8px;
    background-color: var(--text-muted);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator .dot:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator .dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Markdown en respuestas */
.message-content strong { color: inherit; font-weight: 700; }
.message-content ul, .message-content ol { padding-left: 20px; margin-top: 5px; }
.message-content a { color: var(--primary-orange); text-decoration: underline; }
