/* DHA Assistant Chatbot Premium Styles */
:root {
    --chat-accent: #a855f7; /* Soft purple */
    --chat-accent-dark: #9333ea;
    --chat-secondary: #ec4899; /* Soft pink */
    --chat-gradient: linear-gradient(135deg, var(--chat-accent), var(--chat-secondary));
    
    /* Default Light/Airy Theme */
    --chatbot-bg: rgba(245, 243, 255, 0.95); /* Less transparent for readability */
    --chatbot-text: #1e293b;
    --chatbot-muted: #64748b;
    --chatbot-card: rgba(255, 255, 255, 1);
    --chatbot-border: rgba(168, 85, 247, 0.2);
    --chatbot-glass: rgba(255, 255, 255, 0.8);
    --chatbot-shadow: 0 30px 60px -12px rgba(168, 85, 247, 0.2), 0 0 40px rgba(236, 72, 153, 0.1);
    --chatbot-input-bg: #ffffff;
}

/* Explicit Dark Mode Support */
html.dark, [data-theme="dark"], body.dark-mode {
    --chatbot-bg: rgba(15, 23, 42, 0.95);
    --chatbot-text: #f8fafc;
    --chatbot-muted: #cbd5e1;
    --chatbot-card: rgba(30, 41, 59, 0.9);
    --chatbot-border: rgba(255, 255, 255, 0.15);
    --chatbot-glass: rgba(15, 23, 42, 0.6);
    --chatbot-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.5), 0 0 40px rgba(139, 92, 246, 0.15);
    --chatbot-input-bg: rgba(255, 255, 255, 0.05);
}

@media (prefers-color-scheme: dark) {
    :root {
        --chatbot-bg: rgba(15, 23, 42, 0.95);
        --chatbot-text: #f8fafc;
        --chatbot-muted: #cbd5e1;
        --chatbot-card: rgba(30, 41, 59, 0.9);
        --chatbot-border: rgba(255, 255, 255, 0.15);
        --chatbot-glass: rgba(15, 23, 42, 0.6);
        --chatbot-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.5), 0 0 40px rgba(139, 92, 246, 0.15);
        --chatbot-input-bg: rgba(255, 255, 255, 0.05);
    }
}

#dha-chatbot-container {
    pointer-events: none;
    font-family: 'Inter', sans-serif;
    z-index: 999999 !important;
}

/* Toggle Button */
.chatbot-toggle-btn {
    pointer-events: auto !important;
    position: fixed !important;
    right: 25px !important;
    bottom: 90px !important;
    width: 60px !important;
    height: 60px !important;
    border-radius: 50%;
    background: var(--chat-gradient);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 24px;
    box-shadow: 0 10px 25px rgba(139, 92, 246, 0.4);
    z-index: 999999 !important;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulseChat 2s infinite;
}

@keyframes pulseChat {
    0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(99, 102, 241, 0); }
    100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

.toggle-icon-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-icon-wrapper i {
    position: absolute;
    transition: all 0.3s ease;
}

.toggle-icon-wrapper .fa-times {
    opacity: 0;
    transform: rotate(-90deg) scale(0);
}

.chatbot-window:not(.hidden) ~ .chatbot-toggle-btn .fa-comment-dots {
    opacity: 0;
    transform: rotate(90deg) scale(0);
}

.chatbot-window:not(.hidden) ~ .chatbot-toggle-btn .fa-times {
    opacity: 1;
    transform: rotate(0) scale(1);
}

.chatbot-toggle-btn:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 15px 30px rgba(99, 102, 241, 0.5);
}

.toggle-tooltip {
    position: absolute;
    right: 65px;
    background: var(--chatbot-bg);
    color: var(--chatbot-text);
    padding: 6px 12px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    opacity: 0;
    transform: translateX(10px);
    transition: all 0.3s ease;
    pointer-events: none;
    border: 1px solid var(--chatbot-border);
    background: linear-gradient(135deg, var(--chatbot-bg) 0%, var(--chatbot-card) 50%, var(--chatbot-bg) 100%);
    background-size: 200% auto;
    animation: shimmer 2s linear infinite, floatTooltip 3s ease-in-out infinite;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@keyframes floatTooltip {
    0%, 100% { transform: translateX(0) translateY(0); }
    50% { transform: translateX(0) translateY(-5px); }
}

@keyframes shimmer {
    to { background-position: 200% center; }
}

.chatbot-toggle-btn:hover .toggle-tooltip {
    opacity: 1;
    transform: translateX(0);
    animation: shimmer 2s linear infinite, floatTooltip 3s ease-in-out infinite;
}

/* Chat Window */
.chatbot-window {
    pointer-events: auto !important;
    position: fixed;
    right: 25px;
    bottom: 150px;
    width: 360px;
    height: 600px;
    max-height: calc(100vh - 180px);
    background: var(--chatbot-bg);
    backdrop-filter: blur(30px) saturate(200%);
    -webkit-backdrop-filter: blur(30px) saturate(200%);
    border: 1px solid var(--chatbot-border);
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    z-index: 1000000 !important;
    box-shadow: var(--chatbot-shadow);
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    transform-origin: bottom right;
}

.chatbot-window.hidden {
    opacity: 0;
    transform: scale(0.9) translateY(40px) translateX(20px);
    pointer-events: none !important;
}

/* Header */
.chatbot-header {
    padding: 12px 20px;
    background: var(--chatbot-glass);
    border-bottom: 1px solid var(--chatbot-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.bot-info-center {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--chatbot-card);
    padding: 6px 16px;
    border-radius: 50px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    border: 1px solid var(--chatbot-border);
}

.bot-avatar-small {
    width: 24px;
    height: 24px;
    background: var(--chat-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
}

.bot-info-center h6 {
    margin: 0;
    color: var(--chatbot-text);
    font-weight: 700;
    font-size: 0.9rem;
}

.bot-avatar {
    position: relative;
    width: 36px;
    height: 36px;
}

.avatar-inner {
    width: 100%;
    height: 100%;
    background: var(--chat-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    box-shadow: 0 4px 10px rgba(139, 92, 246, 0.3);
}

.avatar-status-indicator {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    background: #10b981;
    border: 2.5px solid var(--chatbot-bg);
    border-radius: 50%;
}

.bot-name h6 {
    margin: 0;
    color: var(--chatbot-text);
    font-weight: 700;
    font-size: 0.95rem;
}

.status-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.status-dot {
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 10px #10b981;
}

.status-text {
    font-size: 11px;
    color: #10b981;
    font-weight: 600;
    text-transform: uppercase;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.control-btn {
    background: var(--chatbot-card);
    border: 1px solid var(--chatbot-border);
    color: var(--chatbot-muted);
    width: 36px;
    height: 36px;
    border-radius: 50%; /* Circle like reference */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    pointer-events: auto !important;
}

.control-btn:hover {
    background: var(--chat-gradient);
    color: white;
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(168, 85, 247, 0.3);
}

.control-btn.close:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* Body */
.chatbot-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    scrollbar-width: thin;
    scrollbar-color: var(--chatbot-border) transparent;
}

.chatbot-body::-webkit-scrollbar { width: 5px; }
.chatbot-body::-webkit-scrollbar-thumb { background: var(--chatbot-border); border-radius: 10px; }

/* Lead Form */
.lead-welcome {
    text-align: center;
    margin-bottom: 24px;
}

.welcome-icon { font-size: 32px; margin-bottom: 10px; }
.lead-welcome h5 { color: var(--chatbot-text); font-weight: 800; font-size: 1.1rem; margin-bottom: 6px; }
.lead-welcome p { color: var(--chatbot-muted); font-size: 13px; line-height: 1.4; }

/* Fix Floating Labels */
.form-floating > .form-control {
    background: var(--chatbot-glass);
    border: 1px solid var(--chatbot-border);
    color: var(--chatbot-text);
    border-radius: 16px;
    height: 58px;
    padding-top: 1.625rem;
    padding-bottom: .625rem;
}

.form-floating > label {
    color: var(--chatbot-muted);
    padding-left: 16px;
}

.form-floating > label::after {
    background-color: transparent !important;
}

.form-floating > .form-control:focus {
    background: var(--chatbot-glass);
    border-color: var(--chat-accent);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
    color: var(--chatbot-text);
}

.form-hint {
    margin-top: 8px;
    font-size: 11px;
    color: var(--chatbot-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-chat-submit {
    background: var(--chat-gradient);
    border: none;
    color: white !important;
    padding: 16px;
    border-radius: 16px;
    font-weight: 800;
    letter-spacing: 0.5px;
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-chat-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(99, 102, 241, 0.4);
    filter: brightness(1.1);
}

/* Messages */
.chatbot-messages-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.message {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 20px;
    font-size: 14.5px;
    line-height: 1.6;
    animation: messagePop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    transform-origin: bottom left;
}

@keyframes messagePop {
    0% { opacity: 0; transform: scale(0.8) translateY(20px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

.message.bot {
    align-self: flex-start;
    background: var(--chatbot-card) !important;
    color: var(--chatbot-text) !important;
    border-bottom-left-radius: 4px;
    border: 1px solid var(--chatbot-border) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05) !important;
}

.message.user {
    align-self: flex-end;
    background: var(--chat-gradient) !important;
    color: #ffffff !important;
    border-bottom-right-radius: 4px;
    box-shadow: 0 8px 20px rgba(168, 85, 247, 0.25) !important;
    transform-origin: bottom right;
}

/* Typing Indicator */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--chatbot-card);
    padding: 12px 18px;
    border-radius: 20px;
    border-bottom-left-radius: 4px;
    border: 1px solid var(--chatbot-border);
    margin-bottom: 10px;
    align-self: flex-start;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    animation: messagePop 0.3s forwards;
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    background-color: var(--chat-accent);
    border-radius: 50%;
    animation: typingPulse 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
.typing-indicator span:nth-child(3) { animation-delay: 0s; }

@keyframes typingPulse {
    0%, 80%, 100% { 
        transform: scale(0.4) translateY(0); 
        opacity: 0.3; 
    }
    40% { 
        transform: scale(1.2) translateY(-4px); 
        opacity: 1; 
        background-color: #d8b4fe; /* Lebih terang saat membesar */
    }
}

/* Quick Replies */
.quick-replies-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.quick-reply-btn {
    background: var(--chatbot-glass);
    border: 1px solid var(--chatbot-border);
    color: var(--chatbot-muted);
    padding: 10px 16px;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.quick-reply-btn:hover {
    background: var(--chat-gradient);
    border-color: transparent;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(139, 92, 246, 0.3);
}

/* Footer & Input */
.chatbot-footer {
    padding: 16px 20px;
    background: var(--chatbot-glass); 
    border-top: 1px solid var(--chatbot-border);
    backdrop-filter: blur(10px);
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--chatbot-input-bg);
    border: 1px solid var(--chatbot-border);
    border-radius: 30px; /* Fully rounded like reference */
    padding: 6px 6px 6px 16px;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03); /* Subtle outer shadow */
}

.input-wrapper:focus-within {
    border-color: var(--chat-accent);
    background: var(--chatbot-input-bg);
    box-shadow: 0 6px 20px rgba(168, 85, 247, 0.15);
    transform: translateY(-2px);
}

#chat-input {
    flex: 1;
    background-color: transparent !important;
    background: transparent !important;
    border: none !important;
    color: var(--chatbot-text) !important;
    font-size: 14.5px;
    outline: none !important;
    resize: none;
    max-height: 100px;
    padding: 10px 0;
    line-height: 1.5;
    box-shadow: none !important;
}

#chat-input::placeholder {
    color: var(--chatbot-muted) !important;
    font-weight: 500;
}

.send-btn {
    background: var(--chatbot-card);
    color: var(--chat-accent);
    border: 1px solid var(--chatbot-border);
    width: 40px;
    height: 40px;
    border-radius: 50%; /* Circle */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.send-btn:not(:disabled):hover {
    transform: scale(1.1);
    background: var(--chat-gradient);
    color: white;
    border-color: transparent;
}

.send-btn:disabled {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.2);
    cursor: not-allowed;
}

.send-btn:not(:disabled):hover {
    transform: scale(1.1);
    background: var(--chat-secondary);
}

.btn-end-chat {
    width: 100%;
    margin-top: 12px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #10b981;
    padding: 12px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    pointer-events: auto !important;
}

.btn-end-chat:hover {
    background: #10b981;
    border-color: #10b981;
    color: white;
    box-shadow: 0 5px 15px rgba(16, 185, 129, 0.3);
}

.hidden { display: none !important; }

@media (max-width: 480px) {
    .chatbot-window {
        right: 15px;
        bottom: 90px;
        width: calc(100% - 30px);
        height: min(600px, 80vh);
        border-radius: 24px;
    }
    .chatbot-toggle-btn {
        right: 20px;
        bottom: 20px;
    }
}
