/**
 * Doc Search AI - Frontend Chat Styles
 */

/* Prevent body scroll when modal is open */
body.doc-search-modal-open {
    overflow: hidden;
}

/* Modal Container */
.doc-search-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.doc-search-modal.active {
    display: block;
}

/* Overlay */
.doc-search-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

/* Modal Container */
.doc-search-modal-container {
    position: relative;
    width: 90%;
    max-width: 800px;
    height: 80vh;
    max-height: 700px;
    margin: 5vh auto;
    background: linear-gradient(135deg, #FFF9E6 0%, #FFFFFF 100%);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

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

/* Header */
.doc-search-modal-header {
    background: linear-gradient(135deg, #617559 0%, #617559 100%);
    padding: 25px 30px;
    border-radius: 20px 20px 0 0;
    position: relative;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.doc-search-modal-header h2 {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
    color: #F5EFE7!important;
    
}

.doc-search-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: #555;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.doc-search-close:hover {
    background: #fff;
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Body / Messages Area */
.doc-search-modal-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    background: #FEFEFE;
    scroll-behavior: smooth;
}

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

/* Message Styles */
.doc-search-message {
    display: flex;
    gap: 12px;
    animation: messageSlide 0.3s ease-out;
}

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

/* User Message */
.doc-search-message.user-message {
    justify-content: flex-end;
}

.doc-search-message.user-message .message-content {
    background: #2271b1;
    color: white;
    padding: 12px 18px;
    border-radius: 18px 18px 4px 18px;
    max-width: 70%;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(34, 113, 177, 0.2);
}

/* Bot Message */
.doc-search-message.bot-message {
    justify-content: flex-start;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.message-bubble {
    flex: 1;
    max-width: 75%;
}

.doc-search-message.bot-message .message-content {
    background: #f0f2f5;
    color: #1c1e21;
    padding: 12px 18px;
    border-radius: 4px 18px 18px 18px;
    word-wrap: break-word;
    line-height: 1.6;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    white-space: pre-wrap; /* Preserve whitespace and newlines */
}

.doc-search-message.bot-message .message-content br {
    display: block;
    content: "";
    margin: 0.5em 0;
}

.doc-search-message.bot-message .message-content a {
    color: #2271b1;
    text-decoration: underline;
    word-break: break-all;
}

/* Sources */
.message-sources {
    margin-top: 10px;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 10px;
    font-size: 13px;
    border: 1px solid #e0e0e0;
}

.message-sources strong {
    display: block;
    margin-bottom: 6px;
    color: #555;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.message-sources ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

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

.message-sources a {
    color: #2271b1;
    text-decoration: none;
    transition: color 0.2s;
    display: inline-block;
    word-break: break-all;
}

.message-sources a:hover {
    color: #135e96;
    text-decoration: underline;
}

/* Typing Indicator */
.typing-indicator .message-content {
    padding: 12px 18px !important;
}

.typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

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

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

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

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

/* Footer / Input Area */
.doc-search-modal-footer {
    padding: 20px;
    background: #fff;
    border-top: 1px solid #e0e0e0;
}

.doc-search-chat-form {
    display: flex;
    gap: 12px;
    align-items: center;
}

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

.doc-search-chat-input:focus {
    border-color: #2271b1;
}

.doc-search-chat-submit {
    width: fit-content;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2271b1 0%, #135e96 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(34, 113, 177, 0.3);
}

.doc-search-chat-submit:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(34, 113, 177, 0.4);
}

.doc-search-chat-submit:active {
    transform: scale(0.95);
}

/* Scrollbar Styling */
.doc-search-modal-body::-webkit-scrollbar {
    width: 6px;
}

.doc-search-modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.doc-search-modal-body::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.doc-search-modal-body::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .doc-search-modal-container {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
    }
    
    .doc-search-modal-header {
        border-radius: 0;
        padding: 20px;
    }
    
    .doc-search-modal-header h2 {
        font-size: 22px;
    }
    
    .message-bubble {
        max-width: 85%;
    }
    
    .doc-search-message.user-message .message-content {
        max-width: 85%;
    }
}

/* Empty State */
.doc-search-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.doc-search-empty-state-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.doc-search-empty-state p {
    margin: 0;
    font-size: 16px;
}