/* DHA Assistant Chatbot Styles */
:root {
    --chat-accent: #6366f1;
    --chat-accent-dark: #4f46e5;
    --chat-secondary: #a855f7;
    
    /* Dynamic variables based on site theme */
    --chatbot-bg: var(--bg, #0f172a);
    --chatbot-text: var(--text, #f8fafc);
    --chatbot-muted: var(--muted, #94a3b8);
    --chatbot-card: var(--card, rgba(30, 41, 59, 0.7));
    --chatbot-border: var(--border, rgba(255, 255, 255, 0.1));
    --chatbot-glass: var(--glass, rgba(255, 255, 255, 0.03));
}

/* Light mode adjustments if needed */
.light :root {
    --chatbot-bg: #ffffff;
    --chatbot-text: #1e293b;
    --chatbot-muted: #64748b;
    --chatbot-card: #f8fafc;
    --chatbot-border: rgba(0, 0, 0, 0.08);
}

#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: 50px !important;
    height: 50px !important;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--chat-accent) 0%, var(--chat-secondary) 100%);
    border: none;
    color: white;
    font-size: 20px;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
    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(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    border: 1px solid var(--chatbot-border);
    border-radius: 28px;
    display: flex;
    flex-direction: column;
    z-index: 1000000 !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
    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: 15px 20px;
    background: var(--chatbot-glass);
    border-bottom: 1px solid var(--chatbot-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.bot-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bot-avatar {
    position: relative;
    width: 36px;
    height: 36px;
}

.avatar-inner {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--chat-accent), var(--chat-secondary));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
}

.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-glass);
    border: none;
    color: var(--chatbot-muted);
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--chatbot-text);
}

.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 > .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: linear-gradient(135deg, var(--chat-accent) 0%, var(--chat-secondary) 100%);
    border: none;
    color: white !important;
    padding: 16px;
    border-radius: 16px;
    font-weight: 700;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
    transition: all 0.3s;
}

.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: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    animation: slideUp 0.3s ease forwards;
}

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

.message.bot {
    align-self: flex-start;
    background: var(--chatbot-glass);
    color: var(--chatbot-text);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--chatbot-border);
}

.message.user {
    align-self: flex-end;
    background: var(--chat-accent);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.2);
}

/* 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: 8px 14px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-reply-btn:hover {
    background: var(--chat-accent);
    border-color: var(--chat-accent);
    color: white;
}

/* Footer & Input */
.chatbot-footer {
    padding: 20px 24px;
    background: var(--chatbot-glass);
    border-top: 1px solid var(--chatbot-border);
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--chatbot-glass);
    border: 1px solid var(--chatbot-border);
    border-radius: 18px;
    padding: 8px 16px;
    transition: all 0.3s;
}

.input-wrapper:focus-within {
    border-color: var(--chat-accent);
    background: var(--chatbot-glass);
}

#chat-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--chatbot-text);
    font-size: 14px;
    outline: none;
    resize: none;
    max-height: 100px;
    padding: 4px 0;
}

.send-btn {
    background: var(--chat-accent);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.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: transparent;
    border: 1px solid #10b981;
    color: #10b981;
    padding: 10px;
    border-radius: 14px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-end-chat:hover {
    background: #10b981;
    color: white;
}

.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;
    }
}
