/**
 * AI Chat Widget - CSS
 */

/* Chat Bubble */
#aict-chat-bubble {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: #0084ff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    transition: transform 0.3s ease;
}

.aict-position-bottom-left #aict-chat-bubble {
    right: auto;
    left: 20px;
}

#aict-chat-bubble:hover {
    transform: scale(1.1);
}

#aict-chat-bubble svg {
    width: 30px;
    height: 30px;
    fill: white;
}

/* Chat Window */
#aict-chat-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
    display: none;
    flex-direction: column;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.aict-position-bottom-left #aict-chat-window {
    right: auto;
    left: 20px;
}

#aict-chat-window.open {
    display: flex;
}

#aict-chat-window.aict-inline {
    position: relative;
    bottom: auto;
    right: auto;
    display: flex;
    margin: 20px auto;
}

/* Header */
#aict-chat-header {
    background: #0084ff;
    color: white;
    padding: 16px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#aict-chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

#aict-close-chat {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    line-height: 1;
}

#aict-close-chat:hover {
    opacity: 0.8;
}

/* Pre-chat Form */
#aict-pre-chat-form {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#aict-pre-chat-form h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: #333;
}

#aict-pre-chat-form input,
#aict-pre-chat-form textarea {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
}

#aict-pre-chat-form input:focus,
#aict-pre-chat-form textarea:focus {
    outline: none;
    border-color: #0084ff;
}

#aict-start-chat {
    padding: 12px;
    background: #0084ff;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s;
}

#aict-start-chat:hover {
    background: #0073e6;
}

#aict-start-chat:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Messages Container */
#aict-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: none;
    flex-direction: column;
    gap: 12px;
    background: #f9f9f9;
}

#aict-messages.active {
    display: flex;
}

/* Individual Messages */
.aict-message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    animation: messageSlideIn 0.3s ease;
}

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

.aict-message-user {
    background: #0084ff;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.aict-message-agent {
    background: white;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.aict-message-system {
    align-self: center;
    background: #fff3cd;
    color: #856404;
    font-size: 12px;
    padding: 6px 10px;
}

/* Typing Indicator */
.aict-typing-indicator {
    display: none;
    align-self: flex-start;
    padding: 10px 14px;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.aict-typing-indicator.active {
    display: block;
}

.aict-typing-indicator span {
    height: 8px;
    width: 8px;
    background: #90949c;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
    animation: typingDot 1.4s infinite;
}

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

.aict-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
    margin-right: 0;
}

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Input Area */
#aict-input-area {
    padding: 16px;
    border-top: 1px solid #eee;
    display: none;
    gap: 8px;
    background: white;
    border-radius: 0 0 12px 12px;
}

#aict-input-area.active {
    display: flex;
}

#aict-message-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
}

#aict-message-input:focus {
    border-color: #0084ff;
}

#aict-send-btn {
    width: 40px;
    height: 40px;
    background: #0084ff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

#aict-send-btn:hover {
    background: #0073e6;
}

#aict-send-btn svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* Scrollbar Styling */
#aict-messages::-webkit-scrollbar {
    width: 6px;
}

#aict-messages::-webkit-scrollbar-track {
    background: transparent;
}

#aict-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

#aict-messages::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* Mobile Responsive */
@media (max-width: 400px) {
    #aict-chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 110px);
        bottom: 10px;
        right: 10px;
    }
    
    .aict-position-bottom-left #aict-chat-window {
        left: 10px;
        right: auto;
    }
    
    #aict-chat-bubble {
        bottom: 10px;
        right: 10px;
    }
    
    .aict-position-bottom-left #aict-chat-bubble {
        left: 10px;
        right: auto;
    }
}

/* Admin Styles */
.aict-status-ai_mode {
    display: inline-block;
    padding: 4px 8px;
    background: #e3f2fd;
    color: #1976d2;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.aict-status-human_controlled {
    display: inline-block;
    padding: 4px 8px;
    background: #fff3e0;
    color: #f57c00;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.aict-chat-transcript {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    max-width: 800px;
}

.aict-message-user,
.aict-message-ai,
.aict-message-human {
    padding: 12px;
    margin-bottom: 12px;
    border-radius: 8px;
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.aict-message-user {
    border-left: 4px solid #0084ff;
}

.aict-message-ai {
    border-left: 4px solid #4caf50;
}

.aict-message-human {
    border-left: 4px solid #ff9800;
}