/* 
 * Inspero AI Chatbot - Frontend Widget Styles 
 * Vanilla CSS - No external dependencies.
 */

:root {
    --inspero-brand-color: #4F46E5;
    --inspero-text-primary: #111827;
    --inspero-text-secondary: #6B7280;
    --inspero-bg-ai: #F3F4F6;
    --inspero-bg-user: #4F46E5;
    --inspero-bg-window: #FFFFFF;
    --inspero-border-color: #E5E7EB;
    --inspero-shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --inspero-shadow-heavy: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --inspero-z-index: 2147483647; /* Max z-index to stay above everything */
}

/* Base Wrapper */
#inspero-chatbot-root {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--inspero-text-primary);
    box-sizing: border-box;
}

/* Modifiers */
#inspero-chatbot-root.inspero-position-left {
    right: auto;
    left: 24px;
}

#inspero-chat-trigger {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

#inspero-chatbot-root.inspero-trigger-hidden #inspero-chat-trigger {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

/* Device Visibility */
@media (max-width: 768px) {
    #inspero-chatbot-root.inspero-desktop-only {
        display: none !important;
    }
}
@media (min-width: 769px) {
    #inspero-chatbot-root.inspero-mobile-only {
        display: none !important;
    }
}

#inspero-chatbot-root *,
#inspero-chatbot-root *::before,
#inspero-chatbot-root *::after {
    box-sizing: inherit;
}

/* Trigger Button (Floating Action Button) */
.inspero-chat-trigger {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--inspero-brand-color);
    color: #ffffff;
    border: none;
    cursor: pointer;
    box-shadow: var(--inspero-shadow-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
    padding: 0;
    position: absolute;
    bottom: 0;
    right: 0;
}

.inspero-chat-trigger:hover {
    transform: scale(1.05);
    box-shadow: var(--inspero-shadow-heavy);
}

.inspero-chat-trigger svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
    transition: opacity 0.2s, transform 0.3s;
}

.inspero-chat-trigger .inspero-icon-close {
    position: absolute;
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

.inspero-chat-trigger.is-open .inspero-icon-chat {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

.inspero-chat-trigger.is-open .inspero-icon-close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

/* Chat Window */
.inspero-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--inspero-bg-window);
    border-radius: 16px;
    box-shadow: var(--inspero-shadow-heavy);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.inspero-chat-window.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* Header */
.inspero-chat-header {
    background: linear-gradient(135deg, var(--inspero-brand-color) 0%, rgba(0,0,0,0.1) 100%);
    background-color: var(--inspero-brand-color);
    padding: 20px 24px;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 16px 16px 0 0;
    flex-shrink: 0;
}

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

.inspero-chat-logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: cover;
    background: #ffffff;
    padding: 2px;
}

.inspero-chat-brand {
    font-weight: 600;
    font-size: 16px;
    letter-spacing: -0.01em;
}

.inspero-chat-close-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.inspero-chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.inspero-chat-close-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Messages Area */
.inspero-chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
    background: #fafafa;
}

/* Hide scrollbar for clean look */
.inspero-chat-messages::-webkit-scrollbar {
    width: 6px;
}
.inspero-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.inspero-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.1);
    border-radius: 3px;
}

/* Message Bubbles */
.inspero-message {
    display: flex;
    max-width: 85%;
    animation: inspero-fade-in-up 0.3s ease forwards;
}

.inspero-message-ai {
    align-self: flex-start;
}

.inspero-message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.inspero-message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14.5px;
    line-height: 1.5;
    word-wrap: break-word;
}

.inspero-message-ai .inspero-message-bubble {
    background: var(--inspero-bg-ai);
    color: var(--inspero-text-primary);
    border-bottom-left-radius: 4px;
}

.inspero-message-user .inspero-message-bubble {
    background: var(--inspero-brand-color);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

/* Markdown Styles inside AI bubble */
.inspero-message-ai .inspero-message-bubble p {
    margin: 0 0 10px 0;
}
.inspero-message-ai .inspero-message-bubble p:last-child {
    margin-bottom: 0;
}
.inspero-message-ai .inspero-message-bubble a {
    color: var(--inspero-brand-color);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.inspero-message-ai .inspero-message-bubble ul,
.inspero-message-ai .inspero-message-bubble ol {
    margin: 8px 0 8px 20px;
    padding: 0;
}
.inspero-message-ai .inspero-message-bubble code {
    background: rgba(0,0,0,0.05);
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 13px;
}
.inspero-message-ai .inspero-message-bubble pre {
    background: #2d3748;
    color: #e2e8f0;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 13px;
    margin: 10px 0;
}

/* Typing Indicator */
.inspero-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 16px 20px;
    background: var(--inspero-bg-ai);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    width: fit-content;
}

.inspero-typing-dot {
    width: 6px;
    height: 6px;
    background: var(--inspero-text-secondary);
    border-radius: 50%;
    animation: inspero-bounce 1.4s infinite ease-in-out both;
}

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

/* Suggestions */
.inspero-chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 20px 16px 20px;
    background: #fafafa;
}

.inspero-suggestion-pill {
    background: var(--inspero-white);
    border: 1px solid var(--inspero-border-color);
    color: var(--inspero-brand-color);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.inspero-suggestion-pill:hover {
    background: var(--inspero-brand-color);
    color: #ffffff;
    border-color: var(--inspero-brand-color);
}

/* Input Area */
.inspero-chat-input-area {
    padding: 16px 20px;
    background: var(--inspero-white);
    border-top: 1px solid var(--inspero-border-color);
    border-radius: 0 0 16px 16px;
}

.inspero-chat-form {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--inspero-bg-ai);
    border-radius: 24px;
    padding: 4px 4px 4px 16px;
    border: 1px solid transparent;
    transition: border-color 0.2s;
}

.inspero-chat-form:focus-within {
    border-color: var(--inspero-brand-color);
}

.inspero-chat-input {
    flex-grow: 1;
    border: none;
    background: transparent;
    padding: 8px 0;
    font-size: 14px;
    outline: none;
    color: var(--inspero-text-primary);
    font-family: inherit;
}

.inspero-chat-input::placeholder {
    color: #9CA3AF;
}

.inspero-chat-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--inspero-brand-color);
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.inspero-chat-send:active {
    transform: scale(0.95);
}

.inspero-chat-send svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
    margin-left: 2px; /* slight visual offset for paper plane */
}

.inspero-chat-send:disabled {
    background: #D1D5DB;
    cursor: not-allowed;
}

.inspero-chat-footer-branding {
    text-align: center;
    font-size: 11px;
    color: #9CA3AF;
    margin-top: 12px;
}

.inspero-chat-footer-branding a {
    color: inherit;
    text-decoration: none;
    font-weight: 500;
}

.inspero-chat-footer-branding a:hover {
    text-decoration: underline;
}

/* Animations */
@keyframes inspero-fade-in-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes inspero-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    #inspero-chatbot-root {
        bottom: 16px;
        right: 16px;
    }
    
    .inspero-chat-window {
        position: fixed;
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        transform: translateY(100%);
    }

    .inspero-chat-window.is-open {
        transform: translateY(0);
    }
    
    .inspero-chat-header {
        border-radius: 0;
        padding-top: env(safe-area-inset-top, 20px);
    }
    
    .inspero-chat-input-area {
        border-radius: 0;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }

    /* Hide trigger button when window is open on mobile */
    .inspero-chat-trigger.is-open {
        display: none;
    }
}
