/**
 * Faciotech AI Assistant Chat Widget Styles
 */

/* Chat Toggle Button */
.ai-chat-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 9998;
}

.ai-chat-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(37, 99, 235, 0.5);
}

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

.ai-chat-toggle.bottom-left {
    right: auto;
    left: 24px;
}

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

/* Chat Window */
.ai-chat-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 520px;
    max-height: calc(100vh - 140px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s ease;
}

.ai-chat-window.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.ai-chat-window.bottom-left {
    right: auto;
    left: 24px;
}

/* Chat Header */
.ai-chat-header {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-chat-header .avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chat-header .avatar svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.ai-chat-header .info {
    flex: 1;
}

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

.ai-chat-header .info span {
    font-size: 12px;
    opacity: 0.9;
}

.ai-chat-header .close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

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

.ai-chat-header .close-btn svg {
    width: 18px;
    height: 18px;
    fill: white;
}

/* Chat Messages */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
    min-height: 0; /* Important for flex scrolling */
}

.ai-chat-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    overflow: hidden;
}

.ai-chat-message.user {
    background: #2563eb;
    color: white !important;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.ai-chat-message.user a {
    color: white !important;
    text-decoration: underline;
}

.ai-chat-message.assistant {
    background: white;
    color: #1e293b;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.ai-chat-message.assistant a {
    color: #2563eb;
    text-decoration: none;
}

.ai-chat-message.assistant a:hover {
    text-decoration: underline;
}

.ai-chat-message.assistant ul,
.ai-chat-message.assistant ol {
    margin: 8px 0;
    padding-left: 20px;
    list-style-position: outside;
}

.ai-chat-message.assistant li {
    margin: 6px 0;
    padding-left: 4px;
}

.ai-chat-message.assistant strong {
    font-weight: 600;
    color: #0f172a;
}

.ai-chat-message.assistant br + br {
    display: block;
    content: "";
    margin-top: 8px;
}

.ai-chat-message.assistant code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.ai-chat-message.assistant pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 13px;
    margin: 8px 0;
}

/* Typing Indicator */
.ai-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.ai-typing-indicator span {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

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

/* Related Articles */
.ai-related-articles {
    background: #f1f5f9;
    padding: 12px;
    border-radius: 8px;
    margin-top: 8px;
}

.ai-related-articles h5 {
    font-size: 12px;
    color: #64748b;
    margin: 0 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ai-related-articles a {
    display: block;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    margin-bottom: 6px;
    color: #1e293b;
    text-decoration: none;
    font-size: 13px;
    transition: background 0.2s;
}

.ai-related-articles a:last-child {
    margin-bottom: 0;
}

.ai-related-articles a:hover {
    background: #e2e8f0;
}

/* Chat Input */
.ai-chat-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
}

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

.ai-chat-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.ai-chat-input:focus {
    border-color: #2563eb;
}

.ai-chat-input::placeholder {
    color: #94a3b8;
}

.ai-chat-send {
    width: 44px;
    height: 44px;
    background: #2563eb;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ai-chat-send:hover {
    background: #1d4ed8;
}

.ai-chat-send:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}

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

/* Quick Actions */
.ai-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 16px 16px;
    background: #f8fafc;
}

.ai-quick-action {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    color: #475569;
}

.ai-quick-action:hover {
    background: #2563eb;
    border-color: #2563eb;
    color: white;
}

/* Feedback */
.ai-feedback {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    font-size: 12px;
    color: #64748b;
}

.ai-feedback button {
    background: #f1f5f9;
    border: none;
    padding: 4px 12px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.ai-feedback button:hover {
    background: #e2e8f0;
}

.ai-feedback button.active {
    background: #2563eb;
    color: white;
}

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

    .ai-chat-window.bottom-left {
        left: 0;
    }

    .ai-chat-toggle {
        bottom: 16px;
        right: 16px;
    }

    .ai-chat-toggle.bottom-left {
        left: 16px;
    }
}

/* Scrollbar */
.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

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

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
