/*
 * FloatChat Public Widget Styles
 * Temas: classic, bubble, card, minimal
 * =====================================================
 */

/* ── Variables y base ──────────────────────────────── */
#floatchat-widget {
    --fc-mx: 20px;
    --fc-my: 20px;
    --fc-btn: #25D366;
    --fc-btn-size: 60px;
    --fc-radius: 50%;
    --fc-shadow: 0 4px 20px rgba(0, 0, 0, 0.22);
    --fc-transition: 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    --fc-z: 99999;

    position: fixed;
    z-index: var(--fc-z);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    box-sizing: border-box;
}

#floatchat-widget *,
#floatchat-widget *::before,
#floatchat-widget *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ── Posiciones ─────────────────────────────────────── */
#floatchat-widget.fc-pos-bottom-right {
    right: var(--fc-mx);
    bottom: var(--fc-my);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

#floatchat-widget.fc-pos-bottom-left {
    left: var(--fc-mx);
    bottom: var(--fc-my);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

/* ── Visibilidad con delay ──────────────────────────── */
#floatchat-widget.fc-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}
#floatchat-widget.fc-visible {
    opacity: 1;
    pointer-events: all;
    transform: scale(1);
    transition: opacity 0.4s ease, transform 0.4s var(--fc-transition);
}

/* ══════════════════════════════════════════════════════
   BOTÓN TOGGLE (común a todos los temas)
   ══════════════════════════════════════════════════════ */
.floatchat-toggle {
    width: var(--fc-btn-size);
    height: var(--fc-btn-size);
    border-radius: var(--fc-radius);
    background: var(--fc-btn, #25D366);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--fc-shadow);
    position: relative;
    z-index: 2;
    color: #fff;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    flex-shrink: 0;
    outline: none;
}
.floatchat-toggle:focus-visible {
    box-shadow: var(--fc-shadow), 0 0 0 3px rgba(255,255,255,0.6);
}
.floatchat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.3);
}
.floatchat-toggle:active { transform: scale(0.96); }

/* Íconos del toggle (open / close) */
.fc-icon-chat,
.fc-icon-close {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease, transform 0.3s var(--fc-transition);
}
.fc-icon-close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.6);
}
.fc-icon-chat {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}
/* Cuando está abierto: intercambiar iconos */
#floatchat-widget.fc-open .fc-icon-chat {
    opacity: 0;
    transform: rotate(90deg) scale(0.6);
}
#floatchat-widget.fc-open .fc-icon-close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* ══════════════════════════════════════════════════════
   MENÚ DE CANALES (Classic + Bubble + Minimal)
   ══════════════════════════════════════════════════════ */
.floatchat-menu {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
    order: -1;
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px);
    transition: opacity 0.22s ease, transform 0.28s var(--fc-transition);
}
#floatchat-widget.fc-open .floatchat-menu {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}

/* Animación escalonada para cada canal */
.floatchat-channel:nth-child(1) { transition-delay: 0ms; }
.floatchat-channel:nth-child(2) { transition-delay: 40ms; }
.floatchat-channel:nth-child(3) { transition-delay: 80ms; }

/* ── Canal base ─────────────────────────────────────── */
.floatchat-channel {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #333;
    border-radius: 40px;
    background: #fff;
    padding: 9px 16px 9px 10px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.13);
    white-space: nowrap;
    font-weight: 600;
    font-size: 13px;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.floatchat-channel:hover {
    transform: translateX(-3px);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
}
/* Alineación izquierda: hover al otro lado */
.fc-pos-bottom-left .floatchat-channel:hover {
    transform: translateX(3px);
}

.fc-ch-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--fc-ch-color, #25D366);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
}
.fc-ch-label { flex: 1; }

/* ══════════════════════════════════════════════════════
   TEMA: CLASSIC
   ══════════════════════════════════════════════════════ */
/* Classic usa los estilos base sin modificaciones adicionales */

/* ══════════════════════════════════════════════════════
   TEMA: BUBBLE
   ══════════════════════════════════════════════════════ */

/* Pulse rings */
#floatchat-widget.fc-theme-bubble .fc-pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--fc-btn, #25D366);
    opacity: 0;
    animation: fc-pulse-ring 2.2s ease-out infinite;
    pointer-events: none;
}
#floatchat-widget.fc-theme-bubble .fc-pulse-2 {
    animation-delay: 0.7s;
}
@keyframes fc-pulse-ring {
    0%   { transform: scale(1); opacity: 0.55; }
    80%  { transform: scale(1.7); opacity: 0; }
    100% { transform: scale(1.7); opacity: 0; }
}

/* Stop pulse when open */
#floatchat-widget.fc-theme-bubble.fc-open .fc-pulse {
    animation: none;
    opacity: 0;
}

/* Tooltip */
#floatchat-widget.fc-theme-bubble .fc-tooltip {
    background: #fff;
    color: #333;
    font-size: 13px;
    font-weight: 600;
    padding: 7px 14px;
    border-radius: 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.14);
    white-space: nowrap;
    margin-bottom: 10px;
    order: 1;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.2s ease, transform 0.2s ease;
    position: relative;
}
/* Arrow de tooltip */
#floatchat-widget.fc-theme-bubble.fc-pos-bottom-right .fc-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 20px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid #fff;
}
#floatchat-widget.fc-theme-bubble.fc-pos-bottom-left .fc-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid #fff;
}
/* Ocultar tooltip cuando está abierto */
#floatchat-widget.fc-theme-bubble.fc-open .fc-tooltip {
    opacity: 0;
    transform: translateY(4px);
    pointer-events: none;
}

/* ══════════════════════════════════════════════════════
   TEMA: CARD
   ══════════════════════════════════════════════════════ */

/* Ocultar menú clásico en tema card */
#floatchat-widget.fc-theme-card .floatchat-menu {
    display: none;
}

/* Card widget */
#floatchat-widget.fc-theme-card .floatchat-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    width: 300px;
    overflow: hidden;
    margin-bottom: 14px;
    order: -1;

    opacity: 0;
    pointer-events: none;
    transform: translateY(16px) scale(0.95);
    transform-origin: bottom right;
    transition: opacity 0.28s ease, transform 0.32s var(--fc-transition);
}
#floatchat-widget.fc-theme-card.fc-pos-bottom-left .floatchat-card {
    transform-origin: bottom left;
}
#floatchat-widget.fc-theme-card.fc-open .floatchat-card {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0) scale(1);
}

.fc-card-header {
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.fc-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    font-weight: 700;
    font-size: 15px;
}
.fc-card-close {
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: background 0.2s;
    flex-shrink: 0;
}
.fc-card-close:hover { background: rgba(255,255,255,0.35); }

.fc-card-body { padding: 16px 18px; }
.fc-card-subtitle {
    font-size: 12px;
    color: #888;
    margin-bottom: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.fc-card-channels {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.fc-card-channel {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 10px;
    text-decoration: none;
    color: #333;
    border: 1px solid #f0f0f0;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.18s ease, border-color 0.18s ease;
}
.fc-card-channel:hover {
    background: #f8f8f8;
    border-color: var(--fc-ch-color, #25D366);
}
.fc-card-ch-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
}
.fc-card-ch-label { flex: 1; }
.fc-card-ch-arrow {
    color: #bbb;
    flex-shrink: 0;
    transition: transform 0.18s ease, color 0.18s ease;
}
.fc-card-channel:hover .fc-card-ch-arrow {
    transform: translateX(3px);
    color: var(--fc-ch-color, #25D366);
}

/* ══════════════════════════════════════════════════════
   TEMA: MINIMAL
   ══════════════════════════════════════════════════════ */

#floatchat-widget.fc-theme-minimal {
    --fc-btn-size: 50px;
}

/* Ocultar labels en minimal */
#floatchat-widget.fc-theme-minimal .fc-ch-label,
#floatchat-widget.fc-theme-minimal .floatchat-menu {
    /* Se sobreescribe inline */
}

#floatchat-widget.fc-theme-minimal .floatchat-menu {
    gap: 8px;
    margin-bottom: 10px;
}

#floatchat-widget.fc-theme-minimal .floatchat-channel {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    padding: 0;
    justify-content: center;
    background: var(--fc-ch-color, #25D366);
    box-shadow: 0 2px 10px rgba(0,0,0,0.18);
    position: relative;
    overflow: visible;
}
#floatchat-widget.fc-theme-minimal .floatchat-channel:hover {
    transform: scale(1.12);
}
#floatchat-widget.fc-theme-minimal .fc-ch-icon {
    background: transparent;
    width: auto;
    height: auto;
    color: #fff;
}
#floatchat-widget.fc-theme-minimal .fc-ch-label {
    display: none;
}

/* Tooltip on hover for minimal */
#floatchat-widget.fc-theme-minimal .floatchat-channel::after {
    content: attr(aria-label);
    position: absolute;
    right: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.75);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
#floatchat-widget.fc-theme-minimal .floatchat-channel:hover::after {
    opacity: 1;
}
#floatchat-widget.fc-theme-minimal.fc-pos-bottom-left .floatchat-channel::after {
    right: auto;
    left: calc(100% + 10px);
}

/* Toggle minimal overrides */
#floatchat-widget.fc-theme-minimal .floatchat-toggle {
    --fc-btn-size: 50px;
}

/* ── Ocultar elementos de otros temas ───────────────── */
/* El tooltip solo se usa en bubble */
.fc-tooltip { display: none; }
#floatchat-widget.fc-theme-bubble .fc-tooltip { display: block; }

/* La card solo se usa en card theme */
.floatchat-card { display: none; }
#floatchat-widget.fc-theme-card .floatchat-card { display: block; }

/* Los pulse rings solo en bubble */
.fc-pulse { display: none; }
#floatchat-widget.fc-theme-bubble .fc-pulse { display: block; }

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 480px) {
    #floatchat-widget {
        --fc-mx: 14px;
        --fc-my: 14px;
    }
    #floatchat-widget.fc-theme-card .floatchat-card {
        width: calc(100vw - 28px);
        max-width: 300px;
    }
    .floatchat-channel {
        padding: 8px 14px 8px 8px;
    }
}

/* ── Reduced motion ─────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    #floatchat-widget.fc-theme-bubble .fc-pulse {
        animation: none;
    }
    .floatchat-toggle,
    .floatchat-menu,
    .floatchat-card,
    .fc-icon-chat,
    .fc-icon-close {
        transition: none;
    }
}