/* ─── YP AI Assistant — Float CSS v1.2.0 ─────────────────────────────────── */

/* ── Root del flotante — solo ancla el botón flotante ───────────────────── */

.ypa-float-root {
    position: fixed;
    bottom: 24px;
    z-index: 999999;
    font-family: inherit;
}

.ypa-float-root--right { right: 24px; }
.ypa-float-root--left  { left:  24px; }

/* ── Burbuja de llamada junto al botón ───────────────────────────────────── */

.ypa-float-bubble {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.ypa-float-bubble-text {
    background: var(--ypa-float-color, #334F9D);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 10px 14px;
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,.2);
    white-space: nowrap;
    max-width: 200px;
    line-height: 1.3;
    position: relative;
    animation: ypa-bubble-in .4s cubic-bezier(.34,1.56,.64,1) .6s both;
}

/* Colita de la burbuja apuntando al botón (derecha) */
.ypa-float-root--right .ypa-float-bubble-text::after {
    content: '';
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    border: 8px solid transparent;
    border-right: 0;
    border-left-color: var(--ypa-float-color, #334F9D);
}

/* Colita izquierda */
.ypa-float-root--left .ypa-float-bubble-text::after {
    content: '';
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    border: 8px solid transparent;
    border-left: 0;
    border-right-color: var(--ypa-float-color, #334F9D);
}

/* Botón cerrar burbuja */
.ypa-float-bubble-close {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0,0,0,.3);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    opacity: 0;
    animation: ypa-bubble-in .3s ease 1.2s forwards;
}

.ypa-float-bubble-close:hover { background: rgba(0,0,0,.5); }

/* Oculta la burbuja cuando el panel está abierto */
.ypa-float-bubble--hidden { display: none !important; }

@keyframes ypa-bubble-in {
    from { opacity: 0; transform: scale(.7) translateX(10px); }
    to   { opacity: 1; transform: scale(1) translateX(0); }
}

/* ── Botón flotante — siempre visible, solo abre el panel ───────────────── */

.ypa-float-root .ypa-float-btn {
    width: 56px;
    height: 56px;
    border-radius: 50% 50% 8px 50% !important;
    background: var(--ypa-float-color, #334F9D) !important;
    border: none !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff !important;
    box-shadow: 0 4px 20px rgba(0,0,0,.22);
    transition: transform .2s ease, box-shadow .2s ease;
    outline: none !important;
    padding: 0 !important;
}

/* Para botón en la izquierda — la colita va al otro lado */
.ypa-float-root--left .ypa-float-btn {
    border-radius: 50% 50% 50% 8px !important;
}

.ypa-float-root .ypa-float-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(0,0,0,.28);
}

.ypa-float-root .ypa-float-btn:active { transform: scale(.96); }

/* ── Overlay detrás del drawer ───────────────────────────────────────────── */

.ypa-float-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 999997;
    animation: ypa-fade .2s ease;
}

.ypa-float-overlay--visible { display: block; }

@keyframes ypa-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Panel — drawer de altura completa (ambos contextos) ─────────────────── */

.ypa-float-panel {
    position: fixed;
    top: 0;
    bottom: 0;
    width: 380px;
    max-width: calc(100vw - 20px);
    overflow: hidden;
    z-index: 999998;
    animation: ypa-drawer-in .22s ease;
}

.ypa-float-root--right .ypa-float-panel {
    right: 0;
    box-shadow: -4px 0 32px rgba(0,0,0,.18);
}

.ypa-float-root--left .ypa-float-panel {
    left: 0;
    box-shadow: 4px 0 32px rgba(0,0,0,.18);
    animation-name: ypa-drawer-in-left;
}

/* Con admin bar de WordPress */
.admin-bar .ypa-float-panel { top: 32px; }

@media screen and (max-width: 782px) {
    .admin-bar .ypa-float-panel { top: 46px; }
}

@keyframes ypa-drawer-in {
    from { opacity: 0; transform: translateX(24px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes ypa-drawer-in-left {
    from { opacity: 0; transform: translateX(-24px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ── Wrap del chat dentro del drawer ─────────────────────────────────────── */

.ypa-float-panel .ypa-wrap {
    border: none;
    box-shadow: none;
    border-radius: 0;
    max-width: 100%;
    margin: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.ypa-float-panel .ypa-messages {
    flex: 1;
    min-height: 0;
    max-height: none;
}

.ypa-float-panel .ypa-header {
    background: var(--ypa-float-color, #334F9D);
    flex-shrink: 0;
}

/* Color dinámico en todos los elementos del chat */
.ypa-float-panel .ypa-send-btn {
    background: var(--ypa-float-color, #334F9D) !important;
}

.ypa-float-panel .ypa-msg--user .ypa-bubble {
    background: var(--ypa-float-color, #334F9D) !important;
}

.ypa-float-panel .ypa-msg--assistant .ypa-bubble {
    border-color: color-mix(in srgb, var(--ypa-float-color, #334F9D) 30%, #e0e4f0) !important;
}

.ypa-float-panel .ypa-input:focus {
    border-color: var(--ypa-float-color, #334F9D) !important;
}

/* Botón flotante — siempre circular */
.ypa-float-panel .ypa-input-area  { flex-shrink: 0; }
.ypa-float-panel .ypa-footer-note { flex-shrink: 0; }

/* ── Mobile ──────────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
    .ypa-float-root { bottom: 16px; }
    .ypa-float-root--right { right: 16px; }
    .ypa-float-root--left  { left:  16px; }
    .ypa-float-panel { width: 100vw; max-width: 100vw; }
    .ypa-float-root .ypa-float-btn {
        width: 62px;
        height: 62px;
    }
    .ypa-float-root .ypa-float-btn svg {
        width: 30px;
        height: 30px;
    }
}

/* ── Pantalla de Boot ─────────────────────────────────────────────────────── */

.ypa-boot-screen {
    position: absolute;
    inset: 0;
    background: #0d1117;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 28px;
    z-index: 10;
    padding: 32px 24px;
}

/* Robot SVG */
.ypa-boot-robot {
    position: relative;
}

.ypa-robot-svg {
    width: 130px;
    height: 150px;
    color: var(--ypa-float-color, #334F9D);
    filter: drop-shadow(0 0 12px var(--ypa-float-color, #334F9D));
}

/* Partes del robot aparecen una por una */
.ypa-robot-part { opacity: 0; }

.ypa-robot-antenna      { animation: ypa-part-in .4s ease .2s  forwards; }
.ypa-robot-antenna-dot  { animation: ypa-part-in .4s ease .4s  forwards; }
.ypa-robot-head         { animation: ypa-part-in .4s ease .6s  forwards; }
.ypa-robot-eye-left,
.ypa-robot-eye-right    { animation: ypa-part-in .4s ease .9s  forwards; }
.ypa-robot-mouth        { animation: ypa-part-in .4s ease 1.1s forwards; }
.ypa-robot-neck         { animation: ypa-part-in .3s ease 1.3s forwards; }
.ypa-robot-body         { animation: ypa-part-in .4s ease 1.5s forwards; }
.ypa-robot-chest        { animation: ypa-part-in .4s ease 1.7s forwards; }
.ypa-robot-arm-left,
.ypa-robot-arm-right    { animation: ypa-part-in .4s ease 1.9s forwards; }

/* Ojos se encienden */
.ypa-robot-eye-glow {
    animation: ypa-eye-glow .6s ease 2.2s forwards,
               ypa-eye-pulse 2s ease-in-out 3s infinite;
}
.ypa-robot-eye-glow--right {
    animation-delay: 2.4s, 3.2s;
}

/* Sonrisa pixel aparece */
.ypa-robot-mouth-dot {
    animation: ypa-part-in .3s ease 2.8s forwards;
}

/* Luces del pecho parpadean en secuencia y luego pulsan */
.ypa-robot-light--1 { animation: ypa-light-blink .4s ease 2.3s forwards, ypa-light-pulse 1.8s ease-in-out 4s infinite; }
.ypa-robot-light--2 { animation: ypa-light-blink .4s ease 2.6s forwards, ypa-light-pulse 1.8s ease-in-out 4.3s infinite; }
.ypa-robot-light--3 { animation: ypa-light-blink .4s ease 2.9s forwards, ypa-light-pulse 1.8s ease-in-out 4.6s infinite; }

/* Barra de carga se llena lento */
.ypa-robot-bar {
    animation: ypa-bar-fill 2.5s ease 1.8s forwards;
}

/* Lentes caen desde arriba */
.ypa-robot-glasses {
    transform: translateY(-30px);
    animation: ypa-glasses-drop .7s cubic-bezier(.34,1.56,.64,1) 2.2s forwards;
}

/* ── Animaciones idle — el robot vive durante los 10s ───────────────────── */

/* Antena pulsa suavemente */
.ypa-robot-antenna-dot {
    animation: ypa-part-in .4s ease .4s forwards,
               ypa-antenna-pulse 1.5s ease-in-out 3.5s infinite;
}

/* ── Texto de boot ────────────────────────────────────────────────────────── */

.ypa-boot-text-wrap {
    text-align: center;
    width: 100%;
}

.ypa-boot-label {
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    letter-spacing: .06em;
    margin-bottom: 18px;
    opacity: 0;
    animation: ypa-fade-up .5s ease .8s forwards;
    text-shadow: 0 0 20px var(--ypa-float-color, #334F9D);
}

.ypa-boot-lines {
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.ypa-boot-line {
    color: #4ade80;
    opacity: 0;
    text-align: left;
    padding: 4px 10px;
    border-left: 3px solid #4ade80;
    white-space: nowrap;
    letter-spacing: .03em;
}

/* 4 líneas distribuidas en ~9 segundos: 1.5s, 3.5s, 5.5s, 7.8s */
.ypa-boot-line[data-delay="0"] { animation: ypa-line-in .4s ease 1.5s forwards; }
.ypa-boot-line[data-delay="1"] { animation: ypa-line-in .4s ease 3.5s forwards; }
.ypa-boot-line[data-delay="2"] { animation: ypa-line-in .4s ease 5.5s forwards; }
.ypa-boot-line[data-delay="3"] { animation: ypa-line-in .4s ease 7.8s forwards; }

.ypa-boot-line--ready {
    color: #fff;
    border-color: var(--ypa-float-color, #334F9D);
    font-weight: 700;
    font-size: 14px;
    text-shadow: 0 0 10px var(--ypa-float-color, #334F9D);
}

/* Puntos animados ... */
.ypa-boot-dots::after {
    content: '';
    animation: ypa-dots 1s steps(3, end) infinite;
}

@keyframes ypa-dots {
    0%   { content: ''; }
    33%  { content: '.'; }
    66%  { content: '..'; }
    100% { content: '...'; }
}

/* ── Keyframes ───────────────────────────────────────────────────────────── */

@keyframes ypa-part-in {
    from { opacity: 0; transform: scale(.8); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes ypa-eye-glow {
    0%   { opacity: 0; }
    50%  { opacity: 1; }
    75%  { opacity: .4; }
    100% { opacity: .9; }
}

@keyframes ypa-eye-pulse {
    0%, 100% { opacity: .9; r: 4; }
    50%       { opacity: .4; r: 3; }
}

@keyframes ypa-light-blink {
    0%   { opacity: 0; }
    40%  { opacity: 1; }
    70%  { opacity: .3; }
    100% { opacity: .85; }
}

@keyframes ypa-light-pulse {
    0%, 100% { opacity: .85; }
    50%       { opacity: .2; }
}

@keyframes ypa-antenna-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: .5; transform: scale(1.3); }
}

@keyframes ypa-bar-fill {
    from { width: 0; }
    to   { width: 40px; }
}

@keyframes ypa-glasses-drop {
    from { opacity: 0; transform: translateY(-30px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes ypa-fade-up {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes ypa-line-in {
    from { opacity: 0; transform: translateX(-6px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* Transición de boot a chat */
.ypa-boot-screen--exit {
    animation: ypa-boot-exit .4s ease forwards;
}

@keyframes ypa-boot-exit {
    from { opacity: 1; transform: scale(1); }
    to   { opacity: 0; transform: scale(1.03); }
}
