/**
 * Gemini Chatbot Custom Styles
 * Theme matching TravelSpotsDaily (Violet/Muted Slate theme)
 */

:root {
    --gemini-primary: #584a5e;
    --gemini-primary-light: #7c6a83;
    --gemini-gradient: linear-gradient(135deg, #7c6a83 0%, #584a5e 100%);
    --gemini-bubble-user: linear-gradient(135deg, #8a7693 0%, #584a5e 100%);
    --gemini-bubble-bot: #f3eff5;
    --gemini-bg-window: #ffffff;
    --gemini-shadow: 0 16px 48px rgba(88, 74, 94, 0.16);
    --gemini-shadow-launcher: 0 8px 32px rgba(88, 74, 94, 0.32);
    --gemini-border-radius-lg: 20px;
    --gemini-border-radius-md: 14px;
    --gemini-transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    --gemini-font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Container */
#gemini-chatbot-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 99999;
    font-family: var(--gemini-font-family);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* Floating Launcher */
.gemini-chat-launcher {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--gemini-gradient);
    border: none;
    cursor: grab;
    box-shadow: var(--gemini-shadow-launcher);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    transition: var(--gemini-transition);
    outline: none;
    z-index: 10;
}

.gemini-chat-launcher:hover {
    transform: scale(1.08) rotate(5deg);
    box-shadow: 0 12px 36px rgba(88, 74, 94, 0.45);
}

.gemini-chat-launcher:active {
    transform: scale(0.95);
}

.gemini-chat-launcher svg {
    width: 28px;
    height: 28px;
    transition: var(--gemini-transition);
}

/* Glow Effect */
.launcher-glow {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--gemini-gradient);
    opacity: 0.4;
    z-index: -1;
    animation: launcher-pulse 2s infinite;
}

@keyframes launcher-pulse {
    0% {
        transform: scale(1);
        opacity: 0.4;
    }
    50% {
        transform: scale(1.3);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}

/* Chat Window */
.gemini-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 580px;
    background: var(--gemini-bg-window);
    border-radius: var(--gemini-border-radius-lg);
    box-shadow: var(--gemini-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    pointer-events: none;
    transition: var(--gemini-transition);
    border: 1px solid rgba(88, 74, 94, 0.1);
}

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

/* Header styling */
.chat-header {
    background: var(--gemini-gradient);
    padding: 16px 20px;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.15) 0%, transparent 60%);
    pointer-events: none;
}

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

.avatar-container {
    position: relative;
}

.avatar-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--gemini-primary);
}

.status-dot.online {
    background-color: #22c55e;
    animation: status-blink 1.5s infinite;
}

@keyframes status-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chatbot-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.3px;
    line-height: 1.2;
}

.chatbot-subtitle {
    margin: 2px 0 0;
    font-size: 11px;
    opacity: 0.85;
    line-height: 1.2;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.header-actions button {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 16px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--gemini-transition);
    opacity: 0.8;
}

.header-actions button:hover {
    background: rgba(255, 255, 255, 0.15);
    opacity: 1;
}

/* Chat Body styling */
.chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fdfcff;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar {
    width: 5px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(88, 74, 94, 0.15);
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(88, 74, 94, 0.3);
}

/* Chat Message Styling */
.chat-message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: message-slide-in 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
    opacity: 0;
    transform: translateY(10px);
}

@keyframes message-slide-in {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.bot {
    align-self: flex-start;
}

.chat-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
    max-width: 80%;
}

.message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--gemini-bubble-bot);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gemini-primary);
    font-size: 13px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(88, 74, 94, 0.08);
}

.message-content {
    padding: 12px 16px;
    border-radius: var(--gemini-border-radius-md);
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    box-shadow: 0 2px 12px rgba(88, 74, 94, 0.04);
}

.chat-message.bot .message-content {
    background: var(--gemini-bubble-bot);
    color: #2d3748;
    border-top-left-radius: 4px;
}

.chat-message.user .message-content {
    background: var(--gemini-bubble-user);
    color: #ffffff;
    border-top-right-radius: 4px;
    box-shadow: 0 4px 14px rgba(88, 74, 94, 0.15);
}

/* Markdown formats inside message content */
.message-content p {
    margin: 0 0 8px 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul, .message-content ol {
    margin: 4px 0 8px 0;
    padding-left: 20px;
}

.message-content li {
    margin-bottom: 4px;
}

.message-content strong {
    font-weight: 600;
}

/* Suggestion Pills styling */
.chat-suggestions {
    padding: 12px 20px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    flex-wrap: nowrap;
    border-top: 1px solid rgba(88, 74, 94, 0.06);
    background: #ffffff;
    scrollbar-width: none; /* Firefox */
}

.chat-suggestions::-webkit-scrollbar {
    display: none; /* Safari and Chrome */
}

.suggest-pill {
    white-space: nowrap;
    background: #ffffff;
    border: 1px solid rgba(88, 74, 94, 0.18);
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 12px;
    color: #4a5568;
    cursor: pointer;
    font-family: var(--gemini-font-family);
    transition: var(--gemini-transition);
    font-weight: 500;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
}

.suggest-pill:hover {
    border-color: var(--gemini-primary);
    color: var(--gemini-primary);
    background: rgba(88, 74, 94, 0.04);
    transform: translateY(-1px);
}

/* Chat Input Footer styling */
.chat-footer {
    padding: 15px 20px;
    background: #ffffff;
    border-top: 1px solid rgba(88, 74, 94, 0.08);
}

.input-container {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f7f6f8;
    border: 1px solid rgba(88, 74, 94, 0.1);
    border-radius: 24px;
    padding: 6px 14px;
    transition: var(--gemini-transition);
}

.input-container:focus-within {
    border-color: var(--gemini-primary);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(88, 74, 94, 0.12);
}

#gemini-chat-input {
    flex: 1 !important;
    border: none !important;
    background: transparent !important;
    padding: 6px 0 !important;
    font-size: 14px !important;
    resize: none !important;
    max-height: 80px !important;
    color: #2d3748 !important;
    font-family: var(--gemini-font-family) !important;
    outline: none !important;
    line-height: 1.4 !important;
    box-shadow: none !important;
    margin: 0 !important;
    scrollbar-width: none !important; /* Firefox */
}

#gemini-chat-input::-webkit-scrollbar {
    display: none !important; /* Safari and Chrome */
}

#gemini-chat-input::placeholder {
    color: #a0aec0 !important;
}

#gemini-chat-send {
    border: none;
    background: var(--gemini-gradient);
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--gemini-transition);
    opacity: 0.9;
    flex-shrink: 0;
}

#gemini-chat-send:hover:not(:disabled) {
    transform: scale(1.08);
    opacity: 1;
}

#gemini-chat-send:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
    transform: none;
    opacity: 0.6;
}

#gemini-chat-send i {
    font-size: 13px;
    margin-left: -1px; /* Align icon better */
}

/* Voice Input Microphone Button */
#gemini-chat-voice {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    color: #a0aec0 !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: var(--gemini-transition) !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

#gemini-chat-voice:hover {
    color: var(--gemini-primary) !important;
    background: rgba(88, 74, 94, 0.08) !important;
}

#gemini-chat-voice.listening {
    color: #ffffff !important;
    background: #ef4444 !important;
    animation: voice-pulse 1.5s infinite !important;
}

@keyframes voice-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4) !important;
    }
    70% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0) !important;
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0) !important;
    }
}

/* Message TTS styling */
.message-actions {
    display: flex !important;
    justify-content: flex-end !important;
    margin-top: 6px !important;
    padding-top: 4px !important;
    border-top: 1px solid rgba(88, 74, 94, 0.05) !important;
}

.message-tts-btn {
    background: rgba(88, 74, 94, 0.04) !important;
    border: 1px solid rgba(88, 74, 94, 0.1) !important;
    box-shadow: none !important;
    color: #8a7693 !important;
    cursor: pointer !important;
    font-size: 11px !important;
    width: 24px !important;
    height: 24px !important;
    border-radius: 50% !important;
    transition: var(--gemini-transition) !important;
    outline: none !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    margin: 0 !important;
}

.message-tts-btn:hover {
    color: #ffffff !important;
    background: var(--gemini-primary) !important;
    border-color: var(--gemini-primary) !important;
}

.message-tts-btn.speaking {
    color: #ffffff !important;
    background: #22c55e !important;
    border-color: #22c55e !important;
    animation: speak-blink 1s infinite alternate !important;
}

@keyframes speak-blink {
    from { opacity: 0.6 !important; }
    to { opacity: 1 !important; }
}

/* Typing Indicator Animation */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--gemini-primary);
    border-radius: 50%;
    opacity: 0.4;
    animation: typing-bounce 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-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

/* API Warning UI */
.api-key-warning {
    background: #fffaf0;
    border: 1px dashed #dd6b20;
    padding: 10px 14px;
    border-radius: var(--gemini-border-radius-md);
    font-size: 12px;
    color: #dd6b20;
    display: flex;
    gap: 8px;
    align-items: flex-start;
    line-height: 1.4;
}

.api-key-warning i {
    margin-top: 2px;
    font-size: 14px;
}

.api-key-warning code {
    background: rgba(221, 107, 32, 0.08);
    padding: 2px 4px;
    border-radius: 4px;
    font-weight: 600;
}

/* Language Alert Banner styling */
.gemini-lang-banner {
    background: #fffbeb !important;
    border-bottom: 1px solid #fef3c7 !important;
    padding: 10px 16px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 10px !important;
    animation: banner-slide-down 0.3s ease-out forwards !important;
    z-index: 50 !important;
    position: relative !important;
}

@keyframes banner-slide-down {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.gemini-lang-banner .banner-text {
    font-size: 12px !important;
    color: #b45309 !important;
    font-weight: 500 !important;
    line-height: 1.35 !important;
}

.gemini-lang-banner .banner-btn {
    background: #d97706 !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 12px !important;
    padding: 4px 10px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: var(--gemini-transition) !important;
    white-space: nowrap !important;
    box-shadow: none !important;
}

.gemini-lang-banner .banner-btn:hover {
    background: #b45309 !important;
}

.gemini-lang-banner .banner-close {
    background: transparent !important;
    border: none !important;
    color: #d97706 !important;
    font-size: 18px !important;
    cursor: pointer !important;
    padding: 0 4px !important;
    line-height: 1 !important;
    box-shadow: none !important;
}

.gemini-lang-banner .banner-close:hover {
    color: #b45309 !important;
}

/* Utility Helpers */
.d-none {
    display: none !important;
}

/* RESPONSIVE DESIGN */
@media (max-width: 576px) {
    #gemini-chatbot-container {
        bottom: 20px;
        right: 25px; /* aligned to 25px like TOC */
    }
    
    .gemini-chat-launcher {
        width: 50px;
        height: 50px;
    }
    
    .gemini-chat-launcher svg {
        width: 24px;
        height: 24px;
    }
    
    .gemini-chat-window {
        bottom: 70px;
        right: 0;
        width: calc(100vw - 40px);
        height: calc(100vh - 120px); /* Fallback */
        height: calc(100svh - 120px);
        max-height: 520px;
    }
}
