/* ═══════════════════════════════════════════════════════
   Zentix™ Landing Page Chatbot Widget — Premium Dark UI
   Matches chatbot-embed.js aesthetic
   ═══════════════════════════════════════════════════════ */

/* ── Design Tokens ── */
:root {
    --zt-w-primary: #667eea;
    --zt-w-primary-rgb: 102, 126, 234;
    --zt-w-primary-hover: #764ba2;
    --zt-w-bg: #0a0a0f;
    --zt-w-surface: #12121a;
    --zt-w-surface-2: #1a1a26;
    --zt-w-surface-3: #22222f;
    --zt-w-text: #f0f0f5;
    --zt-w-text-secondary: #94a3b8;
    --zt-w-border: #2a2a3a;
    --zt-w-glow: rgba(102, 126, 234, 0.35);
    --zt-w-radius: 20px;
    --zt-w-font: 'Inter', 'Poppins', system-ui, -apple-system, sans-serif;
}

/* ═══════════════════════════════════════════════════════
   Persistent Chatbot Input (Replaces FAB + Container)
   ═══════════════════════════════════════════════════════ */
.chatbot-persistent {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    max-width: 1000px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
}

.chatbot-persistent.scroll-hidden {
    transform: translate(-50%, 150px) scale(0.9) !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ── Minimized State: collapse to just the logo ── */
.chatbot-persistent.chatbot-minimized .chatbot-input-wrapper {
    width: 56px !important;
    height: 56px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(var(--zt-w-primary-rgb), 0.3) !important;
    border-color: rgba(var(--zt-w-primary-rgb), 0.3) !important;
}

.chatbot-persistent.chatbot-minimized .chatbot-text-input,
.chatbot-persistent.chatbot-minimized .chatbot-send-btn {
    display: none !important;
}

.chatbot-persistent.chatbot-minimized .chatbot-logo-animated {
    width: 28px;
    height: 28px;
    cursor: pointer;
}

.chatbot-persistent.chatbot-minimized .chatbot-conversation-starters {
    display: none;
}

/* Subtle pulse on the minimized logo to signal interactivity */
.chatbot-persistent.chatbot-minimized .chatbot-input-wrapper {
    animation: minimized-pulse 2.5s ease-in-out infinite;
}

@keyframes minimized-pulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(var(--zt-w-primary-rgb), 0.25); }
    50% { box-shadow: 0 4px 30px rgba(var(--zt-w-primary-rgb), 0.5); }
}

/* ── Pinned State: override scroll hiding ── */
.chatbot-persistent.chatbot-pinned {
    transform: translate(-50%, 0) scale(1) !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.chatbot-persistent.chatbot-pinned .chatbot-input-wrapper {
    width: 100%;
    height: 60px;
    padding: 8px 8px 8px 16px;
    border-radius: 40px;
    cursor: default;
    animation: none;
}

.chatbot-persistent.chatbot-pinned .chatbot-text-input,
.chatbot-persistent.chatbot-pinned .chatbot-send-btn {
    display: flex;
}




/* ── Conversation Starters ── */
.chatbot-conversation-starters {
    display: flex;
    gap: 10px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--zt-w-surface-2);
    padding: 8px 16px;
    border-radius: 30px;
    border: 1px solid var(--zt-w-border);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* Make it dark in light mode too, or light up? The subagent noted no border */
body.light-mode .chatbot-conversation-starters,
body.light-theme .chatbot-conversation-starters {
    background: #ffffff;
    border-color: #cbd5e1;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.chatbot-persistent:hover .chatbot-conversation-starters,
.chatbot-persistent:focus-within .chatbot-conversation-starters {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.starter-icon:hover {
    transform: scale(1.1);
    background: var(--zt-w-primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(var(--zt-w-primary-rgb), 0.3);
}

/* Specific Brand Colors on Hover */
.starter-icon[title="WhatsApp"]:hover { background: #25D366; box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3); color: #fff; }
.starter-icon[title="Slack"]:hover { background: #E01E5A; box-shadow: 0 4px 12px rgba(224, 30, 90, 0.3); color: #fff; }
.starter-icon[title="Telegram"]:hover { background: #0088cc; box-shadow: 0 4px 12px rgba(0, 136, 204, 0.3); color: #fff; }

/* ── Input Wrapper ── */
.chatbot-input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--crystal-bg) !important;
    backdrop-filter: var(--crystal-blur) !important;
    -webkit-backdrop-filter: var(--crystal-blur) !important;
    border: 1px solid var(--crystal-border) !important;
    border-radius: 40px;
    padding: 8px 8px 8px 16px;
    height: 60px;
    box-shadow: var(--crystal-shadow) !important;
    width: 100%;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1) !important;
    position: relative;
    overflow: hidden;
    margin: 0 auto;
}

.chatbot-persistent:hover .chatbot-input-wrapper,
.chatbot-input-wrapper.glow-active {
    border-color: rgba(255, 255, 255, 0.15) !important;
    box-shadow: 
        0 10px 40px rgba(0, 0, 0, 0.2), 
        0 0 0 1px rgba(255, 255, 255, 0.05) inset, 
        0 0 20px rgba(255, 255, 255, 0.05) !important;
}

.chatbot-text-input:focus {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

/* ── Logo inside Input ── */
.chatbot-persistent-logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: contain;
    z-index: 1;
    flex-shrink: 0;
}

/* Animated logo inside chatbot (reuses header structure) */
.chatbot-logo-animated {
    width: 32px;
    height: 32px;
    position: relative;
    flex-shrink: 0;
    z-index: 1;
}

.chatbot-logo-animated .logo-core {
    width: 14px;
    height: 14px;
}

.chatbot-logo-animated .logo-shard {
    transform: scale(0.7);
}

/* ── Text Input ── */
.chatbot-text-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--zt-w-text);
    font-size: 15px;
    font-family: var(--zt-w-font);
    outline: none;
    z-index: 1;
    padding: 0;
    min-width: 0;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 1;
}

body.light-mode .chatbot-text-input,
body.light-theme .chatbot-text-input {
    color: #0f172a;
}

.chatbot-text-input::placeholder {
    color: #a8b4c4;
}

body.light-mode .chatbot-text-input::placeholder,
body.light-theme .chatbot-text-input::placeholder {
    color: #64748b;
}

/* ── Send Button ── */
.chatbot-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--zt-w-primary) 0%, var(--zt-w-primary-hover) 100%);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
    z-index: 10;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    overflow: hidden;
}

.chatbot-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(var(--zt-w-primary-rgb), 0.6);
}

.chatbot-send-btn:active {
    transform: scale(0.92);
}

/* Base Icon Transition */
.chatbot-send-btn i {
    position: absolute;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Arrow Morphing Physic Launch (Fade out Up) */
.chatbot-send-btn.sending i.fa-arrow-up {
    transform: translateY(-30px) scale(0.6);
    opacity: 0;
}

/* Checkmark Morphing Impact Bounce */
.chatbot-send-btn.sent i.fa-check {
    animation: bounce-check 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes bounce-check {
    0% { transform: scale(0); opacity: 0; }
    70% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* ═══════════════════════════════════════════════════════
   Responsive Fixes for Persistent Input
   ═══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    /* On mobile: start as a floating bubble, not a full-width bar */
    .chatbot-persistent {
        bottom: 20px;
        right: 20px;
        left: auto;
        transform: none;
        width: auto;
    }

    .chatbot-persistent .chatbot-input-wrapper {
        width: 56px !important;
        height: 56px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        justify-content: center;
        cursor: pointer;
        box-shadow: 0 4px 20px rgba(var(--zt-w-primary-rgb), 0.3) !important;
        border-color: rgba(var(--zt-w-primary-rgb), 0.3) !important;
        animation: minimized-pulse 2.5s ease-in-out infinite;
    }

    .chatbot-persistent .chatbot-text-input,
    .chatbot-persistent .chatbot-send-btn {
        display: none !important;
    }

    .chatbot-persistent .chatbot-logo-animated {
        width: 28px;
        height: 28px;
        cursor: pointer;
    }

    .chatbot-persistent .chatbot-conversation-starters {
        display: none;
    }

    /* Expanded state: tapping the bubble opens the full bar */
    .chatbot-persistent.chatbot-mobile-expanded {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: 92%;
    }

    .chatbot-persistent.chatbot-mobile-expanded .chatbot-input-wrapper {
        width: 100% !important;
        height: 52px !important;
        padding: 6px 6px 6px 14px !important;
        border-radius: 40px !important;
        animation: none;
    }

    .chatbot-persistent.chatbot-mobile-expanded .chatbot-text-input,
    .chatbot-persistent.chatbot-mobile-expanded .chatbot-send-btn {
        display: flex !important;
    }

    .chatbot-persistent.chatbot-mobile-expanded .chatbot-send-btn {
        width: 40px;
        height: 40px;
    }

    .chatbot-persistent.chatbot-mobile-expanded .chatbot-text-input {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .chatbot-persistent {
        bottom: 15px;
        right: 16px;
    }

    .chatbot-persistent.chatbot-mobile-expanded {
        width: 95%;
    }
}

/* ═══════════════════════════════════════════════════════
   Chat Conversation Panel (slides up from persistent bar)
   ═══════════════════════════════════════════════════════ */

.chatbot-messages-panel {
    width: 100%;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    border-radius: 40px 40px 0 0 !important;
    background: var(--crystal-bg) !important;
    backdrop-filter: var(--crystal-blur) !important;
    -webkit-backdrop-filter: var(--crystal-blur) !important;
    border: 1px solid var(--crystal-border) !important;
    border-bottom: none !important;
    display: flex;
    flex-direction: column;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s ease;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.3);
}

.chatbot-messages-panel.open {
    max-height: 450px;
    opacity: 1;
}

.chatbot-messages-panel.open.enlarged {
    max-height: 80vh;
}

/* When panel is active, round the input wrapper top corners  */
.chatbot-persistent.chatbot-panel-active .chatbot-input-wrapper {
    border-radius: 0 0 40px 40px !important;
    border-top-color: transparent !important;
}

/* ── Panel Header ── */
.chatbot-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--zt-w-border, #2a2a3a);
    flex-shrink: 0;
}

.chatbot-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--zt-w-text, #f0f0f5);
    font-family: var(--zt-w-font, 'Inter', system-ui, sans-serif);
}

.chatbot-panel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
    animation: chatbot-blink 2s infinite;
}

@keyframes chatbot-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ── Header Controls (Pin/Expand) ── */
.chatbot-panel-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}
.chatbot-control-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--crystal-border);
    background: transparent;
    color: var(--zt-w-text-secondary, #94a3b8);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
    z-index: 10;
}

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

.chatbot-control-btn.active-pinned {
    background: var(--zt-w-primary);
    color: #fff;
    border-color: var(--zt-w-primary);
    box-shadow: 0 0 10px rgba(var(--zt-w-primary-rgb), 0.5);
}

.chatbot-persistent.chatbot-minimized .chatbot-control-btn {
    display: none !important;
}

/* ── Messages Area ── */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    max-height: 320px;
}

.chatbot-messages::-webkit-scrollbar { width: 4px; }
.chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--zt-w-border, #2a2a3a);
    border-radius: 10px;
}

/* ── Message Bubbles ── */
.chatbot-msg {
    display: flex;
    max-width: 82%;
    animation: chatbot-msgIn 0.3s ease;
}

.chatbot-msg.bot { align-self: flex-start; }
.chatbot-msg.user { align-self: flex-end; }

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

.chatbot-bubble {
    padding: 10px 16px;
    border-radius: 18px;
    font-size: 13.5px;
    line-height: 1.55;
    font-family: var(--zt-w-font, 'Inter', system-ui, sans-serif);
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.chatbot-msg.bot .chatbot-bubble {
    background: var(--zt-w-surface-2, #1a1a26);
    color: var(--zt-w-text, #f0f0f5);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--zt-w-border, #2a2a3a);
}

.chatbot-msg.user .chatbot-bubble {
    background: linear-gradient(135deg, var(--zt-w-primary, #667eea), var(--zt-w-primary-hover, #764ba2));
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* ── Typing Indicator ── */
.chatbot-typing {
    display: flex;
    gap: 5px;
    padding: 10px 16px;
    background: var(--zt-w-surface-2, #1a1a26);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    border: 1px solid var(--zt-w-border, #2a2a3a);
}

.chatbot-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--zt-w-text-secondary, #94a3b8);
    animation: chatbot-bounce 0.6s infinite alternate;
}

.chatbot-dot:nth-child(2) { animation-delay: 0.15s; }
.chatbot-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes chatbot-bounce {
    to { transform: translateY(-5px); }
}

/* ── Suggestion Chips ── */
.chatbot-suggestions {
    display: flex;
    gap: 8px;
    padding: 0 16px 12px;
    overflow-x: auto;
    flex-shrink: 0;
    scrollbar-width: none;
}

.chatbot-suggestions::-webkit-scrollbar { display: none; }

.chatbot-suggestions:empty { display: none; }

.chatbot-suggestion-chip {
    padding: 6px 14px;
    border-radius: 18px;
    border: 1px solid var(--zt-w-border, #2a2a3a);
    background: var(--zt-w-surface-2, #1a1a26);
    color: var(--zt-w-text-secondary, #94a3b8);
    font-size: 12px;
    font-weight: 500;
    font-family: var(--zt-w-font, 'Inter', system-ui, sans-serif);
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.chatbot-suggestion-chip:hover {
    border-color: var(--zt-w-primary, #667eea);
    color: var(--zt-w-primary, #667eea);
    background: rgba(var(--zt-w-primary-rgb, 102, 126, 234), 0.1);
    transform: translateY(-1px);
}

.chatbot-suggestion-chip:active {
    transform: scale(0.95);
}

/* ── Light mode overrides ── */
body.light-mode .chatbot-messages-panel,
body.light-theme .chatbot-messages-panel {
    background: #ffffff;
    border-color: #e2e8f0;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.08);
}

body.light-mode .chatbot-panel-header,
body.light-theme .chatbot-panel-header {
    border-bottom-color: #e2e8f0;
}

body.light-mode .chatbot-panel-title,
body.light-theme .chatbot-panel-title {
    color: #0f172a;
}

body.light-mode .chatbot-close-btn,
body.light-theme .chatbot-close-btn {
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: #64748b;
}

body.light-mode .chatbot-msg.bot .chatbot-bubble,
body.light-theme .chatbot-msg.bot .chatbot-bubble {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #e2e8f0;
}

body.light-mode .chatbot-typing,
body.light-theme .chatbot-typing {
    background: #f1f5f9;
    border-color: #e2e8f0;
}

body.light-mode .chatbot-suggestion-chip,
body.light-theme .chatbot-suggestion-chip {
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: #475569;
}

/* ── Responsive — Chat Panel ── */
@media (max-width: 768px) {
    .chatbot-messages-panel.open {
        max-height: 380px;
    }

    .chatbot-messages {
        max-height: 260px;
        padding: 12px;
    }

    .chatbot-bubble {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .chatbot-messages-panel {
        border-radius: 20px 20px 0 0;
    }

    .chatbot-messages-panel.open {
        max-height: 55vh;
    }

    .chatbot-messages {
        max-height: 45vh;
    }

    .chatbot-msg {
        max-width: 90%;
    }

    .chatbot-panel-header {
        padding: 10px 14px;
    }
}
