/**
 * Besan CMS - Ultra Luxury Chatbot & Live Support Widget
 * Glassmorphic Dark Gold Aesthetic
 */

:root {
    --chat-gold: #bc9a61;
    --chat-gold-light: #e8ddca;
    --chat-gold-dark: #8c6d3b;
    --chat-gold-glow: rgba(188, 154, 97, 0.4);
    --chat-gold-subtle: rgba(188, 154, 97, 0.15);
    --chat-bg: rgba(12, 10, 8, 0.96);
    --chat-card-bg: rgba(22, 18, 14, 0.85);
    --chat-border: rgba(188, 154, 97, 0.28);
    --chat-text: #f5f5f5;
    --chat-muted: #a8a29e;
}

/* ==========================================================================
   FLOATING LAUNCHER BUTTON (Right Side - Next to WhatsApp)
   ========================================================================== */
.besan-chat-launcher {
    position: fixed;
    bottom: 1.5rem;
    right: 5.8rem;
    left: auto;
    z-index: 9998;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    cursor: pointer;
    user-select: none;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.besan-chat-launcher:hover {
    transform: translateY(-4px) scale(1.03);
}

.besan-chat-launcher-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1c1611 0%, #0c0a08 100%);
    border: 2px solid var(--chat-gold);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.7), 0 0 20px var(--chat-gold-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    color: var(--chat-gold-light);
    font-size: 1.5rem;
    transition: all 0.3s ease;
}

.besan-chat-launcher:hover .besan-chat-launcher-btn {
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.85), 0 0 30px rgba(188, 154, 97, 0.6);
    border-color: #fff;
    color: #fff;
}

.besan-chat-pulse-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #2ecc71;
    border: 2px solid #0c0a08;
    box-shadow: 0 0 8px #2ecc71;
    animation: chatPulse 2s infinite;
}

@keyframes chatPulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(46, 204, 113, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(46, 204, 113, 0); }
}

.besan-chat-teaser-bubble {
    background: rgba(18, 15, 12, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--chat-border);
    border-radius: 12px;
    padding: 0.55rem 1rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--chat-gold-light);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    animation: chatFloatBubble 3s ease-in-out infinite;
}

@keyframes chatFloatBubble {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* ==========================================================================
   CHAT WINDOW MODAL
   ========================================================================== */
.besan-chat-window {
    position: fixed;
    bottom: 90px;
    right: 1.5rem;
    left: auto;
    width: 380px;
    max-width: calc(100vw - 30px);
    height: 580px;
    max-height: calc(100vh - 120px);
    background: var(--chat-bg);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border: 1.5px solid var(--chat-border);
    border-radius: 20px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.9), 0 0 35px var(--chat-gold-subtle);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.besan-chat-window.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* Header */
.besan-chat-header {
    padding: 1.1rem 1.2rem;
    background: linear-gradient(180deg, rgba(28, 23, 18, 0.9) 0%, rgba(14, 12, 9, 0.95) 100%);
    border-bottom: 1px solid var(--chat-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.besan-chat-agent-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.besan-chat-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #0d0b09;
    border: 1.5px solid var(--chat-gold);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.besan-chat-avatar img {
    width: 80%;
    height: 80%;
    object-fit: contain;
}

.besan-chat-title-group h3 {
    font-size: 0.98rem;
    font-weight: 800;
    color: var(--chat-gold-light);
    line-height: 1.2;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.besan-chat-title-group p {
    font-size: 0.75rem;
    color: #2ecc71;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.15rem;
}

.besan-chat-title-group p .live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #2ecc71;
    box-shadow: 0 0 6px #2ecc71;
}

.besan-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.besan-chat-btn-icon {
    background: transparent;
    border: none;
    color: var(--chat-muted);
    font-size: 1.2rem;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.besan-chat-btn-icon:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

/* Body / Message Stream */
.besan-chat-body {
    flex: 1;
    padding: 1.2rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scroll-behavior: smooth;
}

.besan-chat-body::-webkit-scrollbar {
    width: 5px;
}
.besan-chat-body::-webkit-scrollbar-thumb {
    background: rgba(188, 154, 97, 0.3);
    border-radius: 99px;
}

/* Message Rows */
.chat-msg-row {
    display: flex;
    gap: 0.6rem;
    max-width: 88%;
    animation: chatMsgIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes chatMsgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-msg-row.bot,
.chat-msg-row.agent {
    align-self: flex-start;
}

.chat-msg-row.visitor {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(188, 154, 97, 0.15);
    border: 1px solid var(--chat-gold);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--chat-gold);
    flex-shrink: 0;
    margin-top: 2px;
}

.chat-msg-bubble-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.chat-msg-bubble {
    padding: 0.75rem 1rem;
    border-radius: 14px;
    font-size: 0.88rem;
    line-height: 1.55;
    word-break: break-word;
    position: relative;
}

.chat-msg-row.bot .chat-msg-bubble {
    background: var(--chat-card-bg);
    border: 1px solid var(--chat-border);
    color: var(--chat-text);
    border-top-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.chat-msg-row.agent .chat-msg-bubble {
    background: rgba(28, 23, 17, 0.95);
    border: 1.5px solid var(--chat-gold);
    color: #fff;
    border-top-right-radius: 4px;
    box-shadow: 0 4px 15px var(--chat-gold-subtle);
}

.chat-msg-row.visitor .chat-msg-bubble {
    background: linear-gradient(135deg, var(--chat-gold) 0%, var(--chat-gold-dark) 100%);
    color: #0c0a08;
    font-weight: 600;
    border-top-left-radius: 4px;
    box-shadow: 0 4px 15px var(--chat-gold-glow);
}

.chat-msg-time {
    font-size: 0.68rem;
    color: var(--chat-muted);
    align-self: flex-start;
    padding: 0 0.3rem;
}
.chat-msg-row.visitor .chat-msg-time {
    align-self: flex-end;
}

/* Interactive Option Pills */
.chat-options-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.4rem;
}

.chat-option-btn {
    background: rgba(188, 154, 97, 0.08);
    border: 1px solid var(--chat-border);
    color: var(--chat-gold-light);
    padding: 0.6rem 0.9rem;
    border-radius: 10px;
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-align: right;
    transition: all 0.25s ease;
}

.chat-option-btn:hover {
    background: linear-gradient(135deg, var(--chat-gold) 0%, var(--chat-gold-dark) 100%);
    color: #0c0a08;
    border-color: var(--chat-gold);
    transform: translateX(-4px);
    box-shadow: 0 4px 12px var(--chat-gold-glow);
}

.chat-option-btn i {
    font-size: 1rem;
}

/* In-Chat Quick Form */
.chat-inline-form {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--chat-border);
    border-radius: 12px;
    padding: 0.9rem;
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.chat-form-input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--chat-border);
    border-radius: 8px;
    padding: 0.55rem 0.8rem;
    color: #fff;
    font-size: 0.85rem;
    outline: none;
    width: 100%;
}

.chat-form-input:focus {
    border-color: var(--chat-gold);
    background: rgba(0, 0, 0, 0.6);
}

.chat-form-submit-btn {
    background: linear-gradient(135deg, var(--chat-gold) 0%, var(--chat-gold-dark) 100%);
    color: #080706;
    border: none;
    border-radius: 8px;
    padding: 0.6rem;
    font-size: 0.85rem;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: all 0.25s ease;
}

.chat-form-submit-btn:hover {
    box-shadow: 0 4px 12px var(--chat-gold-glow);
    transform: translateY(-1px);
}

/* Typing Simulator Indicator */
.chat-typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0.6rem 0.9rem;
    background: var(--chat-card-bg);
    border: 1px solid var(--chat-border);
    border-radius: 14px;
    border-top-right-radius: 4px;
    width: fit-content;
}

.chat-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--chat-gold);
    animation: chatTypingBounce 1.4s infinite ease-in-out both;
}

.chat-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.chat-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes chatTypingBounce {
    0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Footer / Input Area */
.besan-chat-footer {
    padding: 0.8rem 1rem;
    background: rgba(18, 15, 12, 0.95);
    border-top: 1px solid var(--chat-border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.besan-chat-input-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.besan-chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--chat-border);
    border-radius: 20px;
    padding: 0.65rem 1rem;
    font-size: 0.88rem;
    color: #fff;
    outline: none;
    transition: all 0.25s ease;
}

.besan-chat-input:focus {
    border-color: var(--chat-gold);
    background: rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 10px var(--chat-gold-subtle);
}

.besan-chat-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-gold) 0%, var(--chat-gold-dark) 100%);
    border: none;
    color: #080706;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.25s ease;
    flex-shrink: 0;
}

.besan-chat-send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 12px var(--chat-gold-glow);
}

.besan-chat-quick-handoff {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.72rem;
    color: var(--chat-muted);
}

.besan-chat-handoff-link {
    color: var(--chat-gold-light);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
    font-weight: 700;
}

.besan-chat-handoff-link:hover {
    color: #fff;
    text-decoration: underline;
}

@media (max-width: 768px) {
    .besan-chat-launcher {
        bottom: 4.8rem;
        right: 1.25rem;
        left: auto;
    }
    .besan-chat-window {
        bottom: 0;
        left: 0;
        right: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
}
