/* CZ Chatbot – Frontend Styles */

/* ── Aislamiento defensivo frente a los estilos del tema ──────
   Neutraliza las reglas más habituales que un tema de WordPress
   inyecta sobre botones, textareas, imágenes y tipografía dentro
   del widget. No es un Shadow DOM, pero cubre el 99% de los casos. */
#cz-chatbot-wrapper,
#cz-chatbot-wrapper *,
#cz-chatbot-wrapper *::before,
#cz-chatbot-wrapper *::after {
    box-sizing: border-box;
}
#cz-chatbot-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    letter-spacing: normal;
    text-align: left;
}
#cz-chatbot-wrapper button,
#cz-chatbot-wrapper textarea,
#cz-chatbot-wrapper input,
#cz-chatbot-wrapper a {
    font-family: inherit;
    letter-spacing: normal;
    text-transform: none;
}
#cz-chatbot-wrapper button,
#cz-chatbot-wrapper textarea,
#cz-chatbot-wrapper input {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
    box-shadow: none;
}
#cz-chatbot-wrapper svg { display: block; }

#cz-chatbot-wrapper {
    position: fixed;
    z-index: 999999;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-end;
    gap: 12px;
}
#cz-chatbot-wrapper.cz-pos-bottom-right { right: 24px; }
#cz-chatbot-wrapper.cz-pos-bottom-left  { left: 24px; align-items: flex-start; }

/* ── Botón principal ─────────────────────────────────────── */
/*
   IMPORTANTE: El botón SIEMPRE es visible.
   Nunca ocultar con opacity/visibility desde el wrapper.
*/
.cz-main-toggle {
    position: relative;
    width: 58px; height: 58px; border-radius: 50%;
    background: var(--cz-primary, #6C2BD9);
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    transition: transform .2s, box-shadow .2s;
    outline: none;
    z-index: 2;
    /* Siempre visible — sin opacity 0 aquí */
    opacity: 1;
    visibility: visible;
}
.cz-main-toggle:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(0,0,0,0.3); }
.cz-main-toggle:active { transform: scale(0.96); }

/* Iconos dentro del botón */
.cz-toggle-icon { display: flex; align-items: center; justify-content: center; }

/* ── Menú de acciones ────────────────────────────────────── */
/*
   El menú sale ENCIMA del botón (margin-bottom).
   Empieza oculto y aparece con hover en el wrapper o clase .cz-menu-open.
   El botón está FUERA del menú → el hover no se rompe al moverse hacia las opciones.
*/
.cz-action-menu {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity .22s ease, transform .22s ease;
}
#cz-chatbot-wrapper.cz-pos-bottom-left .cz-action-menu {
    align-items: flex-start;
}

/* Click en móvil (toggle manual) */
.cz-action-menu.cz-menu-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

.cz-contact-wrap {
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-end;
    gap: 12px;
}

/* Cada item: label + botón en fila */
.cz-action-item {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: flex-end;
}
#cz-chatbot-wrapper.cz-pos-bottom-left .cz-action-item {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

/* Label */
.cz-action-label {
    background: white;
    color: #1F2937;
    font-size: 13px;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.12);
    white-space: nowrap;
    font-family: inherit;
    /* Animación de entrada para los labels */
    transition: opacity .15s ease, transform .15s ease;
}

/* Botones de acción */
.cz-action-btn {
    width: 48px; height: 48px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: none; cursor: pointer;
    box-shadow: 0 3px 12px rgba(0,0,0,0.2);
    transition: transform .2s, box-shadow .2s;
    text-decoration: none;
    flex-shrink: 0;
    position: relative;
}
.cz-action-btn:hover { transform: scale(1.1); box-shadow: 0 5px 18px rgba(0,0,0,0.25); }

.cz-action-whatsapp { background: #25D366; }
.cz-action-email    { background: #EF4444; }
.cz-action-phone    { background: #22C55E; }
.cz-action-chat     { background: var(--cz-primary, #6C2BD9); }

/* ── Blindaje anti-tema (algunos temas resetean los <button>) ──────
   Especificidad por ID + !important para que ningún tema agresivo
   tumbe el aspecto de los botones flotantes ni el de enviar. */
#cz-chatbot-wrapper .cz-main-toggle,
#cz-chatbot-wrapper .cz-action-btn,
#cz-chatbot-wrapper .cz-chat-send {
    border: none !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    cursor: pointer !important;
    line-height: normal !important;
}
#cz-chatbot-wrapper .cz-main-toggle {
    width: 58px !important; height: 58px !important;
    background-color: var(--cz-primary, #6C2BD9) !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25) !important;
}
#cz-chatbot-wrapper .cz-action-btn {
    width: 48px !important; height: 48px !important;
    box-shadow: 0 3px 12px rgba(0,0,0,0.2) !important;
}
#cz-chatbot-wrapper .cz-action-whatsapp { background-color: #25D366 !important; }
#cz-chatbot-wrapper .cz-action-email    { background-color: #EF4444 !important; }
#cz-chatbot-wrapper .cz-action-phone    { background-color: #22C55E !important; }
#cz-chatbot-wrapper .cz-action-chat     { background-color: var(--cz-primary, #6C2BD9) !important; }
#cz-chatbot-wrapper .cz-chat-send {
    width: 36px !important; height: 36px !important;
    border-radius: 8px !important;
    background-color: var(--cz-primary, #6C2BD9) !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25) !important;
}
#cz-chatbot-wrapper .cz-main-toggle svg,
#cz-chatbot-wrapper .cz-action-btn svg,
#cz-chatbot-wrapper .cz-chat-send svg {
    display: block !important;
    fill: #fff !important;
}
/* Avatar personalizado dentro del botón lanzador: llena el círculo */
#cz-chatbot-wrapper #cz-chatbot-toggle .cz-toggle-open {
    position: static !important;
}
#cz-chatbot-wrapper .cz-toggle-avatar {
    position: absolute !important;
    top: 0 !important; left: 0 !important;
    width: 100% !important; height: 100% !important;
    object-fit: cover !important;
    border-radius: 50% !important;
    display: block !important;
}

/* Badge en botón chat — usa el color configurado por el usuario */
.cz-unread-badge {
    position: absolute; top: -5px; right: -5px;
    background: var(--cz-primary, #6C2BD9); color: #fff;
    font-size: 11px; font-weight: 700; line-height: 1;
    min-width: 20px; height: 20px; padding: 0 5px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    pointer-events: none; box-sizing: border-box;
}

/* Globo de bienvenida */
.cz-welcome-bubble {
    position: absolute;
    bottom: 8px;
    right: calc(100% + 14px);
    left: auto;
    width: max-content;
    max-width: 240px;
    background: #fff; color: #1F2937;
    padding: 12px 16px; border-radius: 18px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.16);
    font-size: 14px; line-height: 1.4;
    white-space: normal; word-break: normal; overflow-wrap: break-word;
    cursor: pointer;
    opacity: 0; transform: translateY(8px) scale(.96);
    transition: opacity .25s ease, transform .25s ease;
    z-index: 999997;
}
.cz-welcome-bubble.cz-show { opacity: 1; transform: translateY(0) scale(1); }
#cz-chatbot-wrapper.cz-pos-bottom-left .cz-welcome-bubble {
    right: auto; left: calc(100% + 14px);
}
/* Pico del globo apuntando al botón */
.cz-welcome-bubble::after {
    content: ''; position: absolute;
    bottom: 16px; right: -7px;
    width: 0; height: 0;
    border-top: 7px solid transparent; border-bottom: 7px solid transparent;
    border-left: 8px solid #fff;
}
#cz-chatbot-wrapper.cz-pos-bottom-left .cz-welcome-bubble::after {
    right: auto; left: -7px;
    border-left: none; border-right: 8px solid #fff;
}
.cz-welcome-bubble-text { display: block; }

/* ── Ventana del chat ────────────────────────────────────── */
.cz-chat-window {
    position: fixed;
    bottom: 90px;
    right: 90px;
    width: 360px;
    max-height: 520px;
    min-height: 400px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(12px) scale(0.97);
    transition: opacity .25s, transform .25s, visibility .25s;
    z-index: 999998;
}

.cz-pos-bottom-right .cz-chat-window {
    right: 90px;
    bottom: 90px;
}

.cz-pos-bottom-left .cz-chat-window {
    left: 90px;
    bottom: 90px;
}

.cz-chat-window.cz-open {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
    transform: translateY(0) scale(1);
}

/* Header */
.cz-chat-header {
    background: var(--cz-header, var(--cz-primary, #6C2BD9));
    padding: 14px 16px;
    display: flex; align-items: center; justify-content: space-between;
    color: white;
}
.cz-chat-header-info { display: flex; align-items: center; gap: 10px; }
.cz-chat-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex; align-items: center; justify-content: center; color: white;
    overflow: hidden;
    padding: 0px;
    box-sizing: border-box;
}
.cz-chat-name  { display: block; font-size: 14px; font-weight: 700; line-height: 1.2; }
.cz-chat-status { display: block; font-size: 11px; opacity: .75; }
.cz-status-dot { width: 7px; height: 7px; border-radius: 50%; background: #4ADE80; display: inline-block; margin-right: 4px; }
.cz-chat-close {
    background: transparent; border: none; border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: background .2s;
}

/* Mensajes */
.cz-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cz-chat-messages::-webkit-scrollbar { width: 4px; }
.cz-chat-messages::-webkit-scrollbar-track { background: transparent; }
.cz-chat-messages::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 2px; }

/* Burbujas */
.cz-msg { display: flex; gap: 8px; align-items: flex-end; animation: czFadeIn .25s ease; }
@keyframes czFadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.cz-msg-bot  { flex-direction: row; }
.cz-msg-user { flex-direction: row-reverse; }
.cz-msg-avatar {
    width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
    background: var(--cz-primary, #6C2BD9);
    display: flex; align-items: center; justify-content: center; color: white; font-size: 13px;
}
.cz-msg-content { display: flex; flex-direction: column; gap: 8px; max-width: 80%; min-width: 0; }
.cz-bubble { max-width: 100%; padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.55; word-break: break-word; }
.cz-msg-bot  .cz-bubble { background: #F3F4F6; color: #1F2937; border-bottom-left-radius: 4px; }
.cz-msg-user .cz-bubble { background: var(--cz-primary, #6C2BD9); color: white; border-bottom-right-radius: 4px; }
.cz-bubble a { color: var(--cz-primary, #6C2BD9); text-decoration: underline; }

/* Tarjetas de producto (WooCommerce) */
.cz-products { display: flex; flex-direction: column; gap: 8px; }
.cz-product-card {
    display: flex; gap: 10px; align-items: center; text-decoration: none;
    background: #fff; border: 1px solid #E5E7EB; border-radius: 14px; padding: 8px;
    transition: box-shadow .15s ease, border-color .15s ease;
}
.cz-product-card:hover { border-color: var(--cz-primary, #6C2BD9); box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.cz-product-img { flex: 0 0 64px; width: 64px; height: 64px; border-radius: 10px; overflow: hidden; background: #F3F4F6; }
.cz-product-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cz-product-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cz-product-title { font-weight: 600; font-size: 13px; color: #111827; line-height: 1.3; }
.cz-product-price { font-size: 13px; color: var(--cz-primary, #6C2BD9); font-weight: 600; }
.cz-product-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.cz-product-btn, .cz-product-add {
    font-size: 12px; font-weight: 600; line-height: 1.2;
    padding: 6px 12px; border-radius: 999px;
    border: none; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.cz-product-btn { background: #EEF0FB; color: var(--cz-primary, #6C2BD9); }
.cz-product-add { background: var(--cz-primary, #6C2BD9); color: #fff; }
.cz-product-add:hover { filter: brightness(1.06); }
.cz-product-add:disabled { opacity: .7; cursor: default; }

/* Selectores de variante (productos variables) */
.cz-product-variations { display: flex; flex-direction: column; gap: 5px; margin-top: 6px; }
.cz-var-row { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.cz-var-label { color: #6B7280; min-width: 54px; }
.cz-var-select {
    flex: 1; min-width: 0; font-size: 12px; color: #111827;
    padding: 4px 8px; border: 1px solid #E5E7EB; border-radius: 8px; background: #fff;
}
.cz-var-select:focus { outline: none; border-color: var(--cz-primary, #6C2BD9); }

/* Propuesta de carrito (modo selección por presupuesto/personas) */
.cz-proposal {
    background: #fff; border: 1px solid #E5E7EB; border-radius: 14px;
    padding: 10px; display: flex; flex-direction: column; gap: 8px;
}
.cz-prop-items { display: flex; flex-direction: column; gap: 6px; }
.cz-prop-item { display: flex; align-items: center; gap: 8px; }
.cz-prop-img { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 8px; overflow: hidden; background: #F3F4F6; }
.cz-prop-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cz-prop-info { flex: 1; min-width: 0; }
.cz-prop-title { font-size: 12px; font-weight: 600; color: #111827; line-height: 1.3; }
.cz-prop-note { font-size: 11px; color: #6B7280; line-height: 1.3; }
.cz-prop-price { font-size: 12px; font-weight: 600; color: var(--cz-primary, #6C2BD9); white-space: nowrap; }
.cz-prop-total { font-size: 13px; color: #111827; text-align: right; border-top: 1px solid #F3F4F6; padding-top: 6px; }
.cz-prop-add-all {
    align-self: stretch; background: var(--cz-primary, #6C2BD9); color: #fff;
    font-size: 13px; font-weight: 600; padding: 8px 14px;
    border: none; border-radius: 999px; cursor: pointer;
}
.cz-prop-add-all:hover { filter: brightness(1.06); }
.cz-prop-add-all:disabled { opacity: .7; cursor: default; }

/* Confirmación de carrito */
.cz-cart-confirm .cz-bubble { background: #ECFDF5; color: #065F46; border: 1px solid #A7F3D0; }
.cz-cart-link {
    align-self: flex-start; margin-top: 2px;
    background: var(--cz-primary, #6C2BD9); color: #fff;
    font-size: 12px; font-weight: 600; padding: 6px 14px;
    border-radius: 999px; text-decoration: none;
}

/* Typing */
.cz-typing .cz-bubble { background: #F3F4F6; padding: 12px 16px; }
.cz-typing-dots { display: flex; gap: 4px; align-items: center; }
.cz-typing-dots span { width: 7px; height: 7px; background: #9CA3AF; border-radius: 50%; animation: czBounce 1.2s infinite ease-in-out; }
.cz-typing-dots span:nth-child(1) { animation-delay: 0s; }
.cz-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.cz-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes czBounce { 0%,60%,100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-6px); opacity: 1; } }

/* Input */
.cz-chat-input-wrap {
    padding: 12px 16px;
    border-top: 1px solid #f0f0f0;
    background: #fff;
}.cz-chat-input-row {
    display: flex; align-items: center; gap: 8px;
    background: white; border: 1px solid #E5E7EB;
    border-radius: 12px; padding: 6px 6px 6px 12px; transition: border-color .2s;
}
.cz-chat-input-row:focus-within { border-color: var(--cz-primary, #6C2BD9); box-shadow: 0 0 0 3px rgba(108,43,217,0.1); }
#cz-chatbot-wrapper .cz-chat-input {
    flex: 1; border: none; outline: none; resize: none;
    font-size: 14px; line-height: 1.4;
    height: 24px; min-height: 24px; max-height: 100px;
    padding: 2px 0; margin: 0;
    background: transparent; color: #1F2937; font-family: inherit;
    overflow-y: auto;
}
.cz-chat-send {
    width: 36px; height: 36px; border-radius: 8px; border: none;
    background: var(--cz-primary, #6C2BD9); color: white;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: opacity .2s, transform .15s;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25); overflow: hidden;
}
.cz-chat-send svg { display: block; fill: white; width: 18px; height: 18px; min-width: 18px; min-height: 18px; pointer-events: none; }

/* Error */
.cz-msg-error .cz-bubble { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }

/* Responsive */
@media (max-width: 400px) {
    .cz-chat-window { width: calc(100vw - 32px); right: 0 !important; left: 0 !important; margin: 0 auto; }
    #cz-chatbot-wrapper.cz-pos-bottom-right,
    #cz-chatbot-wrapper.cz-pos-bottom-left { right: 16px; left: 16px; }
}

#cz-open-chat-btn {
    width: 48px !important;
    height: 48px !important;
    border-radius: 50% !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
}

.cz-logo-header-full {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    object-fit: cover !important;
    margin: 0 !important;
    transform: none !important;
    display: block !important;

}

.cz-chat-status {
    font-size: 10px;
    opacity: 0.8;
}


.cz-chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    padding: 0px !important;
    box-sizing: border-box;
}