/* ===================================
   Chat AI Styles
   =================================== */

/* FAB Button */
.chat-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10000001;
    border: none;
    outline: none;
}

.chat-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.6);
}

.chat-fab i {
    color: white;
    font-size: 24px;
}

.chat-fab.close-chat {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

/* Chat Modal */
.chat-modal {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 400px;
    max-width: calc(100vw - 60px);
    height: 600px;
    max-height: calc(100vh - 140px);
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    z-index: 10000000;
    overflow: hidden;
}

.chat-modal.active {
    display: flex;
    animation: slideUp 0.3s ease;
}

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

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

.chat-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-header-title i {
    font-size: 24px;
}

.chat-header-title h4 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.chat-header-title small {
    display: block;
    opacity: 0.9;
    font-size: 12px;
}

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

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

/* Chat Header Actions */
.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-clear {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
    opacity: 0.9;
}

.chat-clear:hover {
    background: rgba(255, 255, 255, 0.2);
    opacity: 1;
}

/* Chat Body */
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Chat Message */
.chat-message {
    display: flex;
    gap: 10px;
    animation: fadeIn 0.3s ease;
}

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

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

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

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

.chat-message.user .chat-avatar {
    background: #28a745;
    color: white;
}

.chat-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 15px;
    word-wrap: break-word;
    line-height: 1.5;
}

.chat-message.ai .chat-bubble {
    background: white;
    color: #333;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

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

.chat-bubble strong {
    font-weight: 600;
}

.chat-bubble a {
    color: #667eea;
    text-decoration: underline;
}

.chat-message.user .chat-bubble a {
    color: white;
    font-weight: 600;
}

.chat-time {
    font-size: 11px;
    color: #999;
    margin-top: 5px;
}

/* Document Links in Chat */
.document-link {
    display: block;
    padding: 10px;
    margin: 5px 0;
    background: #f0f4ff;
    border-left: 3px solid #667eea;
    border-radius: 5px;
    text-decoration: none;
    color: #333;
    transition: all 0.2s;
}

.document-link:hover {
    background: #e0e8ff;
    transform: translateX(5px);
}

.document-link-title {
    font-weight: 600;
    color: #667eea;
    margin-bottom: 5px;
}

.document-link-meta {
    font-size: 12px;
    color: #666;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 15px;
}

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

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

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

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

/* Chat Footer */
.chat-footer {
    padding: 15px 20px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

.chat-input-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    outline: none;
    font-size: 14px;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: #667eea;
}

.chat-send {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-send:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

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

/* Welcome Message */
.chat-welcome {
    text-align: center;
    padding: 30px 20px;
    color: #666;
}

.chat-welcome i {
    font-size: 48px;
    color: #667eea;
    margin-bottom: 15px;
}

.chat-welcome h5 {
    color: #333;
    margin-bottom: 10px;
}

.chat-welcome p {
    font-size: 14px;
    line-height: 1.6;
}

/* Responsive */
@media (max-width: 480px) {
    .chat-fab {
        bottom: 20px;
        right: 20px;
        width: 55px;
        height: 55px;
    }

    .chat-modal {
        bottom: 85px;
        right: 20px;
        width: calc(100vw - 40px);
        height: calc(100vh - 120px);
    }
}

/* Scrollbar Custom */
.chat-body::-webkit-scrollbar {
    width: 6px;
}

.chat-body::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-body::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 3px;
}

.chat-body::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}

/* Error Message */
.chat-error {
    padding: 10px;
    background: #fee;
    border-left: 3px solid #f44;
    border-radius: 5px;
    color: #c33;
    font-size: 13px;
}
