/* AI Agent Chat Widget Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Chat Button */
.ai-chat-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    z-index: 999998;
}

.ai-chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.ai-chat-button svg {
    width: 28px;
    height: 28px;
    fill: white;
}

/* Notification badge */
.ai-chat-button .notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #ff4757;
    border-radius: 50%;
    color: white;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

/* Chat Container */
.ai-chat-container {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 140px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: none;
    flex-direction: column;
    z-index: 999999;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.ai-chat-container.open {
    display: flex;
    animation: slideUp 0.3s ease;
}

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

/* Chat Header */
.ai-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.ai-chat-header-info h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.ai-chat-header-info p {
    font-size: 13px;
    opacity: 0.9;
    margin: 4px 0 0 0;
}

.ai-chat-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 24px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s;
    padding: 0;
    line-height: 1;
}

.ai-chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Messages Container */
.ai-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    scroll-behavior: smooth;
}

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

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

.ai-messages-container::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.ai-messages-container::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Message */
.ai-message {
    margin-bottom: 16px;
    display: flex;
    gap: 12px;
    animation: fadeIn 0.3s ease;
}

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

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

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

.ai-message.bot .ai-message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.ai-message.user .ai-message-avatar {
    background: #e9ecef;
}

.ai-message-content {
    max-width: 75%;
    min-width: 100px;
}

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

.ai-message.bot .ai-message-bubble {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.ai-message.user .ai-message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
    font-size: 14px;
    word-wrap: break-word;
    white-space: pre-line; /* ← LÄGG TILL */
}

.ai-message-bubble ul,
.ai-message-bubble ol {
    margin: 8px 0;
    padding-left: 20px;
}

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

.ai-message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    padding: 0 4px;
}

/* Welcome Suggestions */
.ai-welcome-suggestions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.ai-suggestion-button {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    color: #333;
    font-family: inherit;
}

.ai-suggestion-button:hover {
    background: white;
    border-color: #667eea;
    color: #667eea;
    transform: translateX(2px);
}

/* Typing Indicator */
.ai-typing-indicator {
    display: none;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 16px;
    width: fit-content;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.ai-typing-indicator.active {
    display: flex;
}

.ai-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: typing 1.4s infinite;
}

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

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

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

/* Input Container */
.ai-input-container {
    padding: 16px;
    background: white;
    border-top: 1px solid #e9ecef;
    flex-shrink: 0;
}

.ai-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.ai-input-wrapper textarea {
    flex: 1;
    border: 1px solid #dee2e6;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    min-height: 44px;
    line-height: 1.4;
}

.ai-input-wrapper textarea:focus {
    outline: none;
    border-color: #667eea;
}

.ai-input-wrapper textarea::placeholder {
    color: #a0aec0;
}

.ai-send-button {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.ai-send-button:hover:not(:disabled) {
    transform: scale(1.05);
}

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

.ai-send-button svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* Loading state */
.ai-chat-container.loading .ai-send-button {
    pointer-events: none;
}

/* Error message */
.ai-error-message {
    background: #fee;
    color: #c33;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    margin: 8px 0;
    display: none;
}

.ai-error-message.show {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .ai-chat-container {
        width: calc(100vw - 24px);
        height: calc(100vh - 120px);
        right: 12px;
        bottom: 80px;
        border-radius: 12px;
    }

    .ai-chat-button {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }

    .ai-chat-header {
        padding: 16px;
    }

    .ai-messages-container {
        padding: 16px;
    }
}

/* Tablet */
@media (max-width: 768px) and (min-width: 481px) {
    .ai-chat-container {
        width: 360px;
    }
}

/* Animations for better UX */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.ai-chat-button.pulse {
    animation: pulse 2s infinite;
}

/* Custom scrollbar for better look */
.ai-messages-container {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e0 transparent;
}

/* Accessibility */
.ai-chat-button:focus,
.ai-chat-close:focus,
.ai-send-button:focus,
.ai-suggestion-button:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .ai-chat-button,
    .ai-chat-container {
        display: none !important;
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    .ai-chat-container {
        background: #1a202c;
        color: #e2e8f0;
    }

    .ai-messages-container {
        background: #2d3748;
    }

    .ai-message.bot .ai-message-bubble {
        background: #4a5568;
        color: #e2e8f0;
    }

    .ai-suggestion-button {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }

    .ai-suggestion-button:hover {
        background: #4a5568;
        border-color: #667eea;
    }

    .ai-input-wrapper textarea {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }

    .ai-input-container {
        background: #1a202c;
        border-top-color: #4a5568;
    }
}
