/* ============================================================
   Chatbot Widget — 8BITS Asistente Virtual "Byte"
   Paleta: primary #0ea5e9 · accent #0f172a
   ============================================================ */

#chatbot-widget {
    position: fixed;
    bottom: 90px;
    right: 30px;
    z-index: 9998;
    font-family: 'Inter', sans-serif;
}

/* ---- Toggle button ---- */
#chatbot-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0ea5e9 0%, #0f172a 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(14, 165, 233, 0.55);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.3s ease;
    position: relative;
}

#chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(14, 165, 233, 0.7);
}

#chatbot-toggle.cb-toggle-open {
    background: linear-gradient(135deg, #0f172a 0%, #0ea5e9 100%);
}

/* Notification badge */
#chatbot-badge {
    position: absolute;
    top: 0;
    right: 0;
    width: 19px;
    height: 19px;
    background: #ef4444;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    animation: cb-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    pointer-events: none;
}

@keyframes cb-pop {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}

/* ---- Chat panel ---- */
#chatbot-panel {
    position: absolute;
    bottom: calc(100% + 14px);
    right: 0;
    width: 350px;
    max-height: min(500px, calc(100vh - 180px));
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.14), 0 0 0 1px rgba(14, 165, 233, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.85) translateY(16px);
    transform-origin: bottom right;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.2s ease;
}

#chatbot-panel.cb-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* ---- Header ---- */
#chatbot-header {
    background: linear-gradient(135deg, #0f172a 0%, #0369a1 100%);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.cb-header-info {
    display: flex;
    align-items: center;
    gap: 11px;
}

.cb-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    border: 2px solid rgba(255, 255, 255, 0.28);
    flex-shrink: 0;
    overflow: hidden;
}

.cb-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 50%;
}

.cb-name {
    color: #fff;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 14px;
    line-height: 1.2;
}

.cb-status {
    color: rgba(255, 255, 255, 0.78);
    font-size: 11.5px;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.cb-dot {
    width: 7px;
    height: 7px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
    animation: cb-pulse 2.5s ease infinite;
}

@keyframes cb-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.45; }
}

#chatbot-close {
    background: rgba(255, 255, 255, 0.14);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

#chatbot-close:hover { background: rgba(255, 255, 255, 0.26); }

/* ---- Messages ---- */
#chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

#chatbot-messages::-webkit-scrollbar { width: 4px; }
#chatbot-messages::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 4px;
}

.cb-msg {
    display: flex;
    align-items: flex-end;
    gap: 7px;
    animation: cb-msg-in 0.22s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes cb-msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.cb-msg-bot  { align-self: flex-start; max-width: 88%; }
.cb-msg-user { align-self: flex-end; flex-direction: row-reverse; max-width: 88%; }

.cb-avatar-sm {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0f172a, #0ea5e9);
    flex-shrink: 0;
    overflow: hidden;
}

.cb-avatar-sm img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 50%;
}

.cb-bubble {
    padding: 9px 13px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.55;
    word-break: break-word;
}

.cb-msg-bot  .cb-bubble {
    background: #f1f5f9;
    color: #1e293b;
    border-bottom-left-radius: 5px;
}

.cb-msg-user .cb-bubble {
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
    color: #fff;
    border-bottom-right-radius: 5px;
}

/* Typing dots */
.cb-bubble-typing {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 11px 14px;
}

.cb-dot-bounce {
    width: 7px;
    height: 7px;
    background: #94a3b8;
    border-radius: 50%;
    display: inline-block;
    animation: cb-bounce 1.1s ease infinite;
}

.cb-dot-bounce:nth-child(2) { animation-delay: 0.14s; }
.cb-dot-bounce:nth-child(3) { animation-delay: 0.28s; }

@keyframes cb-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%            { transform: translateY(-6px); }
}

/* ---- Suggestion chips ---- */
#chatbot-chips {
    padding: 0 12px 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.cb-chip {
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-radius: 20px;
    padding: 5px 11px;
    font-size: 12px;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    color: #0ea5e9;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
    white-space: nowrap;
}

.cb-chip:hover {
    background: #0ea5e9;
    color: #fff;
    border-color: #0ea5e9;
}

/* ---- Input area ---- */
#chatbot-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #f1f5f9;
    background: #fff;
    flex-shrink: 0;
}

#chatbot-input {
    flex: 1;
    border: 1.5px solid #e2e8f0;
    border-radius: 22px;
    padding: 8px 14px;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    color: #1e293b;
    background: #f8fafc;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    min-height: 38px;
}

#chatbot-input:focus {
    border-color: #0ea5e9;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
    background: #fff;
}

#chatbot-input::placeholder { color: #94a3b8; }

#chatbot-input:disabled { opacity: 0.6; cursor: not-allowed; }

#chatbot-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

#chatbot-send:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.45);
}

#chatbot-send:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---- Mobile ---- */
@media (max-width: 480px) {
    #chatbot-widget {
        bottom: 80px;
        right: 16px;
    }

    #chatbot-panel {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        max-height: 72vh;
        border-radius: 20px 20px 0 0;
        transform-origin: bottom center;
    }
}

@media (prefers-reduced-motion: reduce) {
    #chatbot-panel,
    #chatbot-toggle,
    .cb-msg,
    .cb-dot-bounce,
    .cb-dot {
        animation: none !important;
        transition: none !important;
    }
}
