/* Chatbot Core Styles - Premium Glassmorphism */

:root {
    --chat-bg: rgba(15, 17, 21, 0.85);
    --chat-border: rgba(255, 215, 0, 0.12);
    --chat-accent: #FFD700;
    --chat-text: #FFFFFF;
    --chat-user-msg: rgba(255, 215, 0, 0.08);
    --chat-bot-msg: rgba(255, 255, 255, 0.04);
    --chat-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --chat-font-heading: 'Outfit', 'Inter', sans-serif;
}

.chatbot-container {
    position: fixed;
    bottom: 24px;
    right: 2rem;
    width: 500px;
    max-width: calc(100vw - 3rem);
    height: 850px;
    max-height: calc(100vh - 120px);
    background: var(--chat-bg);
    border: 1px solid var(--chat-border);
    border-radius: 24px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    display: flex;
    flex-direction: column;
    z-index: 10001;
    overflow: hidden;
    transform-origin: bottom right;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: var(--chat-font);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.chatbot-container.closed {
    opacity: 0;
    transform: scale(0.8) translateY(20px);
    pointer-events: none;
}

/* Header */
.chatbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: rgba(0, 0, 0, 0.35);
    border-bottom: 1px solid var(--chat-border);
}

.chatbot-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--chat-accent), #c2a000);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #111;
    font-weight: bold;
    font-size: 1.2rem;
    box-shadow: 0 4px 10px rgba(255, 215, 0, 0.2);
}

.chatbot-title h4 {
    margin: 0;
    font-family: var(--chat-font-heading);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--chat-text);
    letter-spacing: 0.01em;
}

.chatbot-status {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    gap: 4px;
}

.chatbot-status::before {
    content: '';
    display: block;
    width: 6px;
    height: 6px;
    background: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.8);
}

.chatbot-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    padding: 4px;
}

.chatbot-btn:hover {
    color: var(--chat-accent);
}

/* Body */
.chatbot-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    /* Scrollbar Styling */
}

.chatbot-body::-webkit-scrollbar {
    width: 4px;
}

.chatbot-body::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.chatbot-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Responsiveness alignment with WA float */
@media (max-width: 768px) {
    .chatbot-toggle-btn {
        bottom: 88px;
        right: 1.5rem;
    }

    .chatbot-container {
        bottom: 160px;
        right: 1.5rem;
        max-width: calc(100vw - 3rem);
    }
}

.chat-message {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.55;
    letter-spacing: 0.005em;
    max-width: 92%;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease-out;
    font-family: var(--chat-font);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

.bot-message {
    background: var(--chat-bot-msg);
    color: rgba(255, 255, 255, 0.88);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    width: 92%;
}

.bot-message strong {
    color: var(--chat-accent);
}

.bot-message a {
    color: var(--chat-accent);
    text-decoration: underline;
    font-weight: 500;
    transition: all 0.2s ease;
}

.bot-message a:hover {
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
}

.user-message {
    background: var(--chat-user-msg);
    color: var(--chat-text);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    border: 1px solid rgba(255, 215, 0, 0.15);
}

.error-message {
    background: rgba(255, 0, 0, 0.1);
    color: #ffb3b3;
    border: 1px solid rgba(255, 0, 0, 0.2);
}

/* Loading Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    align-self: flex-start;
    background: var(--chat-bot-msg);
    border-radius: 12px;
    border-bottom-left-radius: 2px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

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

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

@keyframes typing {

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

    40% {
        transform: scale(1);
    }
}

/* Footer / Input */
.chatbot-footer {
    padding: 14px 20px;
    background: rgba(0, 0, 0, 0.4);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    gap: 10px;
    align-items: center;
}

#chatbot-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #fff;
    padding: 11px 16px;
    border-radius: 24px;
    font-size: 0.88rem;
    font-family: var(--chat-font);
    letter-spacing: 0.005em;
    transition: border-color 0.2s, background 0.2s;
    outline: none;
}

#chatbot-input:focus {
    border-color: var(--chat-accent);
    background: rgba(255, 255, 255, 0.08);
}

#chatbot-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.chatbot-send-btn {
    background: var(--chat-accent);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #111;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.chatbot-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chatbot-send-btn:not(:disabled):hover {
    transform: scale(1.05);
}

/* Suggestion Chips */
.suggestion-chips {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    /* Align chips to the right, similar to user messages, or stretch them */
    gap: 8px;
    padding: 10px 16px 20px 16px;
    margin-top: -6px;
    animation: fadeIn 0.4s ease-out;
}

.suggestion-chip {
    width: auto;
    max-width: 90%;
    background: rgba(255, 215, 0, 0.08);
    border: 1px solid rgba(255, 215, 0, 0.25);
    color: var(--chat-accent);
    padding: 8px 14px;
    border-radius: 16px;
    font-size: 0.82rem;
    font-family: var(--chat-font);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: normal;
    text-align: left;
    line-height: 1.3;
}

.suggestion-chip:hover {
    background: rgba(255, 215, 0, 0.15);
    border-color: rgba(255, 215, 0, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.1);
}

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

/* Floating Toggle Button — Premium Glowing Gold Pill */
.chatbot-toggle-btn {
    position: fixed !important;
    /* Force floating */
    bottom: 2rem !important;
    right: 2rem !important;
    height: 52px;
    padding: 0 20px 0 16px;
    border-radius: 26px;

    /* Shifting Gold Gradient Background */
    background: linear-gradient(110deg, #d4af37, #ffdf00, #d4af37, #ffd700);
    background-size: 300% 300%;
    animation: goldShimmer 4s ease infinite;

    color: #111;
    border: 1px solid rgba(255, 255, 255, 0.4);

    /* Constant glow instead of just pulse */
    box-shadow: 0 10px 25px rgba(212, 175, 55, 0.4),
        0 0 15px rgba(255, 215, 0, 0.3),
        inset 0 2px 4px rgba(255, 255, 255, 0.6);
    cursor: pointer;
    z-index: 2147483647 !important;
    /* Absolute maximum z-index */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.3s;
}

@keyframes goldShimmer {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.chatbot-toggle-btn::after {
    /* Glass reflection effect */
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    width: 80%;
    height: 30%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0));
    border-radius: 20px 20px 0 0;
    pointer-events: none;
}

.chatbot-toggle-btn svg {
    flex-shrink: 0;
}

.toggle-label {
    font-family: var(--font-heading, "Outfit", sans-serif);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.chatbot-toggle-btn:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 12px 30px rgba(212, 175, 55, 0.6),
        0 0 20px rgba(255, 215, 0, 0.5),
        inset 0 2px 4px rgba(255, 255, 255, 0.8);
}

.chatbot-toggle-btn.active {
    transform: scale(0.9);
}

@keyframes togglePulse {

    0%,
    100% {
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 215, 0, 0.5);
    }

    50% {
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 0 4px rgba(255, 215, 0, 0.3), 0 0 20px rgba(255, 215, 0, 0.15);
    }
}

/* Welcome Bubble */
.chatbot-welcome-bubble {
    position: fixed;
    bottom: 76px;
    right: 2rem;
    max-width: 260px;
    padding: 14px 36px 14px 16px;
    background: rgba(15, 17, 21, 0.92);
    border: 1px solid var(--chat-border);
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.88rem;
    line-height: 1.45;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px);
    z-index: 10000;
    animation: bubbleIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.chatbot-welcome-bubble::after {
    content: '';
    position: absolute;
    bottom: -7px;
    right: 28px;
    width: 14px;
    height: 14px;
    background: rgba(15, 17, 21, 0.92);
    border-right: 1px solid var(--chat-border);
    border-bottom: 1px solid var(--chat-border);
    transform: rotate(45deg);
}

.welcome-close {
    position: absolute;
    top: 8px;
    right: 10px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.4);
    font-size: 1.1rem;
    line-height: 1;
    transition: color 0.2s;
}

.welcome-close:hover {
    color: var(--chat-accent);
}

@keyframes bubbleIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }

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

/* Responsive: Tablet */
@media (max-width: 768px) {
    .chatbot-toggle-btn {
        bottom: 1.5rem;
        right: 1.5rem;
    }

    .chatbot-welcome-bubble {
        bottom: 80px;
        right: 1.5rem;
        max-width: 220px;
    }

    .chatbot-container {
        bottom: 80px;
        right: 1.5rem;
    }
}

/* Mobile: Full Screen Chat */
@media (max-width: 480px) {
    .chatbot-container {
        width: 100vw;
        max-width: 100vw;
        top: 70px;
        /* Force it below the 70px nav bar */
        bottom: 0;
        right: 0;
        left: 0;
        height: auto;
        max-height: none;
        border-radius: 0;
        border: none;
        border-top: 1px solid var(--chat-border);
    }

    .chatbot-toggle-btn {
        bottom: 20px;
        right: 20px;
        padding: 0 16px;
        height: 48px;
    }

    .chatbot-welcome-bubble {
        bottom: 76px;
        right: 16px;
        max-width: calc(100vw - 40px);
    }

    .toggle-label {
        /* Content visibility maintained on mobile */
    }
}



/* ============================
   STREAMING CURSOR
   ============================ */
.bot-message.streaming::after {
    content: '▊';
    color: var(--chat-accent);
    animation: blink 0.8s infinite;
    margin-left: 2px;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* ============================
   EXPORT BUTTON
   ============================ */
.chatbot-export-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    transition: color 0.2s;
}

.chatbot-export-btn:hover {
    color: var(--chat-accent);
}