/**
 * Aura - Chat ViaFacil
 * Estética alineada con el logo y marca ViaFacil.
 * Tono: amigable, ligero, moderno. Inspiración sutil de "aura" / nube.
 */

:root {
    --aura-primary: #1e40af;
    --aura-primary-dark: #1e3a8a;
    --aura-primary-light: #3b82f6;
    /* Naranja ViaFacil (logo) para el botón flotante */
    --aura-orange: #F09546;
    --aura-orange-dark: #e08538;
    --aura-orange-light: #f5a855;
    --aura-cloud: rgba(248, 250, 252, 0.98);
    --aura-cloud-border: rgba(30, 64, 175, 0.12);
    --aura-shadow: 0 4px 24px rgba(30, 64, 175, 0.12);
    --aura-shadow-hover: 0 8px 32px rgba(30, 64, 175, 0.18);
    --aura-radius: 16px;
    --aura-radius-sm: 12px;
    --aura-font: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --aura-text: #334155;
    --aura-text-muted: #64748b;
    --aura-bubble-bot: linear-gradient(145deg, #f8fafc 0%, #f1f5f9 100%);
    --aura-bubble-user: linear-gradient(145deg, var(--aura-primary) 0%, var(--aura-primary-dark) 100%);
    --aura-input-bg: #ffffff;
    --aura-input-border: rgba(15, 118, 110, 0.35);
    --aura-glow: 0 0 40px rgba(59, 130, 246, 0.15);
    /* Cabecera del chat: tono propio (no usado en el resto de la web), armónico con la paleta */
    --aura-header-from: #0f766e;
    --aura-header-to: #0d5c55;
    /* Tamaño del ícono del FAB (signo ?) en px: mismo valor en todo el sitio */
    --aura-fab-icon-size: 38px;
}

/* Contenedor flotante del chat - tamaño de fuente fijo para que se vea igual en todo el sitio */
.aura-chat-wrapper {
    font-family: var(--aura-font);
    font-size: 16px;
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9998;
    width: 440px;
    max-width: calc(100vw - 48px);
    height: 640px;
    max-height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    background: var(--aura-cloud);
    border: 1px solid var(--aura-cloud-border);
    border-radius: var(--aura-radius);
    box-shadow: var(--aura-shadow), var(--aura-glow);
    overflow: hidden;
    transition: box-shadow 0.3s ease, transform 0.2s ease;
}

.aura-chat-wrapper.aura-open {
    box-shadow: var(--aura-shadow-hover), var(--aura-glow);
}

/* Minimizado: ocultar todo el panel para que solo se vea el FAB y los clics lleguen al FAB */
.aura-chat-wrapper.aura-minimized {
    display: none !important;
}

/* Cabecera - Aura (color propio del chat, armónico con la paleta pero distinto al resto) */
.aura-chat-header {
    background: linear-gradient(135deg, var(--aura-header-from) 0%, var(--aura-header-to) 100%);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    box-shadow: 0 2px 12px rgba(15, 118, 110, 0.3);
}

.aura-chat-header-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.aura-header-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.aura-chat-header-text h2 {
    margin: 0;
    font-size: 1.125em;
    font-weight: 700;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.aura-online-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    flex-shrink: 0;
    animation: aura-online-pulse 2s ease-in-out infinite;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4);
}

@keyframes aura-online-pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
    50% { opacity: 0.85; box-shadow: 0 0 0 4px rgba(34, 197, 94, 0); }
}

.aura-chat-header-text p {
    font-size: 0.8125em;
    margin: 6px 0 0 0;
    opacity: 1;
    font-weight: 400;
    background: rgba(0, 0, 0, 0.22);
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    display: inline-block;
}

.aura-chat-toggle {
    margin-left: auto;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 1.1em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.aura-chat-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Bloque de bienvenida (personalidad) */
.aura-chat-welcome {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 0 16px;
    margin-bottom: 4px;
    border-bottom: 1px solid rgba(30, 64, 175, 0.08);
    flex-shrink: 0;
}

.aura-welcome-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 2px 12px rgba(30, 64, 175, 0.2);
}

.aura-welcome-text {
    margin: 0;
    font-size: 0.9375em;
    color: var(--aura-text);
    line-height: 1.45;
}

/* Área de mensajes */
.aura-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: linear-gradient(180deg, #fafbfd 0%, #ffffff 100%);
}

.aura-msg {
    display: flex;
    gap: 10px;
    max-width: 92%;
    animation: aura-msg-in 0.3s ease;
}

@keyframes aura-msg-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.aura-msg.aura-msg-bot {
    align-self: flex-start;
}

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

.aura-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9em;
    overflow: hidden;
}

.aura-msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.aura-msg-bot .aura-msg-avatar {
    background: linear-gradient(135deg, var(--aura-primary-light) 0%, var(--aura-primary) 100%);
    color: #fff;
    box-shadow: 0 1px 4px rgba(30, 64, 175, 0.25);
}

.aura-msg-user .aura-msg-avatar {
    background: var(--aura-primary-dark);
    color: #fff;
}

.aura-msg-bubble {
    padding: 12px 16px;
    border-radius: var(--aura-radius-sm);
    font-size: 0.9375em;
    line-height: 1.5;
    word-break: break-word;
}

.aura-msg-bot .aura-msg-bubble {
    background: var(--aura-bubble-bot);
    color: var(--aura-text);
    border: 1px solid rgba(30, 64, 175, 0.08);
    border-bottom-left-radius: 4px;
}

.aura-msg-user .aura-msg-bubble {
    background: var(--aura-bubble-user);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.aura-msg-bubble strong {
    font-weight: 600;
}

.aura-msg-typing {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.aura-typing-text {
    display: block;
    font-size: 0.8125em;
    color: var(--aura-text-muted);
}

.aura-typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
}

.aura-typing-dots span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--aura-primary-light);
    animation: aura-dot 1.2s ease-in-out infinite;
}

.aura-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.aura-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes aura-dot {
    0%, 80%, 100% { opacity: 0.4; transform: scale(0.9); }
    40% { opacity: 1; transform: scale(1); }
}

/* Avatar con animación cuando Aura "escribe" */
.aura-msg-typing-wrap .aura-msg-avatar {
    animation: aura-avatar-typing 1.5s ease-in-out infinite;
}

@keyframes aura-avatar-typing {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.9; }
}

/* Input */
.aura-chat-footer {
    padding: 16px 20px 12px;
    background: #fff;
    border-top: 1px solid var(--aura-input-border);
    flex-shrink: 0;
}

.aura-chat-credit {
    margin: 10px 0 0 0;
    font-size: 0.75em;
    color: var(--aura-text-muted);
    text-align: center;
}

.aura-chat-form {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.aura-chat-input {
    flex: 1;
    min-height: 44px;
    padding: 10px 16px;
    border: 1px solid var(--aura-input-border);
    border-radius: var(--aura-radius-sm);
    font-family: var(--aura-font);
    font-size: 0.9375em;
    color: var(--aura-text);
    background: var(--aura-input-bg);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    resize: none;
}

.aura-chat-input::placeholder {
    color: var(--aura-text-muted);
}

.aura-chat-input:focus {
    outline: none;
    border-color: var(--aura-header-from);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.2);
}

.aura-chat-send {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: var(--aura-radius-sm);
    background: linear-gradient(135deg, var(--aura-header-from) 0%, var(--aura-header-to) 100%);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1em;
    flex-shrink: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.aura-chat-send:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(15, 118, 110, 0.35);
}

.aura-chat-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Botón flotante para abrir chat (signo de pregunta - ayuda). Tamaño del signo: --aura-fab-icon-size en :root */
.aura-chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--aura-orange) 0%, var(--aura-orange-dark) 100%);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--aura-fab-icon-size);
    font-weight: 700;
    font-family: var(--aura-font);
    line-height: 1;
    box-shadow: 0 4px 20px rgba(240, 149, 70, 0.5), 0 0 0 3px rgba(255, 255, 255, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.aura-chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(240, 149, 70, 0.6), 0 0 0 4px rgba(255, 255, 255, 0.5);
}

.aura-chat-fab.aura-hidden {
    display: none;
}

/* Scrollbar suave */
.aura-chat-body::-webkit-scrollbar {
    width: 6px;
}

.aura-chat-body::-webkit-scrollbar-track {
    background: transparent;
}

.aura-chat-body::-webkit-scrollbar-thumb {
    background: var(--aura-input-border);
    border-radius: 3px;
}

.aura-chat-body::-webkit-scrollbar-thumb:hover {
    background: var(--aura-text-muted);
}
