/* ==============================================
   XN Contact Widget — Frontend
   Burbuja estilo XNSidebar: círculo blanco 42px
   ============================================== */

/* ── Contenedor principal ─────────────────────
   pointer-events:none → el contenedor NO bloquea
   clics cuando el panel está cerrado.
   ─────────────────────────────────────────────*/
#xncw-widget {
    position: fixed;
    z-index: 9991;                  /* 1 por encima de XNSidebar (9990) */
    pointer-events: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --xncw-label-color: #1f2937;
    transition: right 0.32s cubic-bezier(0.4, 0, 0.2, 1),
                left 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Cuando está cerrado, la burbuja sí que tiene pointer-events. El panel no. */
#xncw-widget.xncw-closed #xncw-panel {
        pointer-events: none !important;
        opacity: 0;
        transform: translateY(10px) scale(0.97);
        visibility: hidden;
}

#xncw-widget.xncw-right { right: 24px; bottom: 80px; }
#xncw-widget.xncw-left  { left:  24px; bottom: 80px; }

/* ── Burbuja — igual que XNSidebar ────────────*/
#xncw-bubble {
    pointer-events: auto;
    position: relative;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #ffffff;
    color: #374151;
    border: 1px solid #d1d5db;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
    transition: box-shadow 0.2s ease, transform 0.15s ease;
    outline: none;
    user-select: none;
}

#xncw-bubble:hover {
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
    transform: scale(1.06);
}

#xncw-bubble:active {
    transform: scale(0.93);
}

/* Estado abierto — fondo gris claro (igual que XNSidebar .xnv-open) */
#xncw-widget.xncw-open #xncw-bubble {
    background: #f3f4f6;
    border-color: #9ca3af;
}

/* Swap de icono al abrir */
#xncw-bubble .xncw-icon-main  { transition: opacity 0.18s ease, transform 0.18s ease; }
#xncw-bubble .xncw-icon-close {
    position: absolute;
    opacity: 0;
    transform: rotate(-45deg) scale(0.7);
    transition: opacity 0.18s ease, transform 0.18s ease;
    font-size: 13px;
}

#xncw-widget.xncw-open #xncw-bubble .xncw-icon-main  { opacity: 0; transform: rotate(45deg) scale(0.7); }
#xncw-widget.xncw-open #xncw-bubble .xncw-icon-close { opacity: 1; transform: rotate(0deg) scale(1); }

/* ── Badge de mensajes no leídos ───────────── */
#xncw-badge {
    display: none;
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    background: #ef4444;
    color: #fff;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    pointer-events: none;
    z-index: 1;
}

#xncw-badge.xncw-badge-visible {
    display: flex;
}

/* ── Panel de opciones ────────────────────────*/
#xncw-panel {
    position: absolute;
    bottom: calc(42px + 10px);
    width: 260px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.14), 0 2px 6px rgba(0, 0, 0, 0.06);
    border: 1px solid #e5e7eb;
    overflow: hidden;

    pointer-events: none;
    opacity: 0;
    transform: translateY(10px) scale(0.97);
    transform-origin: bottom right;
    transition: opacity 0.2s ease, transform 0.22s cubic-bezier(0.34, 1.3, 0.64, 1);
}

#xncw-widget.xncw-right #xncw-panel { right: 0; transform-origin: bottom right; }
#xncw-widget.xncw-left  #xncw-panel { left:  0; transform-origin: bottom left; }

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

/* ── Opciones dentro del panel ──────────────── */
.xncw-option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 12px 14px;
    cursor: pointer;
    text-decoration: none;
    text-align: left;
    color: var(--xncw-label-color, #1f2937) !important;
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    transition: background 0.13s ease;
    border: none;
    border-radius: 0;
    border-bottom: 1px solid #f3f4f6;
    appearance: none;
    -webkit-appearance: none;
}

.xncw-option:last-child { border-bottom: none; }
.xncw-option:hover      { background: #f9fafb; }
.xncw-option:active     { background: #f3f4f6; }

.xncw-opt-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    transition: background 0.13s, transform 0.13s;
}

.xncw-option:hover .xncw-opt-icon {
    background: #eef2ff;
    transform: scale(1.08);
}

/* Defensa: chat/asistente son <button>. Hexa pinta button:hover con
   fondo/redondeo propios; además el UA no estira <button> al 100%
   (sí lo hace <a>), por eso el hover salía “píldora” en los 2 primeros. */
#xncw-panel .xncw-option,
#xncw-panel button.xncw-option {
    width: 100%;
    max-width: none;
    box-sizing: border-box;
    margin: 0;
    border-radius: 0;
    box-shadow: none !important;
    text-shadow: none !important;
    color: var(--xncw-label-color, #1f2937) !important;
}
#xncw-panel .xncw-option,
#xncw-panel .xncw-option:focus {
    background-color: transparent !important;
}
#xncw-panel .xncw-option:hover {
    background: #f9fafb !important;
    background-color: #f9fafb !important;
}
#xncw-panel .xncw-option:active {
    background: #f3f4f6 !important;
    background-color: #f3f4f6 !important;
}
#xncw-panel .xncw-option:hover .xncw-opt-icon { background: #eef2ff; }
/* El <i> sigue el color inline del span (.xncw-opt-icon), no el color del button */
#xncw-panel .xncw-option .xncw-opt-icon i { color: inherit; }

/* ==============================================
   Punto "online" en la burbuja (color dinámico)
   ============================================== */
#xncw-bubble .xncw-dot {
    position: absolute;
    top: -1px;
    right: 3px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid #fff;
    pointer-events: none;
}

/* ==============================================
   Burbujas teaser (mensajes que incitan al click)
   ============================================== */
.xncw-teaser {
    position: fixed;
    z-index: 9992;
    width: 230px;
    max-width: calc(100vw - 32px);
    background: #fff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px 30px 10px 13px;
    font-size: 13px;
    line-height: 1.4;
    font-weight: 500;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .16);
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .25s ease, transform .25s ease,
                right 0.32s cubic-bezier(0.4, 0, 0.2, 1),
                left 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    pointer-events: none;
    z-index: 1;
}
.xncw-teaser.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
/* Piquito que apunta a la burbuja (cuadrito rotado 45°, como el del asistente) */
.xncw-teaser::after {
    content: '';
    position: absolute;
    width: 11px;
    height: 11px;
    background: #fff;
    border-right: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
    transform: rotate(45deg);
    bottom: -6px;
}
.xncw-teaser-right { right: 0; }
.xncw-teaser-left  { left: 0; }
.xncw-teaser-right::after { right: 16px; }
.xncw-teaser-left::after  { left: 16px; }
.xncw-teaser-txt { display: block; }
.xncw-teaser-x {
    position: absolute;
    top: 5px;
    right: 7px;
    background: none;
    border: 0;
    font-size: 16px;
    line-height: 1;
    color: #9ca3af;
    cursor: pointer;
    padding: 2px 4px;
}
.xncw-teaser-x:hover { color: #4b5563; }

.xncw-opt-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.xncw-opt-arrow {
    font-size: 10px;
    color: #d1d5db;
    flex-shrink: 0;
    transition: transform 0.13s, color 0.13s;
}

.xncw-option:hover .xncw-opt-arrow {
    transform: translateX(3px);
    color: #9ca3af;
}

/* Resets para botones — width/radius ya en .xncw-option; mantener alias */
button.xncw-option {
    border: none;
    background: transparent;
    cursor: pointer;
}

/* Badge visible/hidden states */
#xncw-badge.xncw-show {
    display: flex;
}

/* ── Dark mode (hx-ds / shell navy) ───────────────
   Labels/icons often come from admin as dark ink (#1f2937 / #6b7280)
   via inline --xncw-label-color and style="color:…". Those beat stylesheet
   variables, so dark rules set color directly with !important. */
html.dark #xncw-widget {
    --xncw-label-color: #e8edf4;
}

html.dark #xncw-bubble {
    background: #1c212b;
    color: #c5ced8;
    border-color: #3a4454;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
}

html.dark #xncw-widget.xncw-open #xncw-bubble {
    background: #252b36;
    border-color: #4a5568;
}

html.dark #xncw-badge {
    border-color: #1c212b;
}

html.dark #xncw-bubble .xncw-dot {
    border-color: #1c212b;
}

html.dark #xncw-panel {
    background: #1c212b;
    border-color: #2a3140;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
}

html.dark .xncw-option {
    border-bottom-color: #2a3140;
}

html.dark .xncw-option:hover {
    background: rgba(255, 255, 255, 0.05);
}

html.dark .xncw-option:active {
    background: rgba(255, 255, 255, 0.08);
}

html.dark .xncw-opt-icon {
    background: #252b36;
}

/* Do NOT use var(--xncw-label-color) here — inline admin color wins and stays dark. */
html.dark #xncw-panel .xncw-option,
html.dark #xncw-panel .xncw-option:hover,
html.dark #xncw-panel .xncw-option:focus,
html.dark #xncw-panel .xncw-option:active,
html.dark #xncw-panel .xncw-option .xncw-opt-label {
    color: #e8edf4 !important;
}

html.dark #xncw-panel .xncw-option:hover {
    background: rgba(255, 255, 255, 0.05) !important;
}

html.dark #xncw-panel .xncw-option:active {
    background: rgba(255, 255, 255, 0.08) !important;
}

html.dark #xncw-panel .xncw-option:hover .xncw-opt-icon {
    background: rgba(77, 154, 224, 0.16);
}

/* Muted/default icon grays (inline) → readable on navy; brand greens/blues keep inline color */
html.dark #xncw-panel .xncw-opt-icon.xncw-opt-icon--muted,
html.dark #xncw-panel .xncw-opt-icon.xncw-opt-icon--muted i {
    color: #9aa8b8 !important;
}

html.dark #xncw-panel .xncw-opt-arrow {
    color: #7a8799 !important;
}

html.dark #xncw-panel .xncw-option:hover .xncw-opt-arrow {
    color: #c5ced8 !important;
}

html.dark .xncw-teaser {
    background: #1c212b;
    color: #e8edf4 !important;
    border-color: #2a3140;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

html.dark .xncw-teaser::after {
    background: #1c212b;
    border-right-color: #2a3140;
    border-bottom-color: #2a3140;
}

html.dark .xncw-teaser-x {
    color: #7a8799;
}

html.dark .xncw-teaser-x:hover {
    color: #c5ced8;
}
