/* ============================================
   ASTRA CHATBOT — styles
   ============================================ */

/* ---------- Bubble ---------- */
#astra-bubble {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9999;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--salmon);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 24px rgba(0, 153, 221, 0.45);
    transition: var(--transition);
    overflow: hidden;
}

#astra-bubble img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    transition: var(--transition);
}

#astra-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 32px rgba(0, 153, 221, 0.65);
}

#astra-bubble .astra-close-icon {
    display: none;
    font-size: 22px;
    color: #fff;
    line-height: 1;
}

#astra-bubble.is-open img { display: none; }
#astra-bubble.is-open .astra-close-icon { display: block; }

/* Pulse ring */
#astra-bubble::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--salmon);
    animation: astra-pulse 2.4s ease-out infinite;
    pointer-events: none;
}

@keyframes astra-pulse {
    0%   { transform: scale(1); opacity: 0.7; }
    70%  { transform: scale(1.6); opacity: 0; }
    100% { transform: scale(1.6); opacity: 0; }
}

/* ---------- Chat window ---------- */
#astra-chat {
    position: fixed;
    bottom: 100px;
    right: 28px;
    z-index: 9998;
    width: 370px;
    max-width: calc(100vw - 40px);
    height: 540px;
    max-height: calc(100vh - 130px);
    background: var(--bg-black-secondary);
    border: 1px solid rgba(0, 153, 221, 0.25);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow:
        0 24px 60px rgba(0,0,0,0.6),
        0 0 0 1px rgba(0,153,221,0.08);
    transform: translateY(16px) scale(0.96);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s cubic-bezier(0.25,0.46,0.45,0.94),
                transform 0.28s cubic-bezier(0.25,0.46,0.45,0.94);
}

#astra-chat.is-visible {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0) scale(1);
}

/* Header */
.astra-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(0, 153, 221, 0.15);
    background: rgba(0, 153, 221, 0.06);
    flex-shrink: 0;
}

.astra-header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid var(--salmon);
    object-fit: cover;
    flex-shrink: 0;
}

.astra-header-info {
    flex: 1;
    min-width: 0;
}

.astra-header-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-light);
    letter-spacing: 0.04em;
}

.astra-header-status {
    font-size: 0.72rem;
    color: var(--salmon);
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 1px;
}

.astra-header-status::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--salmon);
    box-shadow: 0 0 6px var(--salmon);
    animation: astra-blink 2s ease-in-out infinite;
}

@keyframes astra-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

/* Messages area */
.astra-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.astra-messages::-webkit-scrollbar { width: 4px; }
.astra-messages::-webkit-scrollbar-track { background: transparent; }
.astra-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 153, 221, 0.3);
    border-radius: 4px;
}

/* Message bubbles */
.astra-msg {
    max-width: 85%;
    font-size: 0.875rem;
    line-height: 1.55;
    animation: astra-msg-in 0.22s ease-out both;
}

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

.astra-msg.bot {
    align-self: flex-start;
    background: rgba(0, 153, 221, 0.1);
    border: 1px solid rgba(0, 153, 221, 0.2);
    color: var(--text-light);
    border-radius: 4px 16px 16px 16px;
    padding: 10px 14px;
}

.astra-msg.user {
    align-self: flex-end;
    background: var(--salmon);
    color: #fff;
    border-radius: 16px 4px 16px 16px;
    padding: 10px 14px;
}

/* Typing indicator */
.astra-typing {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
    background: rgba(0, 153, 221, 0.08);
    border: 1px solid rgba(0, 153, 221, 0.15);
    border-radius: 4px 16px 16px 16px;
    animation: astra-msg-in 0.22s ease-out both;
}

.astra-typing span {
    width: 7px;
    height: 7px;
    background: var(--salmon);
    border-radius: 50%;
    animation: astra-bounce 1.2s ease-in-out infinite;
}

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

@keyframes astra-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }
    30%            { transform: translateY(-6px); opacity: 1; }
}

/* Input area */
.astra-input-area {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 14px 16px;
    border-top: 1px solid rgba(0, 153, 221, 0.15);
    background: rgba(0,0,0,0.2);
    flex-shrink: 0;
}

#astra-input {
    flex: 1;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(0, 153, 221, 0.2);
    border-radius: 12px;
    color: var(--text-light);
    font-family: inherit;
    font-size: 0.875rem;
    padding: 10px 14px;
    resize: none;
    min-height: 42px;
    max-height: 110px;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.2s;
}

#astra-input::placeholder { color: rgba(255,255,255,0.3); }
#astra-input:focus { border-color: rgba(0, 153, 221, 0.55); }

#astra-send {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    background: var(--salmon);
    border: none;
    border-radius: 12px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: 16px;
}

#astra-send:hover:not(:disabled) {
    background: var(--salmon-dark);
    transform: scale(1.05);
}

#astra-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* Disclaimer */
.astra-disclaimer {
    font-size: 0.68rem;
    color: rgba(255,255,255,0.2);
    text-align: center;
    padding: 6px 16px 10px;
}

/* Mobile adjustments */
@media (max-width: 480px) {
    #astra-chat {
        right: 12px;
        bottom: 90px;
        width: calc(100vw - 24px);
    }
    #astra-bubble {
        right: 16px;
        bottom: 20px;
    }
}

/* ── Links clicables dentro de mensajes de Astra ── */
.astra-msg.bot .astra-link {
    color: var(--salmon);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
    white-space: nowrap;
}

.astra-msg.bot .astra-link:hover {
    color: var(--salmon-dark);
    text-decoration-thickness: 2px;
}