/**
 * luna.css — Widget del agente Luna
 * Pilates Integral Chile
 */

/* ── Botón flotante ─────────────────────────────────────────── */
.luna-bubble {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.8rem;
}

.luna-toggle {
    width: 60px; height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--rose) 0%, var(--terracotta) 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px -8px rgba(111,167,194,0.6);
    transition: all 0.35s var(--ease-out);
    position: relative;
}
.luna-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 40px -8px rgba(111,167,194,0.7);
}
.luna-toggle svg {
    width: 28px; height: 28px;
    stroke: var(--white);
    transition: all 0.3s var(--ease-out);
}
.luna-toggle .luna-icon-close { display: none; }
.luna-toggle.open .luna-icon-chat  { display: none; }
.luna-toggle.open .luna-icon-close { display: block; }

/* Badge de notificación */
.luna-badge {
    position: absolute;
    top: -4px; right: -4px;
    width: 18px; height: 18px;
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid white;
    opacity: 0;
    transform: scale(0);
    transition: all 0.3s var(--ease-out);
}
.luna-badge.visible {
    opacity: 1;
    transform: scale(1);
}

/* Tooltip inicial */
.luna-tooltip {
    background: var(--white);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 0.88rem;
    padding: 0.6rem 1rem;
    border-radius: 100px;
    box-shadow: 0 4px 20px -4px rgba(35,32,32,0.2);
    white-space: nowrap;
    animation: lunaTooltipIn 0.4s var(--ease-out) 2s both;
    cursor: pointer;
}
@keyframes lunaTooltipIn {
    from { opacity: 0; transform: translateX(10px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ── Ventana del chat ───────────────────────────────────────── */
.luna-window {
    position: fixed;
    bottom: 6rem;
    right: 2rem;
    width: 370px;
    max-height: 560px;
    background: var(--white);
    border-radius: 16px;
    box-shadow: 0 24px 60px -12px rgba(35,32,32,0.25);
    display: flex;
    flex-direction: column;
    z-index: 999;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px) scale(0.97);
    transition: all 0.35s var(--ease-out);
    transform-origin: bottom right;
}
.luna-window.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header */
.luna-header {
    background: linear-gradient(135deg, var(--ink) 0%, #2d4e62 100%);
    padding: 1.2rem 1.4rem;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    flex-shrink: 0;
}
.luna-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--rose) 0%, var(--terracotta) 100%);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--white);
    font-style: italic;
    flex-shrink: 0;
}
.luna-header__info { flex: 1; }
.luna-header__name {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--white);
    font-weight: 400;
}
.luna-header__status {
    font-family: var(--font-sans);
    font-size: 0.72rem;
    color: rgba(255,255,255,0.6);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.luna-header__status::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
}

/* Mensajes */
.luna-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    scroll-behavior: smooth;
}
.luna-messages::-webkit-scrollbar { width: 4px; }
.luna-messages::-webkit-scrollbar-track { background: transparent; }
.luna-messages::-webkit-scrollbar-thumb { background: var(--nude); border-radius: 2px; }

/* Burbuja de mensaje */
.luna-msg {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: lunaMsg 0.3s var(--ease-out);
}
@keyframes lunaMsg {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.luna-msg--luna { align-self: flex-start; }
.luna-msg--user { align-self: flex-end; }

.luna-msg__bubble {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    line-height: 1.55;
}
.luna-msg--luna .luna-msg__bubble {
    background: var(--nude-light);
    color: var(--charcoal);
    border-bottom-left-radius: 4px;
}
.luna-msg--user .luna-msg__bubble {
    background: var(--rose);
    color: var(--white);
    border-bottom-right-radius: 4px;
}
.luna-msg__time {
    font-size: 0.7rem;
    color: var(--charcoal);
    opacity: 0.4;
    margin-top: 0.3rem;
    padding: 0 0.2rem;
}
.luna-msg--user .luna-msg__time { text-align: right; }

/* Typing indicator */
.luna-typing {
    display: flex;
    gap: 4px;
    padding: 0.75rem 1rem;
    background: var(--nude-light);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}
.luna-typing span {
    width: 6px; height: 6px;
    background: var(--rose);
    border-radius: 50%;
    animation: lunaDot 1.2s ease-in-out infinite;
}
.luna-typing span:nth-child(2) { animation-delay: 0.2s; }
.luna-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes lunaDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30%            { transform: translateY(-6px); opacity: 1; }
}

/* Input */
.luna-input-area {
    padding: 0.9rem 1rem;
    border-top: 1px solid var(--nude);
    display: flex;
    gap: 0.6rem;
    align-items: flex-end;
    flex-shrink: 0;
}
.luna-input {
    flex: 1;
    border: 1.5px solid var(--nude);
    border-radius: 20px;
    padding: 0.65rem 1rem;
    font-family: var(--font-sans);
    font-size: 0.88rem;
    color: var(--charcoal);
    outline: none;
    resize: none;
    max-height: 80px;
    min-height: 38px;
    transition: border-color 0.3s ease;
    background: var(--off-white);
    line-height: 1.4;
}
.luna-input:focus { border-color: var(--rose); background: var(--white); }
.luna-input::placeholder { color: var(--charcoal); opacity: 0.4; }

.luna-send {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--rose);
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: all 0.25s var(--ease-out);
}
.luna-send:hover { background: var(--terracotta); transform: scale(1.05); }
.luna-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.luna-send svg { width: 16px; height: 16px; stroke: var(--white); }

/* Footer */
.luna-footer {
    text-align: center;
    padding: 0.4rem 0 0.6rem;
    font-family: var(--font-sans);
    font-size: 0.68rem;
    color: var(--charcoal);
    opacity: 0.35;
    flex-shrink: 0;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 480px) {
    .luna-window {
        width: calc(100vw - 2rem);
        right: 1rem;
        bottom: 5rem;
        max-height: calc(100vh - 7rem);
    }
    .luna-bubble { right: 1rem; bottom: 1.5rem; }
}

/* Botón nueva conversación */
.luna-new {
    width: 32px;
    height: 32px;
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    color: var(--white);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
    flex-shrink: 0;
}
.luna-new:hover {
    background: rgba(255,255,255,0.18);
    transform: rotate(20deg);
}
.luna-new:focus-visible,
.luna-send:focus-visible,
.luna-toggle:focus-visible {
    outline: 2px solid var(--white);
    outline-offset: 2px;
}
