/* ============================================
   Suphanna Solutions AI Chatbot Widget v2.0
   Colors: Navy #03345c | Orange #f57921 | Cyan #00AEEF
   Position: Bottom RIGHT
   ============================================ */

/* ── SITE-WIDE SECURITY (ANTI-COPY) ───────── */
html,
body {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* Allow interaction only in input fields and the chatbot text area */
input,
textarea,
#chat-input,
#chat-messages {
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
}

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

#suphanna-chat-widget {
    position: fixed;
    bottom: 28px;
    right: 28px;
    /* ← BOTTOM RIGHT */
    z-index: 9999;
    font-family: 'Inter', sans-serif;
}

/* ── Toggle Button ──────────────────────────── */
#chat-toggle-btn {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid #03345c;
    cursor: pointer;
    box-shadow: 0 6px 28px rgba(3, 52, 92, 0.35), 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
    padding: 0;
}

#chat-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 36px rgba(3, 52, 92, 0.45);
}

/* ── Notification Badge ───────────────────────── */
#chat-notification-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #f57921; /* Suphanna Orange */
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    z-index: 2;
    animation: bounceBadge 2s infinite;
}

#chat-toggle-btn.pulse {
    animation: buttonPulse 2s infinite;
}

@keyframes bounceBadge {
    0%, 20%, 50%, 80%, 100% {transform: translateY(0);}
    40% {transform: translateY(-5px);}
    60% {transform: translateY(-3px);}
}

@keyframes buttonPulse {
    0% { box-shadow: 0 0 0 0 rgba(245, 121, 33, 0.5); transform: scale(1); }
    70% { box-shadow: 0 0 0 15px rgba(245, 121, 33, 0); transform: scale(1.05); }
    100% { box-shadow: 0 0 0 0 rgba(245, 121, 33, 0); transform: scale(1); }
}

#chat-toggle-btn.open #chat-notification-badge {
    display: none;
}

.toggle-logo-wrap {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.25s, transform 0.3s;
    position: absolute;
}

.toggle-logo {
    width: 54px;
    height: 54px;
    object-fit: contain;
    border-radius: 50%;
    padding: 4px;
}

.toggle-logo-fallback {
    width: 30px;
    height: 30px;
    color: #03345c;
}

.icon-close {
    width: 26px;
    height: 26px;
    color: #03345c;
    opacity: 0;
    position: absolute;
    transform: rotate(-90deg) scale(0.6);
    transition: opacity 0.25s, transform 0.3s;
}

#chat-toggle-btn.open .toggle-logo-wrap {
    opacity: 0;
    transform: rotate(90deg) scale(0.6);
}

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

/* Notification dot */
#chat-notif-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    background: #f57921;
    border-radius: 50%;
    border: 2px solid #fff;
    animation: pulse-dot 2s infinite;
    display: none;
}

@keyframes pulse-dot {

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

    50% {
        transform: scale(1.35);
        opacity: 0.7;
    }
}

/* ── Hint Bubble ─────────────────────────────── */
#chat-bubble-hint {
    position: absolute;
    bottom: 80px;
    right: 0;
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-radius: 16px 16px 4px 16px;
    padding: 10px 14px 10px 14px;
    font-size: 13px;
    color: #1e293b;
    white-space: nowrap;
    box-shadow: 0 8px 24px rgba(3, 52, 92, 0.14);
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transform: translateY(8px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
}

#chat-bubble-hint.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

#close-hint-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: #94a3b8;
    line-height: 1;
    padding: 0 0 0 4px;
}

#close-hint-btn:hover {
    color: #475569;
}

/* ── Chat Window ─────────────────────────────── */
#chat-window {
    position: absolute;
    bottom: 84px;
    right: 0;
    /* ← Anchored to the right */
    width: 310px;
    max-height: 480px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 24px 64px rgba(3, 52, 92, 0.2), 0 4px 16px rgba(0, 0, 0, 0.07);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    /* ← Expands from bottom right */
    transform: scale(0.85) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
}

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

/* ── Header ──────────────────────────────────── */
#chat-header {
    background: linear-gradient(135deg, #03345c 0%, #055a9e 100%);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    position: relative;
}

.chat-header-logo {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    padding: 3px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.chat-header-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.chat-logo-fallback {
    width: 26px;
    height: 26px;
    background: linear-gradient(135deg, #f57921, #e06310);
    border-radius: 50%;
    align-items: center;
    justify-content: center;
}

.chat-logo-fallback svg {
    width: 16px;
    height: 16px;
    color: #fff;
}

.chat-header-info {
    flex: 1;
}

.chat-header-info h4 {
    color: #fff;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 13.5px;
    margin: 0 0 2px;
    letter-spacing: 0.01em;
}

.chat-header-info p {
    color: #00AEEF;
    font-size: 11px;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 5px;
}

.online-dot {
    width: 7px;
    height: 7px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
    animation: pulse-dot 2s infinite;
    flex-shrink: 0;
}

#chat-close-btn {
    background: rgba(255, 255, 255, 0.12);
    border: none;
    border-radius: 8px;
    width: 30px;
    height: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

#chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.22);
}

#chat-close-btn svg {
    width: 14px;
    height: 14px;
    color: #fff;
}

/* ── Messages Area ───────────────────────────── */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
    min-height: 0;
}

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

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

#chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

/* Message bubbles */
.msg {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    animation: msg-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes msg-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.95);
    }

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

.msg.bot {
    flex-direction: row;
}

.msg.user {
    flex-direction: row-reverse;
}

/* Bot message avatar with logo */
.msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #fff;
    border: 1.5px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    padding: 2px;
}

.msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.msg-avatar-fallback {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #03345c, #055a9e);
    border-radius: 50%;
    align-items: center;
    justify-content: center;
}

.msg-avatar-fallback svg {
    width: 14px;
    height: 14px;
    color: #fff;
}

.msg-bubble {
    max-width: 78%;
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
}

.msg.bot .msg-bubble {
    background: #fff;
    color: #1e293b;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
}

.msg.user .msg-bubble {
    background: linear-gradient(135deg, #03345c, #055a9e);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Quick reply chips */
.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px 12px;
    background: #f8fafc;
}

.qr-chip {
    background: #fff;
    border: 1.5px solid #03345c;
    color: #03345c;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    font-family: 'Inter', sans-serif;
}

.qr-chip:hover {
    background: #03345c;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(3, 52, 92, 0.2);
}

/* Typing indicator */
.typing-bubble {
    display: flex;
    gap: 4px;
    padding: 12px 14px;
    background: #fff;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    width: fit-content;
}

.typing-bubble span {
    width: 7px;
    height: 7px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typing 1.2s infinite;
}

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

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

@keyframes typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* Lead form */
.lead-form {
    background: linear-gradient(135deg, #f0f7ff, #e8f4ff);
    border: 1.5px solid #bfdbfe;
    border-radius: 14px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 78%;
}

.lead-form-title {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 13px;
    color: #03345c;
    margin: 0 0 4px;
}

.lead-form input {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    color: #1e293b;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
    background: #fff;
}

.lead-form input:focus {
    border-color: #03345c;
}

.lead-form input::placeholder {
    color: #94a3b8;
}

.lead-form button {
    background: linear-gradient(135deg, #f57921, #e06310);
    color: #fff;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    font-family: 'Montserrat', sans-serif;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
    margin-top: 2px;
}

.lead-form button:hover {
    opacity: 0.92;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 121, 33, 0.35);
}

/* ── Input Area ──────────────────────────────── */
#chat-input-area {
    padding: 12px 14px;
    background: #fff;
    border-top: 1px solid #f1f5f9;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

#chat-input {
    flex: 1;
    border: 1.5px solid #e2e8f0;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 13.5px;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.2s;
    color: #1e293b;
    background: #f8fafc;
}

#chat-input:focus {
    border-color: #03345c;
    background: #fff;
}

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

#chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f57921, #e06310);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 3px 10px rgba(245, 121, 33, 0.4);
}

#chat-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 16px rgba(245, 121, 33, 0.5);
}

#chat-send-btn svg {
    width: 17px;
    height: 17px;
    color: #fff;
}

/* ── Footer ──────────────────────────────────── */
#chat-footer {
    padding: 7px 0 9px;
    text-align: center;
    font-size: 10.5px;
    color: #94a3b8;
    background: #fff;
    border-top: 1px solid #f1f5f9;
    letter-spacing: 0.01em;
}

#chat-footer span {
    color: #f57921;
    font-weight: 700;
}

/* ── Responsive ──────────────────────────────── */
@media (max-width: 440px) {
    #suphanna-chat-widget {
        right: 14px;
        bottom: 14px;
    }

    #chat-window {
        width: calc(100vw - 28px);
        right: 0;
    }
}