/* ═══════════════════════════════════════════════
   WC AI Chatbot — Tiendas Ecológicas Tenerife
   ═══════════════════════════════════════════════ */

:root {
    --wcai-primary: #2d6a4f;
    --wcai-primary-dark: #1b4332;
    --wcai-primary-light: #52b788;
    --wcai-accent: #95d5b2;
    --wcai-bg: #ffffff;
    --wcai-bg-chat: #f0f7f4;
    --wcai-text: #1a1a2e;
    --wcai-text-light: #5a6c5e;
    --wcai-bot-bg: #ffffff;
    --wcai-user-bg: #2d6a4f;
    --wcai-user-text: #ffffff;
    --wcai-border: #d8e8d4;
    --wcai-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    --wcai-radius: 16px;
    --wcai-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

/* ── Reset dentro del widget ─────────────────── */
.wcai-chatbot *, .wcai-chatbot *::before, .wcai-chatbot *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ── Contenedor principal ────────────────────── */
.wcai-chatbot {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: var(--wcai-font);
    font-size: 14px;
    line-height: 1.55;
}

/* ── Botón flotante ──────────────────────────── */
.wcai-toggle {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--wcai-primary), var(--wcai-primary-light));
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(45, 106, 79, 0.45);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
}
.wcai-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(45, 106, 79, 0.55);
}
.wcai-toggle svg { width: 28px; height: 28px; }

/* ── Ventana del chat ────────────────────────── */
.wcai-window {
    position: absolute;
    bottom: 78px;
    right: 0;
    width: 400px;
    max-width: calc(100vw - 24px);
    height: 580px;
    max-height: calc(100vh - 110px);
    background: var(--wcai-bg);
    border-radius: var(--wcai-radius);
    box-shadow: var(--wcai-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--wcai-border);
    animation: wcai-slideUp 0.3s ease-out;
}
@keyframes wcai-slideUp {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ──────────────────────────────────── */
.wcai-header {
    background: linear-gradient(135deg, var(--wcai-primary-dark), var(--wcai-primary));
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.wcai-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.wcai-header-info strong { display: block; font-size: 15px; }
.wcai-header-info small  { font-size: 11px; opacity: 0.85; display: block; }
.wcai-avatar { font-size: 30px; line-height: 1; }
.wcai-close-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    font-size: 22px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.wcai-close-btn:hover { background: rgba(255, 255, 255, 0.3); }

/* ── Área de mensajes ────────────────────────── */
.wcai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--wcai-bg-chat);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.wcai-messages::-webkit-scrollbar { width: 5px; }
.wcai-messages::-webkit-scrollbar-track { background: transparent; }
.wcai-messages::-webkit-scrollbar-thumb { background: var(--wcai-border); border-radius: 3px; }

/* ── Burbujas de mensaje ─────────────────────── */
.wcai-msg {
    display: flex;
    max-width: 88%;
    animation: wcai-fadeMsg 0.25s ease-out;
}
@keyframes wcai-fadeMsg {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.wcai-msg-bot  { align-self: flex-start; }
.wcai-msg-user { align-self: flex-end; }

.wcai-msg-bubble {
    padding: 11px 15px;
    border-radius: 14px;
    word-break: break-word;
    white-space: pre-wrap;
}
.wcai-msg-bot .wcai-msg-bubble {
    background: var(--wcai-bot-bg);
    color: var(--wcai-text);
    border: 1px solid var(--wcai-border);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.wcai-msg-user .wcai-msg-bubble {
    background: var(--wcai-user-bg);
    color: var(--wcai-user-text);
    border-bottom-right-radius: 4px;
}

/* ── Markdown dentro de burbujas bot ─────────── */
.wcai-msg-bot .wcai-msg-bubble h3 {
    font-size: 14px;
    font-weight: 700;
    margin: 6px 0 4px;
    color: var(--wcai-primary-dark);
}
.wcai-msg-bot .wcai-msg-bubble hr {
    border: none;
    border-top: 1px solid var(--wcai-border);
    margin: 8px 0;
}
.wcai-msg-bot .wcai-msg-bubble a {
    color: var(--wcai-primary);
    text-decoration: underline;
    font-weight: 500;
}
.wcai-msg-bot .wcai-msg-bubble a:hover {
    color: var(--wcai-primary-dark);
}
.wcai-msg-bot .wcai-msg-bubble strong {
    font-weight: 600;
}

/* ── Typing indicator ────────────────────────── */
.wcai-typing {
    display: flex;
    gap: 5px;
    padding: 12px 16px;
    align-self: flex-start;
}
.wcai-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--wcai-accent);
    border-radius: 50%;
    animation: wcai-bounce 1.4s ease-in-out infinite;
}
.wcai-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.wcai-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes wcai-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40%           { transform: translateY(-8px); }
}

/* ── Quick actions ───────────────────────────── */
.wcai-quick {
    padding: 8px 12px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    background: var(--wcai-bg);
    border-top: 1px solid var(--wcai-border);
    flex-shrink: 0;
}
.wcai-quick-btn {
    font-family: var(--wcai-font);
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--wcai-border);
    background: var(--wcai-bg);
    color: var(--wcai-primary);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.wcai-quick-btn:hover {
    background: var(--wcai-primary);
    color: #fff;
    border-color: var(--wcai-primary);
}

/* ── Área de input ───────────────────────────── */
.wcai-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    background: var(--wcai-bg);
    border-top: 1px solid var(--wcai-border);
    flex-shrink: 0;
}
.wcai-input {
    flex: 1;
    font-family: var(--wcai-font);
    font-size: 14px;
    padding: 10px 14px;
    border: 1px solid var(--wcai-border);
    border-radius: 22px;
    resize: none;
    outline: none;
    max-height: 100px;
    line-height: 1.4;
    transition: border-color 0.2s;
    background: var(--wcai-bg-chat);
}
.wcai-input:focus { border-color: var(--wcai-primary-light); }
.wcai-input::placeholder { color: #9aab9e; }

.wcai-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: var(--wcai-primary);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s;
}
.wcai-send:hover { background: var(--wcai-primary-dark); transform: scale(1.05); }
.wcai-send:disabled { opacity: 0.5; cursor: default; transform: none; }

/* ── Footer ──────────────────────────────────── */
.wcai-footer {
    padding: 6px 12px;
    text-align: center;
    font-size: 11px;
    color: var(--wcai-text-light);
    background: var(--wcai-bg);
    border-top: 1px solid var(--wcai-border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.wcai-footer a {
    color: var(--wcai-primary);
    text-decoration: none;
    font-weight: 500;
}
.wcai-footer a:hover { text-decoration: underline; }

/* ── Producto card dentro de burbuja ─────────── */
.wcai-product-card {
    display: flex;
    gap: 10px;
    background: var(--wcai-bg-chat);
    border: 1px solid var(--wcai-border);
    border-radius: 10px;
    padding: 10px;
    margin: 8px 0;
}
.wcai-product-card img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}
.wcai-product-card-info { flex: 1; font-size: 13px; }
.wcai-product-card-info strong { display: block; margin-bottom: 2px; }
.wcai-product-card-info .wcai-price { color: var(--wcai-primary); font-weight: 700; }

/* ── Notificación de carrito ─────────────────── */
.wcai-cart-notice {
    background: #d4edda;
    border: 1px solid #b7dfb9;
    border-radius: 8px;
    padding: 8px 12px;
    margin: 6px 0;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.wcai-cart-notice a {
    color: var(--wcai-primary-dark);
    font-weight: 600;
    text-decoration: underline;
}

/* ── Responsive ──────────────────────────────── */
@media (max-width: 480px) {
    .wcai-chatbot { bottom: 12px; right: 12px; }
    .wcai-window {
        width: calc(100vw - 24px);
        height: calc(100vh - 90px);
        bottom: 74px;
        right: -8px;
        border-radius: 14px;
    }
    .wcai-toggle { width: 56px; height: 56px; }
    .wcai-toggle svg { width: 24px; height: 24px; }
}
