/* StableState Help IQ Chat Widget Styles */

.chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Chat Bubble (Floating Button) */
.chat-bubble {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4a148c 0%, #6a1b9a 50%, #d4af37 100%);
    box-shadow: 0 4px 20px rgba(74, 20, 140, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
    position: relative;
    animation: pulse 2s infinite;
}

.chat-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(74, 20, 140, 0.4);
}

.chat-bubble.hidden {
    opacity: 0;
    transform: scale(0);
    pointer-events: none;
}

.chat-bubble svg {
    width: 28px;
    height: 28px;
}

.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #d4af37;
    color: #4a148c;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    border: 2px solid white;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(74, 20, 140, 0.3);
    }
    50% {
        box-shadow: 0 4px 30px rgba(74, 20, 140, 0.5), 0 0 0 8px rgba(74, 20, 140, 0.1);
    }
}

/* Chat Window */
.chat-window {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 400px;
    max-width: calc(100vw - 48px);
    height: 600px;
    max-height: calc(100vh - 48px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Dark Mode Support */
html[data-theme="dark"] .chat-window {
    background: #1a1a2e;
    border: 1px solid #404060;
}

html[data-theme="dark"] .chat-message.user-message .message-content {
    background: linear-gradient(135deg, #4a148c, #6a1b9a);
    color: white;
}

html[data-theme="dark"] .chat-message.assistant-message .message-content {
    background: #252541;
    color: #f0f0f5;
}

html[data-theme="dark"] .chat-input {
    background: #252541;
    border-color: #404060;
    color: #f0f0f5;
}

html[data-theme="dark"] .chat-footer {
    background: #252541;
    border-top-color: #404060;
    color: #b0b0c0;
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #4a148c 0%, #6a1b9a 50%, #8b4c8b 100%);
    color: white;
    padding: 20px;
    border-radius: 16px 16px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

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

.chat-avatar {
    font-size: 32px;
    line-height: 1;
}

.chat-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.chat-status {
    margin: 4px 0 0 0;
    font-size: 0.85rem;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    display: inline-block;
    animation: blink 2s infinite;
}

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

.close-chat {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.close-chat:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

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

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

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

.chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.chat-message {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    animation: slideIn 0.3s ease;
}

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

.chat-message.user-message {
    flex-direction: row-reverse;
}

.message-avatar {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: #f3f4f6;
}

.message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 0.95rem;
    word-wrap: break-word;
}

.chat-message.user-message .message-content {
    background: linear-gradient(135deg, #4a148c, #6a1b9a);
    color: white;
    border-radius: 12px 12px 0 12px;
}

.chat-message.assistant-message .message-content {
    background: #f3f4f6;
    color: #1f2937;
    border-radius: 12px 12px 12px 0;
}

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

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

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

/* Typing Indicator */
.typing-indicator .typing-dots {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #6b7280;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

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

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

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

/* Chat Input */
.chat-input-container {
    padding: 16px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px 16px;
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    transition: border-color 0.2s ease;
    line-height: 1.5;
}

.chat-input:focus {
    outline: none;
    border-color: #6a1b9a;
}

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

.send-button {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #4a148c, #6a1b9a);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
    background: linear-gradient(135deg, #6a1b9a, #8b4c8b);
    transform: scale(1.05);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Chat Footer */
.chat-footer {
    padding: 12px 20px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    border-radius: 0 0 16px 16px;
    text-align: center;
    font-size: 0.8rem;
    color: #6b7280;
    flex-shrink: 0;
}

.chat-footer a {
    color: #6a1b9a;
    text-decoration: none;
    font-weight: 500;
}

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

/* Mobile Responsive */
@media (max-width: 480px) {
    .chat-window {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }

    .chat-window.open {
        border-radius: 0;
    }

    .chat-header {
        border-radius: 0;
    }

    .chat-footer {
        border-radius: 0;
    }

    .chat-bubble {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
    }
}

/* Accessibility */
.chat-input:focus,
.send-button:focus,
.close-chat:focus {
    outline: 2px solid #6a1b9a;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .chat-widget {
        display: none !important;
    }
}
