/* 
    Apple Intelligence 2025 - Ultra Premium Chatbot
   Design System: Glassmorphism 2.0, Vivid Gradients, SF Pro
*/

:root {
    /* 2025 Apple Palette */
    --ai-bg-light: rgb(255 255 255 / 65%);
    --ai-bg-dark: rgb(20 20 25 / 65%);
    --ai-blur: blur(40px) saturate(180%);
    --ai-border-light: rgb(255 255 255 / 40%);
    --ai-border-dark: rgb(255 255 255 / 10%);
    --ai-shadow: 0 25px 50px -12px rgb(0 0 0 / 25%);

    /* Apple Intelligence Gradient */
    --ai-gradient: linear-gradient(135deg, #30CFD0 0%, #330867 100%);
    --ai-glow: conic-gradient(from 180deg at 50% 50%, #2E88F9 0deg, #F93B30 72deg, #F9D030 144deg, #30D158 216deg, #2E88F9 360deg);
    --ai-font: -apple-system, blinkmacsystemfont, "SF Pro Display", "SF Pro Text", sans-serif;
    --ai-primary: #007aff;
    --ai-text-light: #1d1d1f;
    --ai-text-dark: #f5f5f7;
}

/* ═══════════════════════════════════════════════════════════
   WIDGET CONTAINER - COMPACT & POSITIONED ABOVE TOGGLE
   ═══════════════════════════════════════════════════════════ */
#chatbot-widget {
    position: fixed;
    bottom: 168px;
    /* Positioned above the toggle button (96px + 56px + 16px spacing) */
    right: 24px;
    width: 400px;
    /* Optimal width for conversations */
    height: 600px;
    /* Taller window for better chat experience */
    max-height: calc(100vh - 240px);
    /* Leaves space for navbar (56px) + toggle area (168px) + small margin */

    /* Glassmorphism 2.0 */
    background: var(--ai-bg-light);
    backdrop-filter: var(--ai-blur);
    backdrop-filter: var(--ai-blur);
    border: 1px solid var(--ai-border-light);
    box-shadow: var(--ai-shadow), 0 0 0 1px rgb(255 255 255 / 20%) inset;
    border-radius: 24px;

    /* Slightly smaller radius for compact look */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;

    /* Below mobile menu (10000+) */
    font-family: var(--ai-font);

    /* Animation: Spring Pop from bottom-right */
    transform-origin: bottom right;
    transition: all 0.5s cubic-bezier(0.32, 0.72, 0, 1);
    opacity: 0;
    transform: scale(0.9) translateY(20px) rotate(-2deg);
    pointer-events: none;
}

html.dark #chatbot-widget {
    background: var(--ai-bg-dark);
    border-color: var(--ai-border-dark);
    box-shadow: 0 30px 60px rgb(0 0 0 / 60%), 0 0 0 1px rgb(255 255 255 / 5%) inset;
}

#chatbot-widget.visible {
    opacity: 1;
    transform: scale(1) translateY(0) rotate(0);
    pointer-events: auto;
}

/* ═══════════════════════════════════════════════════════════
   HEADER - APPLE INTELLIGENCE GLOW (COMPACT)
   ═══════════════════════════════════════════════════════════ */
.chatbot-header {
    padding: 18px 20px;

    /* More compact padding */
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgb(0 0 0 / 5%);
    background: linear-gradient(to bottom, rgb(255 255 255 / 50%), transparent);
}

html.dark .chatbot-header {
    border-bottom: 1px solid rgb(255 255 255 / 5%);
    background: linear-gradient(to bottom, rgb(0 0 0 / 20%), transparent);
}

.chatbot-title {
    font-size: 22px;
    font-weight: 700;
    background: var(--ai-glow);
    background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
    filter: drop-shadow(0 0 10px rgb(46 136 249 / 30%));
}

.chatbot-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgb(0 0 0 / 5%);
    border: none;
    color: var(--ai-text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

html.dark .chatbot-close-btn {
    background: rgb(255 255 255 / 10%);
    color: #fff;
}

.chatbot-close-btn:hover {
    background: rgb(0 0 0 / 10%);
    transform: rotate(90deg);
}

html.dark .chatbot-close-btn:hover {
    background: rgb(255 255 255 / 20%);
}

/* ═══════════════════════════════════════════════════════════
   TYPING INDICATOR
   ═══════════════════════════════════════════════════════════ */
.typing-indicator {
    padding: 16px 20px;
    background: rgb(255 255 255 / 70%);
    border-radius: 22px;
    display: inline-flex;
    gap: 6px;
    align-self: flex-start;
    border: 1px solid rgb(255 255 255 / 50%);
    margin-bottom: 8px;
    box-shadow: 0 2px 10px rgb(0 0 0 / 3%);
    backdrop-filter: blur(10px);
}

html.dark .typing-indicator {
    background: rgb(40 40 45 / 70%);
    border: 1px solid rgb(255 255 255 / 10%);
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: rgb(0 0 0 / 40%);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

html.dark .typing-dot {
    background: rgb(255 255 255 / 40%);
}

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

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

@keyframes typingBounce {

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

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

/* ═══════════════════════════════════════════════════════════
   SUGGESTION CHIPS - PREMIUM
   ═══════════════════════════════════════════════════════════ */
.suggested-prompts-container {
    padding: 0 24px 16px;
    animation: fadeIn 0.5s ease-out;
}

.suggested-prompts-label {
    font-size: 13px;
    color: rgb(0 0 0 / 50%);
    margin-bottom: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

html.dark .suggested-prompts-label {
    color: rgb(255 255 255 / 50%);
}

.suggested-prompts-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.suggested-prompt-btn {
    background: rgb(255 255 255 / 70%);
    border: 1px solid rgb(0 0 0 / 5%);
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 14px;
    color: var(--ai-text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    backdrop-filter: blur(5px);
    font-family: var(--ai-font);
}

html.dark .suggested-prompt-btn {
    background: rgb(40 40 45 / 60%);
    border: 1px solid rgb(255 255 255 / 10%);
    color: var(--ai-text-dark);
}

.suggested-prompt-btn:hover {
    background: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgb(0 0 0 / 10%);
}

html.dark .suggested-prompt-btn:hover {
    background: rgb(60 60 65 / 80%);
    box-shadow: 0 4px 12px rgb(0 0 0 / 40%);
}

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

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

/* ═══════════════════════════════════════════════════════════
   MESSAGES AREA - CLEAN & FLUID
   ═══════════════════════════════════════════════════════════ */
#chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scrollbar-width: none;

    /* Hide scrollbar */
    -ms-overflow-style: none;
}

#chatbot-messages::-webkit-scrollbar {
    display: none;
}

/* ═══════════════════════════════════════════════════════════
   BUBBLES - iMESSAGE STYLE
   ═══════════════════════════════════════════════════════════ */
.message {
    max-width: 85%;
    display: flex;
    flex-direction: column;
    gap: 4px;
    animation: msgPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

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

/* Assistant */
.assistant-message {
    align-self: flex-start;
}

.assistant-message .message-content {
    background: rgb(255 255 255 / 70%);
    color: #000;
    padding: 16px 20px;
    border-radius: 22px 22px 22px 4px;
    font-size: 16px;
    line-height: 1.5;
    box-shadow: 0 2px 10px rgb(0 0 0 / 3%);
    backdrop-filter: blur(10px);
    border: 1px solid rgb(255 255 255 / 50%);
}

html.dark .assistant-message .message-content {
    background: rgb(40 40 45 / 70%);
    color: #fff;
    border: 1px solid rgb(255 255 255 / 10%);
}

/* User */
.user-message {
    align-self: flex-end;
}

.user-message .message-content {
    background: #007aff;
    color: white;
    padding: 14px 20px;
    border-radius: 22px 22px 4px;
    font-size: 16px;
    line-height: 1.5;
    box-shadow: 0 4px 15px rgb(0 122 255 / 30%);
}

html.dark .user-message .message-content {
    background: linear-gradient(135deg, #0a84ff 0%, #06c 100%);
    box-shadow: 0 4px 16px rgb(10 132 255 / 30%);
}

/* ═══════════════════════════════════════════════════════════
   METADATA CHIPS - THEME AWARE
   ═══════════════════════════════════════════════════════════ */
.message-metadata {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    align-items: center;
}

.meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    background: rgb(0 0 0 / 5%);
    color: #3c3c43;
    border: 1px solid rgb(0 0 0 / 8%);
    transition: all 0.2s;
}

html.dark .meta-chip {
    background: rgb(255 255 255 / 8%);
    color: #ebebf5;
    border: 1px solid rgb(255 255 255 / 12%);
}

.meta-chip-model {
    background: rgb(0 122 255 / 10%);
    color: #007aff;
    border-color: rgb(0 122 255 / 20%);
}

html.dark .meta-chip-model {
    background: rgb(10 132 255 / 15%);
    color: #0a84ff;
    border-color: rgb(10 132 255 / 25%);
}

.meta-chip-source {
    background: rgb(52 199 89 / 10%);
    color: #34c759;
    border-color: rgb(52 199 89 / 20%);
}

html.dark .meta-chip-source {
    background: rgb(48 209 88 / 15%);
    color: #30d158;
    border-color: rgb(48 209 88 / 25%);
}

.meta-chip-runtime,
.meta-chip-speed {
    background: rgb(255 149 0 / 10%);
    color: #ff9500;
    border-color: rgb(255 149 0 / 20%);
}

html.dark .meta-chip-runtime,
html.dark .meta-chip-speed {
    background: rgb(255 159 10 / 15%);
    color: #ff9f0a;
    border-color: rgb(255 159 10 / 25%);
}

.meta-chip-cost {
    background: rgb(255 45 85 / 10%);
    color: #ff2d55;
    border-color: rgb(255 45 85 / 20%);
}

html.dark .meta-chip-cost {
    background: rgb(255 55 95 / 15%);
    color: #ff375f;
    border-color: rgb(255 55 95 / 25%);
}

.meta-chip-confidence {
    background: rgb(90 200 250 / 10%);
    color: #5ac8fa;
    border-color: rgb(90 200 250 / 20%);
}

html.dark .meta-chip-confidence {
    background: rgb(100 210 255 / 15%);
    color: #64d2ff;
    border-color: rgb(100 210 255 / 25%);
}

/* ═══════════════════════════════════════════════════════════
   ACTION BUTTONS - THEME AWARE
   ═══════════════════════════════════════════════════════════ */
.message-actions {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.msg-action-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgb(0 0 0 / 5%);
    color: #3c3c43;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

html.dark .msg-action-btn {
    background: rgb(255 255 255 / 8%);
    color: #ebebf5;
}

.msg-action-btn:hover {
    background: rgb(0 122 255 / 15%);
    color: #007aff;
    transform: scale(1.1);
}

html.dark .msg-action-btn:hover {
    background: rgb(10 132 255 / 20%);
    color: #0a84ff;
}

.msg-action-btn.success {
    background: rgb(52 199 89 / 15%);
    color: #34c759;
}

html.dark .msg-action-btn.success {
    background: rgb(48 209 88 / 20%);
    color: #30d158;
}

.msg-action-btn.speaking {
    background: rgb(255 149 0 / 15%);
    color: #ff9500;
    animation: pulse 1s infinite;
}

html.dark .msg-action-btn.speaking {
    background: rgb(255 159 10 / 20%);
    color: #ff9f0a;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

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

/* ═══════════════════════════════════════════════════════════
   INPUT AREA - APPLE INTELLIGENCE PREMIUM DESIGN
   ═══════════════════════════════════════════════════════════ */

/* Container */
.chatbot-input-container {
    padding: 20px 24px;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    background: transparent;
    flex-shrink: 0;
    border-top: none;
}

/* Main Pill Wrapper */
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;

    /* Compact padding since buttons are inside */
    background: #FFF;
    border-radius: 40px;

    /* Full pill shape */
    box-shadow: 0 4px 24px rgb(0 0 0 / 8%), 0 1px 2px rgb(0 0 0 / 5%);
    border: 1px solid rgb(0 0 0 / 5%);
    transition: all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
}

html.dark .input-wrapper {
    background: #1C1C1E;
    box-shadow: 0 4px 24px rgb(0 0 0 / 40%);
    border: 1px solid rgb(255 255 255 / 10%);
}

.input-wrapper:focus-within {
    transform: translateY(-1px);
    box-shadow: 0 8px 32px rgb(0 122 255 / 15%);
    border-color: rgb(0 122 255 / 30%);
}

/* Voice Button (Left) - Green Circle */
.chatbot-voice-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    flex-shrink: 0;
    border-radius: 50%;
    border: none;
    background: #34C759;

    /* Apple Green */
    color: white;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease;
    margin-left: 4px;
}

.chatbot-voice-btn:hover {
    background: #30D158;
    transform: scale(1.05);
}

.chatbot-voice-btn:active {
    transform: scale(0.95);
}

/* Textarea (Center) - Clean & Invisible */
#chatbot-input {
    flex: 1;
    min-width: 0;

    /* Flexbox text overflow fix */
    background: transparent;
    border: none;
    outline: none;
    padding: 8px 4px;
    font-size: 16px;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
    color: #1D1D1F;
    line-height: 1.4;
    resize: none;
    max-height: 100px;
    overflow-y: auto;
}

html.dark #chatbot-input {
    color: #F5F5F7;
}

#chatbot-input::placeholder {
    color: #86868B;
}

/* Send Button (Right) - Blue Circle */
.chatbot-send-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    flex-shrink: 0;
    border-radius: 50%;
    border: none;
    background: #007AFF;

    /* Apple Blue */
    color: white;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease;
    margin-right: 4px;
}

.chatbot-send-btn:hover {
    background: #0071E3;
    transform: scale(1.05);
}

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

/* Scrollbar Hiding */
#chatbot-input::-webkit-scrollbar {
    display: none;
}


/* ═══════════════════════════════════════════════════════════
   TOGGLE BUTTON - GLOWING ORB
   ═══════════════════════════════════════════════════════════ */
#chatbot-toggle {
    position: fixed;
    bottom: 96px;
    /* Positioned UP - above go-to-top button (28 + 56 + 12 spacing) */
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: conic-gradient(from 180deg at 50% 50%, #2E88F9 0deg, #F93B30 72deg, #F9D030 144deg, #30D158 216deg, #2E88F9 360deg);
    border: 1px solid rgb(255 255 255 / 20%);
    color: white;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 10px 40px rgb(0 0 0 / 25%);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 9998;
    animation: orbSpin 10s linear infinite;
}

@keyframes orbSpin {
    0% {
        filter: hue-rotate(0deg);
    }

    100% {
        filter: hue-rotate(360deg);
    }
}

#chatbot-toggle:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 15px 50px rgb(0 0 0 / 35%);
}

#chatbot-toggle i {
    filter: drop-shadow(0 2px 4px rgb(0 0 0 / 20%));
}

/* ═══════════════════════════════════════════════════════════
   2025 ENHANCEMENTS - WELCOME MESSAGE & VOICE INPUT
   ═══════════════════════════════════════════════════════════ */

/* Welcome Message Styling */
.welcome-message .message-content {
    text-align: center;
    padding: 24px 20px !important;
}

.welcome-icon {
    font-size: 32px;
    margin-bottom: 12px;
    animation: welcomePulse 2s ease-in-out infinite;
}

@keyframes welcomePulse {

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

    50% {
        transform: scale(1.1);
    }
}

.welcome-title {
    font-size: 18px;
    font-weight: 700;
    color: #1d1d1f;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

html.dark .welcome-title {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    -webkit-background-clip: text;
    background-clip: text;
}

.welcome-subtitle {
    font-size: 14px;
    color: #86868b;
    line-height: 1.4;
}

html.dark .welcome-subtitle {
    color: #a1a1a6;
}

/* Voice Button Active/Listening State */
.chatbot-voice-btn.listening {
    background: #FF3B30 !important;
    animation: voicePulse 1s ease-in-out infinite;
}

@keyframes voicePulse {

    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.4);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 12px rgba(255, 59, 48, 0);
    }
}

/* ═══════════════════════════════════════════════════════════
   MOBILE STYLES MOVED TO src/assets/css/chatbot-mobile.css
   ═══════════════════════════════════════════════════════════ */

/* Tablet & Desktop Adjustments */
@media (min-width: 769px) {
    #chatbot-widget {
        width: 420px !important;
        height: 640px !important;
        /* Taller window to utilize available space */
        max-height: calc(100vh - 240px) !important;
        bottom: 168px !important;
        right: 24px !important;
        left: auto !important;
        top: auto !important;
        border-radius: 24px !important;
        box-shadow: 0 12px 50px rgba(0, 0, 0, 0.15) !important;
    }
}