/* =========================================================
   PRIYANSU AI CHATBOT — Complete Stylesheet
   Clean white / light theme with purple accent
   ========================================================= */

/* ── Google Font ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── CSS Custom Properties ── */
:root {
    --cb-purple: #6c47ff;
    --cb-purple-dark: #4f2fe8;
    --cb-purple-light: #ede9ff;
    --cb-purple-mid: #8b6dff;
    --cb-accent: #a78bfa;
    --cb-white: #ffffff;
    --cb-bg: #f8f7ff;
    --cb-border: rgba(108, 71, 255, 0.12);
    --cb-shadow: 0 24px 64px rgba(60, 20, 180, 0.18), 0 4px 16px rgba(60, 20, 180, 0.08);
    --cb-shadow-btn: 0 8px 28px rgba(108, 71, 255, 0.45);
    --cb-radius: 20px;
    --cb-radius-msg: 18px;
    --cb-font: 'Inter', sans-serif;
    --cb-transition: 0.28s cubic-bezier(.4, 0, .2, 1);
    --cb-header-h: 72px;
    --cb-widget-w: 380px;
    --cb-widget-h: 580px;
}

/* =========================================================
   FLOATING LAUNCH BUTTON
   ========================================================= */
#cb-launch-btn {
    position: fixed;
    bottom: 90px;
    /* Moved up to clear back-to-top button */
    right: 28px;
    z-index: 9990;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 24px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    background: linear-gradient(135deg, #7c5cff, #4f2fe8, #7c5cff);
    background-size: 200% auto;
    color: #fff;
    font-family: var(--cb-font);
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(108, 71, 255, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.3);
    transition: transform var(--cb-transition), box-shadow var(--cb-transition), opacity var(--cb-transition), background-position 0.4s ease;
    will-change: transform;
    overflow: hidden;
}

#cb-launch-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.4), transparent);
    transform: skewX(-20deg);
    animation: cb-shine 4s infinite;
}

@keyframes cb-shine {
    0% {
        left: -100%;
    }

    20% {
        left: 200%;
    }

    100% {
        left: 200%;
    }
}

#cb-launch-btn .cb-btn-icon {
    font-size: 1.35rem;
    line-height: 1;
    animation: cb-pulse-icon 2.4s ease-in-out infinite;
    position: relative;
    z-index: 1;
}

#cb-launch-btn .cb-btn-label {
    position: relative;
    z-index: 1;
}

#cb-launch-btn:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 15px 35px rgba(108, 71, 255, 0.55), inset 0 2px 4px rgba(255, 255, 255, 0.4);
    background-position: right center;
}

#cb-launch-btn:active {
    transform: translateY(0) scale(0.98);
}

#cb-launch-btn.cb-btn-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px) scale(0.92);
}

/* Notification badge */
#cb-launch-btn .cb-notif-dot {
    position: absolute;
    top: 7px;
    right: 21px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ff4b6e;
    border: 2px solid #fff;
    animation: cb-dot-pop 0.4s ease both;
}

@keyframes cb-pulse-icon {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.18);
    }
}

@keyframes cb-dot-pop {
    0% {
        transform: scale(0);
    }

    80% {
        transform: scale(1.25);
    }

    100% {
        transform: scale(1);
    }
}

/* =========================================================
   CHAT WIDGET WRAPPER
   ========================================================= */
#cb-widget {
    position: fixed;
    bottom: 155px;
    /* Keep it above the new button position */
    right: 28px;
    z-index: 9999;
    width: var(--cb-widget-w);
    height: var(--cb-widget-h);
    max-height: calc(100vh - 180px);
    /* Ensures it never touches the top of the browser */
    border-radius: var(--cb-radius);
    background: var(--cb-white);
    box-shadow: var(--cb-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--cb-border);
    font-family: var(--cb-font);
    /* entrance / exit */
    opacity: 0;
    transform: translateY(24px) scale(0.94);
    pointer-events: none;
    transition: opacity var(--cb-transition), transform var(--cb-transition);
    transform-origin: bottom right;
}

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

/* =========================================================
   HEADER
   ========================================================= */
#cb-header {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 18px;
    height: var(--cb-header-h);
    background: linear-gradient(135deg, #1e0a4f 0%, #3b18a8 55%, #6c47ff 100%);
    flex-shrink: 0;
    overflow: hidden;
}

#cb-header::before {
    content: '';
    position: absolute;
    inset: -40% -20%;
    background: radial-gradient(circle, rgba(167, 139, 250, 0.22) 0%, transparent 68%);
    pointer-events: none;
}

.cb-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, #a78bfa, #6c47ff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(108, 71, 255, 0.45);
    position: relative;
    z-index: 1;
}

.cb-header-info {
    flex: 1;
    position: relative;
    z-index: 1;
}

.cb-header-name {
    display: block;
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.01em;
}

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

.cb-online-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.35);
    animation: cb-online-blink 2s ease-in-out infinite;
}

@keyframes cb-online-blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.55;
    }
}

.cb-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    position: relative;
    z-index: 1;
}

.cb-header-btn {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--cb-transition), transform var(--cb-transition);
    line-height: 1;
}

.cb-header-btn:hover {
    background: rgba(255, 255, 255, 0.24);
    transform: scale(1.08);
}

.cb-close-btn {
    font-size: 1.25rem;
    font-weight: 300;
}

/* =========================================================
   MESSAGES AREA
   ========================================================= */
#cb-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px 10px;
    background: var(--cb-bg);
    scroll-behavior: smooth;
}

#cb-messages::-webkit-scrollbar {
    width: 4px;
}

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

#cb-messages::-webkit-scrollbar-thumb {
    background: rgba(108, 71, 255, 0.22);
    border-radius: 99px;
}

/* ── Message row ── */
.cb-msg-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 14px;
    animation: cb-msg-in 0.32s cubic-bezier(.4, 0, .2, 1) both;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Bot message ── */
.cb-msg-row.cb-bot {
    justify-content: flex-start;
}

.cb-msg-row.cb-bot .cb-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #a78bfa, #6c47ff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    align-self: flex-end;
}

.cb-msg-row.cb-bot .cb-bubble {
    background: #fff;
    color: #1e0a4f;
    border-radius: var(--cb-radius-msg) var(--cb-radius-msg) var(--cb-radius-msg) 4px;
    box-shadow: 0 3px 12px rgba(60, 20, 180, 0.1);
    border: 1px solid rgba(108, 71, 255, 0.1);
}

/* ── User message ── */
.cb-msg-row.cb-user {
    justify-content: flex-end;
}

.cb-msg-row.cb-user .cb-bubble {
    background: linear-gradient(135deg, var(--cb-purple), var(--cb-purple-dark));
    color: #fff;
    border-radius: var(--cb-radius-msg) var(--cb-radius-msg) 4px var(--cb-radius-msg);
    box-shadow: 0 6px 20px rgba(108, 71, 255, 0.35);
}

/* ── Bubble base ── */
.cb-bubble {
    max-width: 82%;
    padding: 10px 14px;
    font-size: 0.88rem;
    line-height: 1.6;
    word-break: break-word;
}

.cb-bubble-inner {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cb-bubble-text {
    white-space: pre-line;
}

/* Timestamp inside bubble */
.cb-msg-time {
    font-size: 0.68rem;
    opacity: 0.65;
    margin-top: 2px;
    text-align: right;
}

.cb-msg-row.cb-bot .cb-msg-time {
    text-align: left;
    color: #6b7280;
    opacity: 0.85;
}

/* Action button inside bot bubble */
.cb-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    padding: 7px 14px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--cb-purple), var(--cb-purple-dark));
    color: #fff !important;
    font-size: 0.8rem;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 4px 14px rgba(108, 71, 255, 0.38);
    transition: transform var(--cb-transition), box-shadow var(--cb-transition);
    align-self: flex-start;
    border: none;
    cursor: pointer;
}

.cb-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(108, 71, 255, 0.5);
    color: #fff;
}

/* =========================================================
   TYPING INDICATOR
   ========================================================= */
.cb-typing-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 14px;
    animation: cb-msg-in 0.32s cubic-bezier(.4, 0, .2, 1) both;
}

.cb-typing-row .cb-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #a78bfa, #6c47ff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.cb-typing-bubble {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
    background: #fff;
    border-radius: var(--cb-radius-msg) var(--cb-radius-msg) var(--cb-radius-msg) 4px;
    box-shadow: 0 3px 12px rgba(60, 20, 180, 0.1);
    border: 1px solid rgba(108, 71, 255, 0.1);
}

.cb-typing-label {
    font-size: 0.78rem;
    color: #6b7280;
    font-weight: 500;
    margin-right: 4px;
}

.cb-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--cb-purple);
    animation: cb-typing-bounce 1.2s ease-in-out infinite;
}

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

.cb-typing-dot: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;
    }
}

/* =========================================================
   SUGGESTIONS SECTION
   ========================================================= */
.cb-suggestions-wrap {
    padding: 8px 16px 6px;
    background: var(--cb-bg);
    flex-shrink: 0;
    border-top: 1px solid rgba(108, 71, 255, 0.08);
}

.cb-suggestions-label {
    font-size: 0.73rem;
    font-weight: 700;
    color: #6c47ff;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.cb-suggestions-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 210px;
    overflow-y: auto;
    padding-right: 2px;
}

.cb-suggestions-list::-webkit-scrollbar {
    width: 3px;
}

.cb-suggestions-list::-webkit-scrollbar-thumb {
    background: rgba(108, 71, 255, 0.2);
    border-radius: 99px;
}

/* Inline suggestions (after each answer) */
.cb-inline-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.cb-inline-suggestions .cb-sugg-btn {
    font-size: 0.78rem;
    padding: 5px 12px;
    border-radius: 999px;
}

.cb-sugg-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 14px;
    border: 1.5px solid rgba(108, 71, 255, 0.18);
    border-radius: 12px;
    background: #fff;
    color: #1e0a4f;
    font-family: var(--cb-font);
    font-size: 0.84rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background var(--cb-transition), border-color var(--cb-transition),
        color var(--cb-transition), transform var(--cb-transition), box-shadow var(--cb-transition);
    width: 100%;
    line-height: 1.4;
}

.cb-inline-suggestions .cb-sugg-btn {
    width: auto;
}

.cb-sugg-btn:hover {
    background: var(--cb-purple-light);
    border-color: var(--cb-purple);
    color: var(--cb-purple-dark);
    transform: translateX(2px);
    box-shadow: 0 4px 14px rgba(108, 71, 255, 0.14);
}

.cb-sugg-btn:active {
    transform: scale(0.97);
}

.cb-sugg-btn .cb-sugg-icon {
    flex-shrink: 0;
    color: var(--cb-purple);
    font-size: 0.8rem;
    opacity: 0.7;
}

/* =========================================================
   FOOTER / POWERED BY
   ========================================================= */
#cb-footer {
    padding: 7px 16px;
    background: #fff;
    border-top: 1px solid rgba(108, 71, 255, 0.08);
    text-align: center;
    flex-shrink: 0;
}

.cb-powered {
    font-size: 0.7rem;
    color: #a0aec0;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.cb-powered span {
    color: var(--cb-purple);
    font-weight: 700;
}

/* =========================================================
   "YOU MAY ALSO ASK" BLOCK (after answer in chat)
   ========================================================= */
.cb-also-ask-row {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 14px;
    animation: cb-msg-in 0.32s cubic-bezier(.4, 0, .2, 1) both;
}

.cb-also-ask-inner {
    max-width: 100%;
}

.cb-also-ask-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: #6c47ff;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 7px;
    padding-left: 2px;
}

.cb-also-ask-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.cb-also-ask-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border: 1.5px solid rgba(108, 71, 255, 0.22);
    border-radius: 999px;
    background: #fff;
    color: #1e0a4f;
    font-family: var(--cb-font);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--cb-transition), border-color var(--cb-transition),
        color var(--cb-transition), transform var(--cb-transition);
    max-width: 100%;
    text-align: left;
    line-height: 1.35;
    word-break: break-word;
}

.cb-also-ask-pill:hover {
    background: var(--cb-purple-light);
    border-color: var(--cb-purple);
    color: var(--cb-purple-dark);
    transform: translateY(-2px);
}

/* =========================================================
   WELCOME MESSAGE
   ========================================================= */
.cb-welcome-bubble {
    position: relative;
}

.cb-welcome-bubble::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(108, 71, 255, 0.04), transparent);
    pointer-events: none;
}

/* =========================================================
   RESPONSIVE — MOBILE
   ========================================================= */
@media (max-width: 480px) {
    :root {
        --cb-widget-w: calc(100vw - 24px);
        --cb-widget-h: calc(100dvh - 175px);
        /* Adjusted for new bottom position */
    }

    #cb-widget {
        bottom: 150px;
        right: 12px;
        left: 12px;
        width: auto;
        max-height: var(--cb-widget-h);
        border-radius: 16px;
    }

    #cb-launch-btn {
        bottom: 80px;
        right: 16px;
        padding: 12px 18px;
        font-size: 0.88rem;
    }

    .cb-bubble {
        max-width: 90%;
    }
}

@media (max-width: 360px) {
    #cb-launch-btn .cb-btn-label {
        display: none;
    }

    #cb-launch-btn {
        padding: 13px;
        gap: 0;
        border-radius: 50%;
    }
}

/* =========================================================
   UTILITY — cursor blink for typewriter
   ========================================================= */
.cb-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: currentColor;
    margin-left: 1px;
    vertical-align: text-bottom;
    animation: cb-cursor-blink 0.7s step-end infinite;
}

@keyframes cb-cursor-blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* =========================================================
   END-OF-CONVERSATION CONTACT CARD
   ========================================================= */
.cb-end-links {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-top: 8px;
}

.cb-end-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1.5px solid rgba(108, 71, 255, 0.22);
    background: var(--cb-purple-light);
    color: var(--cb-purple-dark) !important;
    font-family: var(--cb-font);
    font-size: 0.82rem;
    font-weight: 700;
    text-decoration: none;
    transition: background var(--cb-transition), border-color var(--cb-transition),
        transform var(--cb-transition), box-shadow var(--cb-transition);
    align-self: flex-start;
    animation: cb-msg-in 0.3s ease both;
}

.cb-end-link-btn:hover {
    background: var(--cb-purple);
    border-color: var(--cb-purple-dark);
    color: #fff !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(108, 71, 255, 0.35);
}