/* ── WP Chatbot AI – Widget Styles ────────────────────────────────────────── */
/* Variables definidas inline desde PHP con el color del admin */

/* Contenedor principal */
.wpcb-widget {
    position: fixed;
    bottom: 24px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.wpcb-right { right: 24px; }
.wpcb-left  { left: 24px; }

/* ── Botón flotante ──────────────────────────────────────────────────────── */
.wpcb-toggle-btn {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--wpcb-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0,0,0,.25);
    transition: transform .2s ease, box-shadow .2s ease;
    color: #fff;
    position: relative;
    z-index: 1;
}

.wpcb-toggle-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(0,0,0,.35);
}

.wpcb-toggle-btn svg {
    width: 26px;
    height: 26px;
    transition: opacity .2s, transform .2s;
    position: absolute;
}

.wpcb-icon-open  { opacity: 1; transform: rotate(0deg); }
.wpcb-icon-close { opacity: 0; transform: rotate(90deg); }

.wpcb-widget:not(.wpcb-closed) .wpcb-icon-open  { opacity: 0; transform: rotate(-90deg); }
.wpcb-widget:not(.wpcb-closed) .wpcb-icon-close { opacity: 1; transform: rotate(0deg); }

/* Pulso de notificación (se activa con JS si hay mensaje nuevo) */
.wpcb-toggle-btn::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    background: #22c55e;
    border-radius: 50%;
    top: 4px;
    right: 4px;
    border: 2px solid #fff;
    display: none;
}

.wpcb-widget.wpcb-has-notification .wpcb-toggle-btn::after {
    display: block;
    animation: wpcb-pulse 1.5s infinite;
}

@keyframes wpcb-pulse {
    0%   { transform: scale(1); opacity: 1; }
    50%  { transform: scale(1.4); opacity: .6; }
    100% { transform: scale(1); opacity: 1; }
}

/* ── Ventana del chat ────────────────────────────────────────────────────── */
.wpcb-chat-window {
    position: absolute;
    bottom: 72px;
    width: 360px;
    max-height: 540px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(.96);
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease;
}

.wpcb-right .wpcb-chat-window { right: 0; }
.wpcb-left  .wpcb-chat-window { left: 0; }

.wpcb-widget:not(.wpcb-closed) .wpcb-chat-window {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.wpcb-header {
    background: var(--wpcb-primary);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.wpcb-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.wpcb-avatar {
    font-size: 1.6rem;
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wpcb-bot-name {
    font-weight: 700;
    font-size: .95rem;
    line-height: 1.2;
}

.wpcb-status-indicator {
    font-size: .75rem;
    opacity: .85;
    display: flex;
    align-items: center;
    gap: 5px;
}

.wpcb-dot {
    width: 7px;
    height: 7px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
}

.wpcb-close-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: rgba(255,255,255,.8);
    padding: 4px;
    border-radius: 6px;
    display: flex;
    transition: color .15s, background .15s;
}

.wpcb-close-btn:hover {
    color: #fff;
    background: rgba(255,255,255,.15);
}

/* ── Mensajes ─────────────────────────────────────────────────────────────── */
.wpcb-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.wpcb-messages::-webkit-scrollbar { width: 5px; }
.wpcb-messages::-webkit-scrollbar-track { background: transparent; }
.wpcb-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 10px; }

.wpcb-msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: .88rem;
    line-height: 1.5;
    word-break: break-word;
    animation: wpcb-fadein .2s ease;
}

@keyframes wpcb-fadein {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.wpcb-msg-bot {
    background: #f3f4f6;
    color: #111827;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

.wpcb-msg-user {
    background: var(--wpcb-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

/* Typing indicator */
.wpcb-typing {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 12px 16px;
}

.wpcb-typing span {
    width: 7px;
    height: 7px;
    background: #9ca3af;
    border-radius: 50%;
    animation: wpcb-bounce .8s infinite;
    display: inline-block;
}

.wpcb-typing span:nth-child(2) { animation-delay: .15s; }
.wpcb-typing span:nth-child(3) { animation-delay: .3s; }

@keyframes wpcb-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40%           { transform: translateY(-6px); }
}

/* Timestamp de mensajes */
.wpcb-msg-time {
    font-size: .7rem;
    opacity: .6;
    margin-top: 3px;
    text-align: right;
}

/* ── Quick replies ────────────────────────────────────────────────────────── */
.wpcb-quick-replies {
    padding: 0 14px 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.wpcb-quick-btn {
    background: var(--wpcb-primary-light);
    color: var(--wpcb-primary);
    border: 1px solid var(--wpcb-primary);
    border-radius: 20px;
    padding: 5px 13px;
    font-size: .78rem;
    cursor: pointer;
    transition: background .15s, color .15s;
    font-weight: 500;
}

.wpcb-quick-btn:hover {
    background: var(--wpcb-primary);
    color: #fff;
}

/* ── Input area ───────────────────────────────────────────────────────────── */
.wpcb-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.wpcb-input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 24px;
    padding: 9px 16px;
    font-size: .88rem;
    outline: none;
    transition: border-color .2s;
    background: #f9fafb;
    color: #111827;
}

.wpcb-input:focus {
    border-color: var(--wpcb-primary);
    background: #fff;
}

.wpcb-send-btn {
    width: 40px;
    height: 40px;
    background: var(--wpcb-primary);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .2s, transform .15s;
}

.wpcb-send-btn:hover:not(:disabled) {
    background: var(--wpcb-primary-dark);
    transform: scale(1.05);
}

.wpcb-send-btn:disabled {
    opacity: .5;      /* visible pero atenuado */
    cursor: default;
}

/* ── Footer ───────────────────────────────────────────────────────────────── */
.wpcb-footer {
    text-align: center;
    font-size: .7rem;
    color: #9ca3af;
    padding: 6px 0 8px;
    flex-shrink: 0;
}

/* ── Mobile ───────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .wpcb-widget {
        bottom: 0;
        right: 0 !important;
        left: 0 !important;
    }

    .wpcb-toggle-btn {
        position: fixed;
        bottom: 20px;
        right: 20px;
    }

    .wpcb-left .wpcb-toggle-btn {
        right: auto;
        left: 20px;
    }

    .wpcb-chat-window {
        position: fixed;
        bottom: 0;
        left: 0 !important;
        right: 0 !important;
        width: 100%;
        max-height: 85vh;
        border-radius: 16px 16px 0 0;
    }
}
