/**
 * zenia.css — Estilos del Chatbot ZenIA para Gratitud Yoga
 * ─────────────────────────────────────────────────────────
 * Paleta integrada con el diseño del sitio:
 *   --primary-color: #5d737e
 *   --accent-color:  #b59da4
 *   --sand:          #f4f1ea
 */

/* ══════════════════════════════════════════
   VARIABLES PROPIAS DE ZENIA
══════════════════════════════════════════ */
:root {
    --zenia-primary:     #5d737e;
    --zenia-accent:      #b59da4;
    --zenia-sand:        #f4f1ea;
    --zenia-white:       #ffffff;
    --zenia-bubble-user: #5d737e;
    --zenia-bubble-bot:  #ffffff;
    --zenia-text-user:   #ffffff;
    --zenia-text-bot:    #2c3e50;
    --zenia-shadow:      0 8px 32px rgba(93, 115, 126, 0.22);
    --zenia-radius:      20px;
    --zenia-panel-w:     370px;
    --zenia-panel-h:     580px;
    --zenia-z:           9000;
    --zenia-font:        'Jost', 'Montserrat', sans-serif;
}

/* ══════════════════════════════════════════
   BOTÓN FLOTANTE (FAB)
══════════════════════════════════════════ */
.zenia-fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    background: transparent;
    box-shadow: none;
    cursor: pointer;
    z-index: var(--zenia-z);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: visible;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.35s ease;
    will-change: transform;
    filter: drop-shadow(0 4px 12px rgba(93, 115, 126, 0.4));
}

.zenia-fab:hover {
    transform: scale(1.1);
    filter: drop-shadow(0 8px 20px rgba(93, 115, 126, 0.55));
}

.zenia-fab--active {
    transform: scale(0.92) rotate(5deg);
}

.zenia-fab--appear {
    animation: zeniaFabAppear 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.zenia-fab-avatar {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 0;
    display: block;
}

/* Pulso de atención (modo prod) */
.zenia-fab--pulse::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--zenia-accent);
    animation: zeniaPulse 2s ease-out infinite;
    pointer-events: none;
}

/* Badge de notificación */
.zenia-fab-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #e74c3c;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    line-height: 1;
}

/* Estado oculto (modo dev) */
.zenia-hidden {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: scale(0.5) !important;
}

/* ══════════════════════════════════════════
   PANEL DE CHAT
══════════════════════════════════════════ */
.zenia-panel {
    position: fixed;
    bottom: 104px;
    right: 28px;
    width: var(--zenia-panel-w);
    height: var(--zenia-panel-h);
    background: var(--zenia-white);
    border-radius: var(--zenia-radius);
    box-shadow: var(--zenia-shadow), 0 0 0 1px rgba(93, 115, 126, 0.08);
    z-index: calc(var(--zenia-z) - 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
    transform: translateY(20px) scale(0.96);
    transform-origin: bottom right;
    transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    will-change: transform, opacity;
}

.zenia-panel--open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ── HEADER ── */
.zenia-header {
    background: linear-gradient(135deg, var(--zenia-primary) 0%, #4a6470 100%);
    padding: 1rem 1.1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    position: relative;
}

.zenia-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(255,255,255,0.12);
}

.zenia-header-identity {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.zenia-avatar-wrapper {
    position: relative;
    flex-shrink: 0;
}

.zenia-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.35);
    display: block;
}

.zenia-status-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #2ecc71;
    border: 2px solid var(--zenia-primary);
    animation: zeniaBlink 2.5s ease-in-out infinite;
}

.zenia-header-info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.zenia-name {
    color: white;
    font-weight: 700;
    font-size: 1rem;
    font-family: var(--zenia-font);
    letter-spacing: 0.3px;
}

.zenia-tagline {
    color: rgba(255,255,255,0.72);
    font-size: 0.73rem;
    font-family: var(--zenia-font);
    letter-spacing: 0.2px;
}

.zenia-close-btn {
    background: rgba(255,255,255,0.12);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
    flex-shrink: 0;
}

.zenia-close-btn:hover {
    background: rgba(255,255,255,0.25);
    transform: scale(1.1);
}

/* ── MENSAJES ── */
.zenia-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    scroll-behavior: smooth;
    background: #f8f7f5;
}

.zenia-messages::-webkit-scrollbar {
    width: 4px;
}

.zenia-messages::-webkit-scrollbar-track {
    background: transparent;
}

.zenia-messages::-webkit-scrollbar-thumb {
    background: rgba(93, 115, 126, 0.25);
    border-radius: 4px;
}

/* ── BURBUJA DE MENSAJE ── */
.zenia-msg {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    max-width: 88%;
    animation: zeniaMsgIn 0.28s ease both;
}

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

.zenia-msg--assistant {
    align-self: flex-start;
}

.zenia-msg-avatar-sm {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

.zenia-msg-avatar-sm img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.zenia-msg-bubble {
    padding: 0.65rem 1rem;
    border-radius: 16px;
    font-family: var(--zenia-font);
    font-size: 0.875rem;
    line-height: 1.55;
    max-width: 100%;
    word-break: break-word;
}

.zenia-msg--user .zenia-msg-bubble {
    background: var(--zenia-bubble-user);
    color: var(--zenia-text-user);
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(93, 115, 126, 0.3);
}

.zenia-msg--assistant .zenia-msg-bubble {
    background: var(--zenia-bubble-bot);
    color: var(--zenia-text-bot);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
}

/* Parrafos dentro del bubble */
.zenia-msg-text p {
    margin: 0 0 0.4em;
}

.zenia-msg-text p:last-child {
    margin-bottom: 0;
}

.zenia-msg-text strong {
    color: var(--zenia-primary);
    font-weight: 700;
}

.zenia-msg--user .zenia-msg-text strong {
    color: rgba(255,255,255,0.9);
}

/* ── BOTONES DE ACCIÓN (en burbuja del agente) ── */
.zenia-action-btns {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-top: 0.75rem;
}

.zenia-action-btn {
    background: var(--zenia-primary);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 0.55rem 0.9rem;
    font-family: var(--zenia-font);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s ease, transform 0.15s ease;
    letter-spacing: 0.2px;
}

.zenia-action-btn:hover {
    background: #4a6470;
    transform: translateX(3px);
}

.zenia-action-btn--inline {
    display: inline-block;
    margin-top: 0.25rem;
    margin-bottom: 0.75rem;
}

/* ── TYPING INDICATOR ── */
.zenia-typing-wrapper {
    max-width: fit-content;
}

.zenia-typing-bubble {
    padding: 0.75rem 1.1rem !important;
    display: flex;
    align-items: center;
    gap: 5px;
}

.zenia-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--zenia-accent);
    animation: zeniaDot 1.4s ease-in-out infinite;
    display: inline-block;
}

.zenia-dot:nth-child(2) { animation-delay: 0.2s; }
.zenia-dot:nth-child(3) { animation-delay: 0.4s; }

/* ── SUGERENCIAS RÁPIDAS ── */
.zenia-suggestions {
    padding: 0.65rem 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    background: var(--zenia-sand);
    border-top: 1px solid rgba(93, 115, 126, 0.1);
    flex-shrink: 0;
}

.zenia-suggestion-chip {
    background: white;
    border: 1.5px solid rgba(93, 115, 126, 0.2);
    color: var(--zenia-primary);
    border-radius: 20px;
    padding: 0.35rem 0.75rem;
    font-family: var(--zenia-font);
    font-size: 0.76rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1.3;
    text-align: left;
}

.zenia-suggestion-chip:hover {
    background: var(--zenia-primary);
    color: white;
    border-color: var(--zenia-primary);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(93, 115, 126, 0.25);
}

/* ── INPUT ── */
.zenia-input-area {
    padding: 0.75rem 1rem 0.65rem;
    background: white;
    border-top: 1px solid rgba(93, 115, 126, 0.1);
    flex-shrink: 0;
}

.zenia-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    background: #f0ede8;
    border-radius: 14px;
    padding: 0.5rem 0.6rem 0.5rem 0.9rem;
    transition: box-shadow 0.2s ease;
}

.zenia-input-wrapper:focus-within {
    box-shadow: 0 0 0 2px rgba(93, 115, 126, 0.3);
}

.zenia-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-family: var(--zenia-font);
    font-size: 0.875rem;
    color: #2c3e50;
    resize: none;
    line-height: 1.45;
    max-height: 120px;
    min-height: 22px;
    padding: 0;
}

.zenia-input::placeholder {
    color: #aaa;
}

.zenia-send-btn {
    background: var(--zenia-primary);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    align-self: flex-end;
}

.zenia-send-btn:hover:not(:disabled) {
    background: #4a6470;
    transform: scale(1.1);
}

.zenia-send-btn:disabled {
    background: #c8d3d8;
    cursor: not-allowed;
}

.zenia-disclaimer {
    font-family: var(--zenia-font);
    font-size: 0.67rem;
    color: #bbb;
    text-align: center;
    margin-top: 0.4rem;
    line-height: 1.3;
}

/* ══════════════════════════════════════════
   TOAST DE MODO DEV
══════════════════════════════════════════ */
.zenia-dev-toast {
    position: fixed;
    bottom: 110px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(93, 115, 126, 0.92);
    color: white;
    padding: 0.65rem 1.3rem;
    border-radius: 30px;
    font-family: var(--zenia-font);
    font-size: 0.82rem;
    font-weight: 500;
    z-index: 99999;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    backdrop-filter: blur(8px);
    white-space: nowrap;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.zenia-dev-toast--show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ══════════════════════════════════════════
   ANIMACIONES
══════════════════════════════════════════ */
@keyframes zeniaFabAppear {
    from { opacity: 0; transform: scale(0.4) rotate(-15deg); }
    to   { opacity: 1; transform: scale(1) rotate(0deg); }
}

@keyframes zeniaPulse {
    0%   { transform: scale(1);   opacity: 0.9; }
    70%  { transform: scale(1.5); opacity: 0; }
    100% { transform: scale(1.5); opacity: 0; }
}

@keyframes zeniaBlink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

@keyframes zeniaDot {
    0%, 60%, 100% { transform: translateY(0); }
    30%           { transform: translateY(-5px); }
}

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

/* ══════════════════════════════════════════
   RESPONSIVE — MÓVIL
══════════════════════════════════════════ */
@media (max-width: 480px) {
    .zenia-panel {
        width: calc(100vw - 20px);
        right: 10px;
        bottom: 90px;
        height: calc(100dvh - 105px);
        max-height: 600px;
        border-radius: 18px;
    }

    .zenia-fab {
        bottom: 20px;
        right: 18px;
        width: 58px;
        height: 58px;
    }

    .zenia-suggestion-chip {
        font-size: 0.72rem;
        padding: 0.3rem 0.65rem;
    }
}
