/**
 * Akademia 360 - Estilos Modernos del Asistente Virtual Inteligente
 * Paleta corporativa: Turquesa (#03cbc5), Rojo (#f8415b), Gris Profundo (#192121)
 */

:root {
    --aka-turquesa: #03cbc5;
    --aka-turquesa-dark: #029b97;
    --aka-turquesa-light: #e6faf9;
    --aka-rojo: #f8415b;
    --aka-rojo-hover: #d92c44;
    --aka-dark: #192121;
    --aka-gray-bg: #f4f7f6;
    --aka-border: #e2e8f0;
    --aka-text: #2d3748;
    --aka-shadow: 0 12px 36px rgba(0, 0, 0, 0.18);
    --aka-radius: 18px;
}

/* ====================================================
   1. BOTÓN LANZADOR Y BURBUJA INVITACIONAL
   ==================================================== */
.aka-chat-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--aka-turquesa) 0%, var(--aka-turquesa-dark) 100%);
    box-shadow: 0 8px 24px rgba(3, 203, 197, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 99999;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: none;
    outline: none;
    color: #ffffff;
}

.aka-chat-launcher:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 30px rgba(3, 203, 197, 0.6);
}

.aka-chat-launcher .launcher-icon-chat,
.aka-chat-launcher .launcher-icon-close {
    font-size: 26px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.aka-chat-launcher .launcher-icon-close {
    display: none;
}

.aka-chat-launcher.is-active .launcher-icon-chat {
    display: none;
}

.aka-chat-launcher.is-active .launcher-icon-close {
    display: block;
    transform: rotate(90deg);
}

/* Tooltip / Globo de Invitación */
.aka-chat-callout {
    position: fixed;
    bottom: 30px;
    right: 96px;
    background: #ffffff;
    color: var(--aka-dark);
    padding: 12px 18px;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    font-size: 13.5px;
    font-weight: 500;
    z-index: 99998;
    max-width: 250px;
    line-height: 1.4;
    border-left: 4px solid var(--aka-turquesa);
    animation: akaPulseBounce 4s infinite ease-in-out;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.aka-chat-callout-close {
    background: transparent;
    border: none;
    color: #a0aec0;
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.aka-chat-callout-close:hover {
    color: var(--aka-rojo);
}

@keyframes akaPulseBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* ====================================================
   2. VENTANA PRINCIPAL DEL CHAT
   ==================================================== */
.aka-chat-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 380px;
    height: 580px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: var(--aka-radius);
    box-shadow: var(--aka-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.aka-chat-window.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header */
.aka-chat-header {
    background: linear-gradient(135deg, var(--aka-dark) 0%, #2a3737 100%);
    color: #ffffff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid var(--aka-turquesa);
}

.aka-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.aka-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--aka-turquesa);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    position: relative;
    box-shadow: 0 4px 10px rgba(3, 203, 197, 0.3);
}

.aka-chat-online-badge {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background: #10b981;
    border: 2px solid #ffffff;
    border-radius: 50%;
}

.aka-chat-title h5 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.2px;
    color: #ffffff;
}

.aka-chat-title span {
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.75);
    display: flex;
    align-items: center;
    gap: 4px;
}

.aka-chat-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.aka-chat-action-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-size: 15px;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s;
}

.aka-chat-action-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
}

/* ====================================================
   3. ÁREA DE MENSAJES
   ==================================================== */
.aka-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px 14px;
    background: var(--aka-gray-bg);
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

.aka-msg {
    display: flex;
    gap: 10px;
    max-width: 90%;
    animation: akaFadeInUp 0.25s ease-out forwards;
}

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

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

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

.aka-msg-content {
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.5;
    word-break: break-word;
}

.aka-msg-bot .aka-msg-content {
    background: #ffffff;
    color: var(--aka-text);
    border-top-left-radius: 2px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border: 1px solid #edf2f7;
}

.aka-msg-user .aka-msg-content {
    background: linear-gradient(135deg, var(--aka-turquesa) 0%, var(--aka-turquesa-dark) 100%);
    color: #ffffff;
    border-top-right-radius: 2px;
    box-shadow: 0 3px 10px rgba(3, 203, 197, 0.3);
}

.aka-msg-content p {
    margin: 0 0 6px 0;
}
.aka-msg-content p:last-child {
    margin-bottom: 0;
}

.aka-msg-content ul {
    margin: 6px 0 6px 18px;
    padding: 0;
}

.aka-msg-content a {
    color: var(--aka-turquesa-dark);
    font-weight: 600;
    text-decoration: underline;
}

.aka-msg-content a.aka-course-btn {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 14px;
    background: var(--aka-turquesa);
    color: #ffffff !important;
    text-decoration: none !important;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    transition: background 0.2s;
}

.aka-msg-content a.aka-course-btn:hover {
    background: var(--aka-turquesa-dark);
}

.aka-chat-disclaimer {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed #e2e8f0;
    font-size: 11px;
    color: #718096;
    line-height: 1.35;
    font-style: italic;
    display: block;
}

/* Indicador de escritura (Thinking) */
.aka-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    width: fit-content;
}

.aka-typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--aka-turquesa);
    border-radius: 50%;
    animation: akaBlink 1.4s infinite both;
}

.aka-typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.aka-typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes akaBlink {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1.1); }
}

/* ====================================================
   4. CHIPS DE SUGERENCIAS RÁPIDAS
   ==================================================== */
.aka-chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.aka-chip-btn {
    background: #ffffff;
    border: 1px solid rgba(3, 203, 197, 0.4);
    color: var(--aka-dark);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.aka-chip-btn:hover {
    background: var(--aka-turquesa-light);
    border-color: var(--aka-turquesa);
    color: var(--aka-turquesa-dark);
    transform: translateY(-1px);
}

/* ====================================================
   5. MINI FORMULARIO DE DERIVACIÓN A HUMANO (HANDOFF)
   ==================================================== */
.aka-handoff-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-top: 3px solid var(--aka-rojo);
    border-radius: 12px;
    padding: 14px;
    margin-top: 6px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
    animation: akaFadeInUp 0.3s ease-out;
}

.aka-handoff-card h6 {
    margin: 0 0 4px 0;
    font-size: 13.5px;
    font-weight: 700;
    color: var(--aka-dark);
    display: flex;
    align-items: center;
    gap: 6px;
}

.aka-handoff-card p {
    font-size: 12px;
    color: #718096;
    margin-bottom: 10px;
}

.aka-handoff-field {
    margin-bottom: 8px;
}

.aka-handoff-field input,
.aka-handoff-field textarea {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 12.5px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.aka-handoff-field input:focus,
.aka-handoff-field textarea:focus {
    border-color: var(--aka-turquesa);
    box-shadow: 0 0 0 2px rgba(3, 203, 197, 0.15);
}

.aka-handoff-btn {
    width: 100%;
    background: var(--aka-rojo);
    color: #ffffff;
    border: none;
    padding: 9px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 6px;
}

.aka-handoff-btn:hover {
    background: var(--aka-rojo-hover);
}

.aka-handoff-btn:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
}

/* ====================================================
   6. ÁREA DE INPUT Y ENVÍO
   ==================================================== */
.aka-chat-footer {
    padding: 10px 14px;
    background: #ffffff;
    border-top: 1px solid var(--aka-border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.aka-chat-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    resize: none;
    max-height: 80px;
    transition: border-color 0.2s;
}

.aka-chat-input:focus {
    border-color: var(--aka-turquesa);
}

.aka-chat-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--aka-turquesa);
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.aka-chat-send-btn:hover {
    background: var(--aka-turquesa-dark);
    transform: scale(1.05);
}

.aka-chat-send-btn:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
    transform: none;
}

/* ====================================================
   7. RESPONSIVE (Móviles)
   ==================================================== */
@media (max-width: 480px) {
    .aka-chat-window {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    .aka-chat-callout {
        display: none; /* En móviles ocultamos el globo para no tapar pantalla */
    }
}
