/* ============================================================
   Xabia Agent — interfaz nativa (avatar oficial + panel)
   ============================================================ */

/* --- Telón / desenfoque --- */
.xabia-blur-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.2);
    backdrop-filter: blur(0);
    -webkit-backdrop-filter: blur(0);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.4s ease, visibility 0.4s ease, backdrop-filter 0.4s ease;
    z-index: 99980;
}

body.xabia-open .xabia-blur-overlay.is-active,
body.xabia-open .xabia-blur-overlay:not([hidden]) {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* --- Contenedor disparador (sticky footer box) --- */
.xabia-sticky-footer-box,
#sticky-footer-box {
    position: fixed;
    width: 130px;
    height: 130px;
    left: auto;
    right: 30px;
    bottom: 20px;
    z-index: 99990;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    pointer-events: none;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    transition: transform 0.48s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.32s ease;
}

body.xabia-open .xabia-sticky-footer-box {
    z-index: 99996;
}

.xabia-sticky-footer-box.xabia-trigger--bottom-left {
    left: 30px;
    right: auto;
}

.xabia-sticky-footer-box.xabia-trigger--bottom-right {
    left: auto;
    right: 30px;
}

.xabia-sticky-footer-box.xabia-trigger--custom {
    left: auto;
    right: auto;
    width: 130px;
    height: 130px;
    padding: 0;
}

.xabia-sticky-footer-box.footer-hidden {
    transform: translateY(135%) scale(0.96);
    opacity: 0;
}

.xabia-sticky-footer-box.footer-hidden .xabia-interface-trigger {
    pointer-events: none;
}

.xabia-sticky-footer-box.is-anchored {
    position: fixed;
    bottom: 20px;
    left: auto;
    right: 30px;
    width: 130px;
    height: 130px;
    max-width: 130px;
    padding: 0;
    transform: translateY(0);
    opacity: 1;
}

.xabia-sticky-footer-box.xabia-trigger--bottom-left.is-anchored {
    left: 30px;
    right: auto;
}

.xabia-sticky-footer-box .xabia-interface-trigger {
    pointer-events: auto;
}

/* --- Botón / trigger (sin borde rojo del tema) --- */
.xabia-interface-trigger {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 125px;
    height: 125px;
    isolation: isolate;
    border: none !important;
    padding: 0;
    margin: 0;
    background: transparent !important;
    cursor: pointer;
    line-height: 0;
    filter: none !important;
    -webkit-tap-highlight-color: transparent;
    box-shadow: none !important;
    outline: none !important;
    border-radius: 999px;
    overflow: visible !important;
    appearance: none;
    -webkit-appearance: none;
    transition: transform 0.25s ease;
}

.xabia-interface-trigger::before {
    content: '';
    position: absolute;
    inset: -16px;
    z-index: 0;
    border-radius: 999px;
    background:
        radial-gradient(circle at 58% 42%,
            color-mix(in srgb, var(--xabia-avatar-bg, #99ccff) 50%, #ffffff) 0%,
            color-mix(in srgb, var(--xabia-avatar-bg, #99ccff) 32%, transparent) 36%,
            color-mix(in srgb, var(--xabia-dots-color, #ff9966) 22%, transparent) 62%,
            transparent 76%);
    filter: blur(10px);
    opacity: 0;
    transform: scale(0.82);
    pointer-events: none;
    transition: opacity 0.28s ease, transform 0.28s ease;
}

.xabia-interface-trigger:hover,
.xabia-interface-trigger:focus,
.xabia-interface-trigger:focus-visible,
.xabia-interface-trigger:active {
    transform: scale(1.03);
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.xabia-interface-trigger:hover::before,
.xabia-interface-trigger:focus-visible::before {
    opacity: 0.95;
    transform: scale(1);
}

.xabia-interface-trigger.is-active {
    transform: scale(0.97);
}

.xabia-trigger-custom-img {
    display: block;
    width: 125px;
    height: 125px;
    object-fit: contain;
}

/* --- Avatar cinético (capas oficiales) --- */
.xabia-kinetic-wrapper {
    width: 125px;
    height: 125px;
    margin: 0;
    position: relative;
    z-index: 1;
    overflow: visible;
    pointer-events: none;
}

.x-avatar-container {
    width: 125px;
    height: 125px;
    position: relative;
    margin: 0;
    perspective: 1000px;
    transform-style: preserve-3d;
    overflow: visible;
}

.x-avatar-stage {
    position: absolute;
    display: block;
    top: 0;
    left: -37.13px;
    width: 162.14px;
    height: 125px;
    overflow: visible;
    opacity: 1;
    visibility: visible;
    pointer-events: none;
}

.x-avatar-head-layer,
.x-avatar-sockets-layer,
.x-avatar-eyes-layer {
    transform-style: preserve-3d;
    will-change: transform;
}

.x-avatar-head-layer {
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.02));
}

.x-avatar-sockets-layer {
    filter: drop-shadow(0 4px 9px rgba(15, 23, 42, 0.05));
}

.x-avatar-eyes-layer {
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.05));
}

.x-avatar-fill-bg {
    fill: var(--xabia-avatar-bg, #99ccff);
}

.x-avatar-fill-socket {
    fill: #ffffff;
}

.x-avatar-fill-dot {
    fill: var(--xabia-dots-color, #ff9966);
}

.x-avatar-fill-secondary {
    fill: color-mix(in srgb, var(--xabia-dots-color, #ff9966) 18%, #ccb3b3);
}

/* --- Panel de chat (shell) --- */
@property --xabia-halo-angle {
    syntax: '<angle>';
    inherits: false;
    initial-value: 0deg;
}

.xabia-chatbox.xabia-panel-shell {
    display: none !important;
    position: fixed;
    z-index: 9999995;
    flex-direction: column !important;
    min-height: 0;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    --xabia-halo-angle: 0deg;
    background:
        linear-gradient(#ffffff, #ffffff) padding-box,
        conic-gradient(
            from var(--xabia-halo-angle),
            transparent 0deg,
            transparent 235deg,
            color-mix(in srgb, var(--xabia-accent, #2271b1) 10%, transparent) 265deg,
            color-mix(in srgb, var(--xabia-accent, #2271b1) 85%, #ffffff) 292deg,
            color-mix(in srgb, var(--xabia-accent, #2271b1) 55%, #c2185b) 318deg,
            transparent 350deg,
            transparent 360deg
        ) border-box !important;
    border: 12px solid transparent !important;
    border-radius: 28px;
    box-shadow:
        0 4px 6px rgba(0, 0, 0, 0.04),
        0 24px 64px rgba(0, 0, 0, 0.14),
        0 0 36px color-mix(in srgb, var(--xabia-accent, #2271b1) 22%, transparent),
        0 0 0 1px rgba(255, 255, 255, 0.6) inset;
    overflow: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease, transform 0.4s ease, box-shadow 0.4s ease;
    visibility: hidden;
    opacity: 0;
    filter: none !important;
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
}

.xabia-chatbox.xabia-panel-shell.is-active {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 99995 !important;
    pointer-events: auto !important;
    animation: xabiaPanelHalo 3.6s linear infinite;
}

@keyframes xabiaPanelHalo {
    to {
        --xabia-halo-angle: 360deg;
    }
}

body.xabia-open .xabia-chatbox.xabia-panel-shell.is-active {
    z-index: 99995 !important;
}

.xabia-chatbox.xabia-panel-shell.is-active .xabia-input-area,
.xabia-chatbox.xabia-panel-shell.is-active .xabia-input-area * {
    pointer-events: auto !important;
}

.xabia-chatbox.xabia-panel-shell .xabia-chat-history {
    flex: 1 1 auto;
    min-height: 0;
    padding: 22px 24px 18px !important;
    background: linear-gradient(180deg, #f9fafb 0%, #ffffff 48px) !important;
}

.xabia-chatbox.xabia-panel-shell .xabia-chat-history .xabia-msg.bot:first-child {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    max-width: 100% !important;
    font-size: 1.02em;
    line-height: 1.55;
}

.xabia-chatbox.xabia-panel-shell .xabia-input-area,
.xabia-chatbox.xabia-panel-shell .xabia-powered-by {
    flex-shrink: 0;
    background: #fff !important;
}

.xabia-panel-close {
    display: none !important;
}

/* Fila de entrada: mic | campo | mute+send (como referencia Mirentxu) */
.xabia-chatbox.xabia-panel-shell .xabia-input-area {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 14px 20px 10px !important;
    border-top: 1px solid rgba(0, 0, 0, 0.06) !important;
    background: #fff !important;
    box-sizing: border-box;
}

.xabia-chatbox.xabia-panel-shell .xabia-input-field {
    display: block !important;
    flex: 1 1 0% !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    min-height: 44px !important;
    max-height: 120px !important;
    margin: 0 !important;
    border: 1px solid #d2d2d7 !important;
    border-radius: 22px !important;
    padding: 11px 18px !important;
    resize: none !important;
    box-sizing: border-box;
    font-size: 15px;
    line-height: 1.4;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.xabia-chatbox.xabia-panel-shell .xabia-input-field:focus {
    outline: none !important;
    border-color: var(--xabia-accent, #2271b1) !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--xabia-accent, #2271b1) 22%, transparent) !important;
}

.xabia-chatbox.xabia-panel-shell .xabia-input-actions {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 4px !important;
    flex: 0 0 auto !important;
    flex-shrink: 0 !important;
}

.xabia-chatbox.xabia-panel-shell .xabia-input-area .xabia-btn-icon,
.xabia-chatbox.xabia-panel-shell .xabia-input-actions .xabia-btn-icon {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 40px !important;
    height: 40px !important;
    flex: 0 0 40px !important;
    margin: 0 !important;
    float: none !important;
    font-size: 22px !important;
    line-height: 1 !important;
    color: #86868b !important;
    cursor: pointer;
    border-radius: 50%;
    user-select: none;
    transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.xabia-chatbox.xabia-panel-shell .xabia-btn-icon .xabia-icon-svg {
    display: block !important;
    width: 22px !important;
    height: 22px !important;
    color: currentColor !important;
    fill: currentColor !important;
}

.xabia-chatbox.xabia-panel-shell .xabia-btn-icon .xabia-icon-svg path {
    fill: currentColor !important;
}

.xabia-chatbox.xabia-panel-shell .xabia-btn-icon.xabia-mute .xabia-icon-vol-on {
    display: none !important;
}

.xabia-chatbox.xabia-panel-shell .xabia-btn-icon.xabia-mute.is-voice-on .xabia-icon-vol-off {
    display: none !important;
}

.xabia-chatbox.xabia-panel-shell .xabia-btn-icon.xabia-mute.is-voice-on .xabia-icon-vol-on {
    display: block !important;
}

.xabia-chatbox.xabia-panel-shell .xabia-btn-icon.xabia-mute:not(.is-voice-on) {
    color: #fff !important;
    background: #e53935 !important;
}

.xabia-chatbox.xabia-panel-shell .xabia-btn-icon.xabia-send:hover,
.xabia-chatbox.xabia-panel-shell .xabia-btn-icon.xabia-send:focus-visible {
    color: #fff !important;
    background: var(--xabia-accent, #2271b1) !important;
}

.xabia-chatbox.xabia-panel-shell .xabia-btn-icon.xabia-mute.is-voice-on {
    color: #fff !important;
    background: var(--xabia-accent, #2271b1) !important;
}

.xabia-chatbox.xabia-panel-shell .xabia-btn-icon.xabia-mic.xabia-mic-listening {
    color: #fff !important;
    background: #e53935 !important;
}


.xabia-chatbox.xabia-panel-shell .xabia-powered-by {
    padding: 6px 20px 16px !important;
    text-align: center !important;
    background: #fff !important;
}

.xabia-chatbox.xabia-panel-shell .xabia-powered-by a {
    color: #9a9aa0 !important;
    text-decoration: none !important;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 10px;
}

.xabia-chatbox.xabia-panel-shell .xabia-powered-by a:hover {
    color: #7a7a82 !important;
}

/* Flotante lateral */
.xabia-chatbox.xabia-panel-shell.layout-right-float {
    right: 24px;
    bottom: 100px;
    left: auto;
    top: auto;
    transform: none;
    width: min(380px, calc(100vw - 48px));
    max-height: min(80vh, 640px);
    height: min(560px, 80vh);
}

.xabia-chatbox.xabia-panel-shell.layout-right-float.is-active {
    animation:
        xabiaPanelIn 0.35s cubic-bezier(0.25, 1, 0.5, 1),
        xabiaPanelHalo 3.6s linear infinite;
}

.xabia-chatbox.xabia-panel-shell.layout-left-float {
    left: 24px;
    bottom: 100px;
    right: auto;
    top: auto;
    transform: none;
    width: min(380px, calc(100vw - 48px));
    max-height: min(80vh, 640px);
    height: min(560px, 80vh);
}

.xabia-chatbox.xabia-panel-shell.layout-left-float.is-active {
    animation:
        xabiaPanelIn 0.35s cubic-bezier(0.25, 1, 0.5, 1),
        xabiaPanelHalo 3.6s linear infinite;
}

@keyframes xabiaPanelIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Modal centrado + pantalla completa = caja blanca centrada con margen (no edge-to-edge) */
.xabia-chatbox.xabia-panel-shell.layout-centered-modal,
.xabia-chatbox.xabia-panel-shell.layout-full-screen {
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translate(-50%, -50%) !important;
    width: min(440px, calc(100vw - 48px)) !important;
    max-width: min(440px, calc(100vw - 48px)) !important;
    height: min(600px, calc(100vh - 80px)) !important;
    max-height: min(85vh, 680px) !important;
    margin: 0;
}

.xabia-chatbox.xabia-panel-shell.layout-full-screen {
    width: min(520px, calc(100vw - 56px)) !important;
    max-width: min(520px, calc(100vw - 56px)) !important;
    height: min(720px, calc(100vh - 72px)) !important;
    max-height: min(90vh, 760px) !important;
}

.xabia-chatbox.xabia-panel-shell.layout-centered-modal.is-active,
.xabia-chatbox.xabia-panel-shell.layout-full-screen.is-active {
    animation:
        xabiaPanelModalIn 0.35s cubic-bezier(0.25, 1, 0.5, 1),
        xabiaPanelHalo 3.6s linear infinite;
}

@keyframes xabiaPanelModalIn {
    from {
        opacity: 0;
        transform: translate(-50%, -46%) scale(0.96) !important;
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1) !important;
    }
}

body.xabia-native-interface .xabia-chatbox.xabia-panel-shell:not(.is-active) {
    visibility: hidden;
    pointer-events: none;
}

@media (max-width: 640px) {
    .xabia-chatbox.xabia-panel-shell.layout-right-float,
    .xabia-chatbox.xabia-panel-shell.layout-left-float,
    .xabia-chatbox.xabia-panel-shell.layout-centered-modal,
    .xabia-chatbox.xabia-panel-shell.layout-full-screen {
        width: calc(100vw - 24px) !important;
        max-width: calc(100vw - 24px) !important;
        height: calc(100vh - 48px) !important;
        max-height: calc(100vh - 48px) !important;
    }

    .xabia-sticky-footer-box {
        right: 18px;
        bottom: 16px;
    }

    .xabia-sticky-footer-box.xabia-trigger--bottom-left {
        left: 18px;
        right: auto;
    }
}
