/* CZ Chatbot – Frontend Styles */
#cz-chatbot-wrapper {
    position: fixed;
    z-index: 999999;
    bottom: 24px;
}
#cz-chatbot-wrapper.cz-pos-bottom-right { right: 24px; }
#cz-chatbot-wrapper.cz-pos-bottom-left  { left: 24px; }

/* Toggle button */
.cz-chat-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;
}
.cz-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(0,0,0,0.3);
}
.cz-chat-toggle:active { transform: scale(0.96); }

.cz-unread-badge {
    position: absolute; top: -4px; right: -4px;
    background: #EF4444; color: white;
    font-size: 11px; font-weight: 700;
    width: 20px; height: 20px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid white; pointer-events: none;
}

/* Chat window */
.cz-chat-window {
    position: absolute;
    bottom: 70px;
    width: 360px;
    max-height: 520px;
    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;
    transform: translateY(12px) scale(0.97);
    transition: opacity .25s, transform .25s, visibility .25s;
}
.cz-pos-bottom-right .cz-chat-window { right: 0; }
.cz-pos-bottom-left  .cz-chat-window { left: 0; }

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

/* Header */
.cz-chat-header {
    background: 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: 36px; height: 36px; border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex; align-items: center; justify-content: center;
    color: white;
}
.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 {
    border: none;
    border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .2s;
}
.cz-chat-close:hover { background: rgba(255,255,255,0.3); }

/* Messages */
.cz-chat-messages {
    flex: 1; overflow-y: auto; padding: 16px;
    display: flex; flex-direction: column; gap: 12px;
    scroll-behavior: smooth;
}
.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; }

/* Bubbles */
.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-bubble {
    max-width: 80%; 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;
}

/* Typing indicator */
.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 10px;
    border-top: 1px solid #E5E7EB;
    background: #FAFAFA;
}
.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-chat-input {
    flex: 1; border: none; outline: none; resize: none;
    font-size: 14px; line-height: 1.5; max-height: 100px;
    background: transparent; color: #1F2937;
    font-family: inherit;
}
.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; 
}

.cz-chat-footer {
    text-align: center; font-size: 11px; color: #9CA3AF; margin: 6px 0 0;
}
.cz-chat-footer a { color: inherit; }

/* Error message */
.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; }
}

/* Burbuja de bienvenida */
.cz-chat-bubble {
    position: absolute; bottom: 12px; right: 70px;
    background: white; color: #1F2937;
    padding: 10px 16px;
    border-radius: 20px 20px 20px 20px;
    font-size: 14px; font-weight: 400; white-space: nowrap;
    box-shadow: 0 2px 10px rgba(0,0,0,0.12);
    display: flex; align-items: center; gap: 8px;
    animation: czSlideIn .4s ease forwards;
}
.cz-chat-bubble::after {
    content: '';
    position: absolute; top: 50%; right: -8px;
    transform: translateY(-50%);
    width: 0; height: 0;
    border-left: 8px solid white;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
}
.cz-bubble-close {
    background: none; border: none; cursor: pointer;
    color: #9CA3AF; display: flex; align-items: center;
    padding: 0; line-height: 1;
}
.cz-bubble-close:hover { color: #1F2937; }
.cz-bubble-close svg { width: 10px; height: 10px; }
@keyframes czSlideIn {
    from { opacity: 0; transform: translateX(10px); }
    to   { opacity: 1; transform: translateX(0); }
}
