/* ============================================
   THU HỒI NỢ PRO — Chatbot Widget Styles
   Dark + Orange Glow Theme (matching website)
   ============================================ */

/* === TOGGLE BUTTON === */
.cb-toggle {
    position: fixed;
    bottom: 100px;
    right: 24px;
    z-index: 9999;
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #FF6B00 0%, #FF9A40 50%, #FF6B00 100%);
    color: #000;
    cursor: pointer;
    box-shadow: 0 4px 24px rgba(255, 107, 0, 0.4), 0 0 0 0 rgba(255, 107, 0, 0.3);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: cb-pulse-shadow 2.5s ease-in-out infinite;
}

@keyframes cb-pulse-shadow {
    0%, 100% { box-shadow: 0 4px 24px rgba(255, 107, 0, 0.4), 0 0 0 0 rgba(255, 107, 0, 0.3); }
    50% { box-shadow: 0 4px 24px rgba(255, 107, 0, 0.4), 0 0 0 12px rgba(255, 107, 0, 0); }
}

.cb-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 32px rgba(255, 107, 0, 0.5);
}

.cb-toggle--open {
    animation: none;
}

.cb-toggle-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.cb-toggle-icon svg {
    width: 26px;
    height: 26px;
}

.cb-toggle-icon--close {
    position: absolute;
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

.cb-toggle--open .cb-toggle-icon--chat {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

.cb-toggle--open .cb-toggle-icon--close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Notification badge */
.cb-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 22px;
    height: 22px;
    background: #ff3b30;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-family: 'Inter', sans-serif;
    animation: cb-badge-bounce 0.5s ease;
    box-shadow: 0 2px 8px rgba(255, 59, 48, 0.4);
}

@keyframes cb-badge-bounce {
    0% { transform: scale(0); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* === CHAT WINDOW === */
.cb-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    z-index: 9998;
    width: 380px;
    height: 560px;
    max-height: calc(100vh - 140px);
    background: #0A0A0A;
    border: 1px solid rgba(255, 107, 0, 0.15);
    border-radius: 22px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.6),
        0 0 40px rgba(255, 107, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.03);

    /* Hidden state */
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: bottom right;
}

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

/* === HEADER === */
.cb-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    background: linear-gradient(145deg, rgba(17, 17, 17, 0.95) 0%, rgba(10, 10, 10, 0.98) 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.cb-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cb-avatar {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 107, 0, 0.1);
    border: 1px solid rgba(255, 107, 0, 0.2);
    border-radius: 12px;
    font-size: 20px;
}

.cb-header-name {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.3px;
}

.cb-header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #777;
    font-weight: 500;
}

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

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

.cb-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    cursor: pointer;
    color: #777;
    transition: all 0.2s ease;
}

.cb-close:hover {
    background: rgba(255, 107, 0, 0.1);
    border-color: rgba(255, 107, 0, 0.2);
    color: #FF9A40;
}

.cb-close svg {
    width: 16px;
    height: 16px;
}

/* === MESSAGES AREA === */
.cb-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 107, 0, 0.2) transparent;
}

.cb-messages::-webkit-scrollbar {
    width: 5px;
}

.cb-messages::-webkit-scrollbar-track {
    background: transparent;
}

.cb-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 107, 0, 0.2);
    border-radius: 10px;
}

.cb-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 107, 0, 0.35);
}

/* === MESSAGE BUBBLES === */
.cb-msg {
    display: flex;
    gap: 10px;
    max-width: 90%;
    align-items: flex-end;
}

.cb-msg--bot {
    align-self: flex-start;
}

.cb-msg--user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.cb-msg--animate {
    animation: cb-msg-in 0.35s cubic-bezier(0.4, 0, 0.2, 1) both;
}

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

.cb-msg-avatar {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 107, 0, 0.1);
    border: 1px solid rgba(255, 107, 0, 0.15);
    border-radius: 10px;
    font-size: 14px;
    flex-shrink: 0;
}

.cb-msg-bubble {
    padding: 12px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 13.5px;
    line-height: 1.65;
    border-radius: 16px;
    word-wrap: break-word;
}

.cb-msg--bot .cb-msg-bubble {
    background: linear-gradient(145deg, rgba(17, 17, 17, 0.95) 0%, rgba(24, 24, 24, 0.9) 100%);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: #C0C0C0;
    border-bottom-left-radius: 4px;
}

.cb-msg--bot .cb-msg-bubble strong {
    color: #FF9A40;
    font-weight: 700;
}

.cb-msg--user .cb-msg-bubble {
    background: linear-gradient(135deg, #FF6B00 0%, #FF9A40 100%);
    color: #000;
    font-weight: 500;
    border-bottom-right-radius: 4px;
}

/* === TYPING INDICATOR === */
.cb-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 0;
}

.cb-typing span {
    width: 7px;
    height: 7px;
    background: rgba(255, 107, 0, 0.5);
    border-radius: 50%;
    animation: cb-typing-bounce 1.2s ease-in-out infinite;
}

.cb-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.cb-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

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

/* === QUICK REPLY BUTTONS === */
.cb-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-left: 40px;
}

.cb-quick-btn {
    padding: 8px 14px;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: #FF9A40;
    background: rgba(255, 107, 0, 0.06);
    border: 1px solid rgba(255, 107, 0, 0.18);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.cb-quick-btn:hover {
    background: rgba(255, 107, 0, 0.14);
    border-color: rgba(255, 107, 0, 0.35);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 107, 0, 0.12);
}

.cb-quick-btn:active {
    transform: translateY(0);
}

/* === CTA BUTTONS === */
.cb-cta-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-left: 40px;
}

.cb-cta-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 18px;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 700;
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.3s ease;
    text-align: center;
}

.cb-cta-btn--primary {
    background: linear-gradient(135deg, #FF6B00 0%, #FF9A40 100%);
    color: #000;
    box-shadow: 0 4px 16px rgba(255, 107, 0, 0.3);
}

.cb-cta-btn--primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(255, 107, 0, 0.4);
    filter: brightness(1.1);
}

.cb-cta-btn--zalo {
    background: rgba(0, 104, 255, 0.12);
    color: #60a5fa;
    border: 1px solid rgba(0, 104, 255, 0.2);
}

.cb-cta-btn--zalo:hover {
    background: rgba(0, 104, 255, 0.2);
    border-color: rgba(0, 104, 255, 0.35);
    transform: translateY(-1px);
}

/* === INPUT AREA === */
.cb-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: rgba(17, 17, 17, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.cb-input {
    flex: 1;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.2s ease;
}

.cb-input::placeholder {
    color: #555;
}

.cb-input:focus {
    border-color: rgba(255, 107, 0, 0.4);
    box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.06);
}

.cb-send {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #FF6B00, #FF9A40);
    border: none;
    border-radius: 10px;
    color: #000;
    cursor: pointer;
    transition: all 0.25s ease;
    flex-shrink: 0;
}

.cb-send:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(255, 107, 0, 0.35);
}

.cb-send:active {
    transform: scale(0.95);
}

.cb-send svg {
    width: 18px;
    height: 18px;
}

/* === RESPONSIVE === */
@media (max-width: 480px) {
    .cb-toggle {
        bottom: 80px;
        right: 16px;
        width: 54px;
        height: 54px;
    }

    .cb-toggle-icon svg {
        width: 22px;
        height: 22px;
    }

    .cb-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }

    .cb-window--open {
        transform: translateY(0) scale(1);
    }

    .cb-header {
        padding: 14px 16px;
        padding-top: max(14px, env(safe-area-inset-top));
    }

    .cb-messages {
        padding: 14px 12px;
    }

    .cb-input-area {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .cb-quick-replies {
        padding-left: 0;
    }

    .cb-cta-wrap {
        padding-left: 0;
    }
}

/* Hide toggle when chat is open on mobile */
@media (max-width: 480px) {
    .cb-toggle--open {
        opacity: 0;
        pointer-events: none;
    }
}
