/* Mikasa Chatbot Styles */
:root {
    --cb-purple-primary: #8b5cf6;
    --cb-purple-light: #a78bfa;
    --cb-blue-light: #60a5fa;
    --cb-bg-gradient: linear-gradient(150deg, #FDFBFF 0%, #F8F5FF 30%, #F0F8FF 70%, #F5FBFF 100%);
    --cb-header-gradient: linear-gradient(135deg, #FAF6FF 0%, #F5F3FF 50%, #F0F8FF 100%);
    --cb-user-msg-gradient: linear-gradient(to bottom right, #a78bfa, #c4b5fd, #93c5fd);
    --cb-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: transparent;
    overflow: hidden;
    height: 100vh;
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
}

.chatbot-container {
    position: relative;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Character Orb & Pill Entry */
.chatbot-character {
    position: absolute;
    bottom: clamp(10px, 2vh, 20px);
    left: clamp(10px, 2vw, 20px);
    display: flex;
    align-items: center;
    gap: clamp(0px, 1vw, 5px);
    cursor: pointer;
    pointer-events: auto;
    z-index: 10000;
    transition: all 0.5s cubic-bezier(0.19, 1, 0.22, 1);
    transform: translateX(-clamp(10px, 1.5vw, 20px));
}

.chatbot-character.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50px) scale(0.8);
}

.orb-canvas-container {
    width: clamp(120px, 20vw, 320px);
    /* Increased for premium PC feel */
    height: clamp(120px, 20vw, 320px);
    position: relative;
    border-radius: 50%;
    filter: drop-shadow(0 0 20px rgba(0, 255, 140, 0.3));
    /* Stronger glow for overlay feel */
    transition: all 0.4s ease;
}

.chatbot-character:hover .orb-canvas-container {
    filter: drop-shadow(0 0 25px rgba(0, 255, 140, 0.4));
    transform: scale(1.05);
}

#orbCanvas {
    width: 100%;
    height: 100%;
}

.character-pill {
    padding: clamp(5px, 0.7vw, 7px) clamp(12px, 1.5vw, 18px);
    /* 50% height reduction */
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 99px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(139, 92, 246, 0.1);
    position: relative;
    overflow: hidden;
    transition: all 0.4s ease;
}

.pill-glow {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(139, 92, 246, 0.05), transparent);
    animation: pillShimmer 3s infinite;
}

@keyframes pillShimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

.character-pill i {
    font-size: 0.8rem;
    /* Scaled down icon */
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.character-pill span {
    font-size: clamp(0.7rem, 0.8vw, 0.8rem);
    /* Scaled down text */
    font-weight: 600;
    color: #059669;
    /* Emerald Green */
    white-space: nowrap;
}

.chatbot-character:hover .character-pill {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
    border-color: #059669;
}

/* Talking Animation Override for canvas-based orb */
.chatbot-character.talking .orb-canvas-container {
    animation: orbVibrate 0.3s infinite ease-in-out;
}

@keyframes orbVibrate {

    0%,
    100% {
        transform: rotate(0deg) scale(1.02);
    }

    25% {
        transform: rotate(1deg) scale(1.04);
    }

    75% {
        transform: rotate(-1deg) scale(1.04);
    }
}

/* Mobile & Tablet Responsive Adjustments */
@media (max-width: 1024px) {
    .character-pill {
        display: none !important;
        /* Hide box on tablet/mobile */
    }

    .chatbot-character {
        transform: none !important;
        /* Reset offset since box is gone */
        left: 10px;
        bottom: 10px;
    }
}

/* Chat Window */
.chat-window {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--cb-bg-gradient);
    border-radius: 24px;
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(139, 92, 246, 0.15);
    pointer-events: auto;
    z-index: 200;
}

.chat-window.open {
    display: flex;
    animation: windowOpen 0.5s cubic-bezier(0.19, 1, 0.22, 1);
}

@keyframes windowOpen {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(40px);
    }

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

/* Header */
.chat-header {
    padding: 16px 24px;
    background: var(--cb-header-gradient);
    border-bottom: 1px solid rgba(139, 92, 246, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    padding: 2px;
    border: 1px solid rgba(139, 92, 246, 0.2);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.header-text h2 {
    font-size: 1rem;
    color: #1e1b4b;
    font-weight: 600;
}

.header-text p {
    font-size: 0.75rem;
    color: #8b5cf6;
    display: flex;
    align-items: center;
    gap: 6px;
}

.online-indicator {
    width: 6px;
    height: 6px;
    background: #4ade80;
    border-radius: 50%;
    animation: blink 2s infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

.close-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
}

.close-btn:hover {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
}

/* Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scrollbar-width: thin;
    scrollbar-color: #ddd transparent;
}

.chat-messages::-webkit-scrollbar {
    width: 5px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background-color: #ddd;
    border-radius: 10px;
}

.message {
    max-width: 80%;
    display: flex;
    flex-direction: column;
    gap: 4px;
    animation: msgIn 0.3s ease-out;
}

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

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

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

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

.msg-bubble {
    padding: 12px 16px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.message.assistant .msg-bubble {
    background: white;
    color: #374151;
    border-radius: 2px 16px 16px 16px;
    border: 1px solid rgba(139, 92, 246, 0.1);
}

.message.user .msg-bubble {
    background: var(--cb-user-msg-gradient);
    color: white;
    border-radius: 16px 16px 2px 16px;
}

.msg-meta {
    font-size: 0.7rem;
    color: #94a3b8;
    margin: 0 4px;
}

.message.user .msg-meta {
    text-align: right;
}

/* Searching Pill (Perplexity Style) */
.typing-pill {
    display: none;
    align-self: center;
    margin: 10px 0;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px) saturate(200%);
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: 99px;
    display: none;
    align-items: center;
    gap: 12px;
    box-shadow: 0 12px 30px rgba(139, 92, 246, 0.15), 0 4px 10px rgba(0, 0, 0, 0.05);
    animation: pillPop 0.5s cubic-bezier(0.19, 1, 0.22, 1);
    z-index: 10;
}

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

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

.pulsing-orb {
    width: 10px;
    height: 10px;
    background: #8b5cf6;
    border-radius: 50%;
    position: relative;
}

.pulsing-orb::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: rgba(139, 92, 246, 0.4);
    animation: orbBreath 1.5s infinite ease-in-out;
}

@keyframes orbBreath {

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

    50% {
        transform: scale(1.8);
        opacity: 0.6;
    }
}

#searching-text {
    font-size: 0.85rem;
    font-weight: 500;
    color: #4b5563;
    letter-spacing: -0.01em;
}

/* Input Area */
.chat-input-area {
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(139, 92, 246, 0.1);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: white;
    padding: 8px 12px;
    border-radius: 24px;
    border: 1px solid rgba(139, 92, 246, 0.2);
    transition: all 0.2s;
}

.input-wrapper:focus-within {
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

textarea {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 4px;
    font-size: 0.9rem;
    color: #374151;
    resize: none;
    max-height: 120px;
    outline: none;
    line-height: normal;
}

.send-btn {
    background: var(--cb-purple-primary);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.send-btn:hover {
    background: #7c3aed;
    transform: scale(1.05);
}

.send-btn:disabled {
    background: #e2e8f0;
    cursor: not-allowed;
    transform: none;
}

.input-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 10px;
    font-size: 0.7rem;
    color: #94a3b8;
}

.sparkle-icon {
    width: 12px;
    height: 12px;
    color: #8b5cf6;
}

/* Markdown styling in messages */
.msg-bubble p {
    margin-bottom: 8px;
}

.msg-bubble p:last-child {
    margin-bottom: 0;
}

.msg-bubble strong {
    font-weight: 700;
}

.msg-bubble ul,
.msg-bubble ol {
    margin-left: 20px;
    margin-bottom: 8px;
}

.msg-bubble li {
    margin-bottom: 4px;
}