/* Needful AI Chat Widget Styles */

:root {
    --needful-teal: #14B8A6;
    --needful-teal-dark: #0D9488;
    --needful-dark: #14B8A6;
    --needful-darker: #0D9488;
    --needful-gray: #6B7280;
    --needful-light: #F9FAFB;
}

.needful-ai-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.needful-ai-toggle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--needful-teal) 0%, var(--needful-teal-dark) 100%);
    border: none;
    color: white;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(20, 184, 166, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.needful-ai-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 32px rgba(20, 184, 166, 0.5);
}

.needful-ai-toggle.active {
    display: none;
}

.needful-ai-toggle svg {
    width: 28px;
    height: 28px;
}

.needful-ai-panel {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 420px;
    max-width: calc(100vw - 40px);
    height: 650px;
    max-height: calc(100vh - 140px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.needful-ai-panel.active {
    display: flex;
}

.needful-ai-header {
    padding: 20px 24px;
    background: linear-gradient(135deg, var(--needful-dark) 0%, var(--needful-darker) 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--needful-teal);
}

.needful-ai-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
}

.needful-ai-header h3::before {
    content: '';
    font-size: 20px;
}

.needful-ai-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
}

.needful-ai-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.needful-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--needful-light);
    scroll-behavior: smooth;
}

.needful-ai-messages::-webkit-scrollbar {
    width: 6px;
}

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

.needful-ai-messages::-webkit-scrollbar-thumb {
    background: rgba(107, 114, 128, 0.3);
    border-radius: 3px;
}

.needful-ai-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(107, 114, 128, 0.5);
}

.needful-ai-message {
    margin-bottom: 20px;
    display: flex;
    animation: messageSlide 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.needful-ai-message-content {
    padding: 14px 18px;
    border-radius: 16px;
    max-width: 85%;
    word-wrap: break-word;
    line-height: 1.6;
    font-size: 15px;
}

.needful-ai-message-user .needful-ai-message-content {
    background: linear-gradient(135deg, var(--needful-teal) 0%, var(--needful-teal-dark) 100%);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 6px;
    box-shadow: 0 2px 8px rgba(20, 184, 166, 0.3);
}

.needful-ai-message-assistant .needful-ai-message-content {
    background: white;
    color: var(--needful-dark);
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.needful-ai-message-thinking .needful-ai-message-content {
    background: white;
    color: var(--needful-gray);
    font-style: italic;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* Markdown Styles in Messages */
.needful-ai-message-content p {
    margin: 0 0 12px 0;
}

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

.needful-ai-message-content strong {
    font-weight: 600;
    color: inherit;
}

.needful-ai-message-content em {
    font-style: italic;
}

.needful-ai-message-content a {
    color: var(--needful-teal);
    text-decoration: underline;
    transition: opacity 0.2s;
}

.needful-ai-message-user .needful-ai-message-content a {
    color: white;
    text-decoration: underline;
    font-weight: 500;
}

.needful-ai-message-content a:hover {
    opacity: 0.8;
}

.needful-ai-message-content code {
    background: rgba(0, 0, 0, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 13px;
}

.needful-ai-message-user .needful-ai-message-content code {
    background: rgba(255, 255, 255, 0.2);
}

.needful-ai-message-content pre {
    background: var(--needful-darker);
    color: #E5E7EB;
    padding: 12px 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.5;
}

.needful-ai-message-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.needful-ai-message-content ul,
.needful-ai-message-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.needful-ai-message-content li {
    margin: 4px 0;
}

.needful-ai-message-content blockquote {
    border-left: 3px solid var(--needful-teal);
    padding-left: 12px;
    margin: 12px 0;
    color: var(--needful-gray);
    font-style: italic;
}

.needful-ai-typing-indicator {
    display: inline-flex;
    gap: 5px;
    padding: 4px 0;
}

.needful-ai-typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--needful-gray);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.needful-ai-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.needful-ai-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

.needful-ai-input-container {
    padding: 20px;
    background: white;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.needful-ai-input {
    flex: 1;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    min-height: 48px;
    max-height: 120px;
    line-height: 1.5;
    transition: all 0.2s;
    margin-bottom: 0px;
}

.needful-ai-input:focus {
    outline: none;
    border-color: var(--needful-teal);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.1);
}

.needful-ai-input::placeholder {
    color: var(--needful-gray);
}

.needful-ai-send {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    flex-shrink: 0;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--needful-teal) 0%, var(--needful-teal-dark) 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
    box-shadow: 0 2px 8px rgba(20, 184, 166, 0.3);
}

.needful-ai-send svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
}

.needful-ai-send:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.4);
}

.needful-ai-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: scale(1);
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .needful-ai-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        max-width: 100%;
        border-radius: 0;
    }
    
    .needful-ai-toggle {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }
    
    .needful-ai-messages {
        padding: 16px;
    }
}

/* Error message */
.needful-ai-error {
    padding: 14px 16px;
    background: #FEE2E2;
    color: #991B1B;
    border-radius: 12px;
    margin: 12px 0;
    font-size: 14px;
    border: 1px solid #FECACA;
    animation: messageSlide 0.3s ease-out;
}

