@charset "UTF-8";

/* Reset and base styles */
.mks-chat-widget * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Chat Widget Container */
.mks-chat-widget {
    position: fixed;
    bottom: 15px;
    right: 15px;
    z-index: 1000;
}

/* Chat Button - Using your existing better styling */
.mks-chat-button {
    color: #fff;
    display: inline-block;
    width: 44px;
    height: 44px;
    text-align: center;
    line-height: 1;
    font-size: 18px;
    border: none;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: background 0.5s, opacity 0.3s;
    cursor: pointer;
}

.mks-chat-button:hover {
    opacity: 0.8;
}

.mks-chat-button:focus {
    outline: none;
}

.mks-chat-button.active {
    background: #f3f4f6;
}

.mks-chat-button i {
    font-size: 18px;
    line-height: 44px;
}

/* Chat Container - Using your existing better animation */
.mks-chat-container {
    position: fixed;
    background-color: #fff;
    right: 15px;
    bottom: 15px;
    width: 400px;
    height: 400px;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(2, 6, 23, .6);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(20px) scale(.98);
    opacity: 0;
    pointer-events: none;
    transition: all .18s ease;
    z-index: 1000;
}

.mks-chat-container.show {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

/* Chat Header */
.mks-chat-header {
    background: white;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mks-chat-title {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 6px;
}

.mks-status-dot {
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
}

.mks-status-dot.offline {
    background: #ef4444;
}

.mks-chat-actions {
    display: flex;
    gap: 8px;
}

.mks-action-btn {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #000;
    font-size: 16px;
    font-weight: 600;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.mks-action-btn:hover,
.mks-close-btn:hover {
    opacity: 0.8;
}

.mks-close-btn {
    background: none;
    border: none;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    color: #000;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.mks-close-btn:focus,
.mks-action-btn:focus {
    outline: none;
}

/* Messages Area */
.mks-messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    scroll-behavior: smooth;
}

.mks-message {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mks-message.user {
    align-items: flex-end;
}

.mks-message.assistant {
    align-items: flex-start;
}

.mks-message-content {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.4;
    word-wrap: break-word;
}

.user .mks-message-content {
    background: #f3f4f6;
    color: #374151;
    border-bottom-right-radius: 4px;
}

.assistant .mks-message-content {
    background: #f8fafc;
    color: #374151;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

.mks-message-meta {
    font-size: 10px;
    color: #6b7280;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.mks-confidence-badge {
    background: #f3f4f6;
    color: #374151;
    padding: 2px 4px;
    border-radius: 6px;
    font-size: 9px;
    font-weight: 500;
}

.confidence-high { background: #dcfce7; color: #166534; }
.confidence-medium { background: #fef3c7; color: #92400e; }
.confidence-low { background: #fee2e2; color: #991b1b; }

/* Typing indicator */
.mks-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    max-width: 85%;
    justify-content: center;
}

.mks-typing-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #9ca3af;
    animation: typing 1.4s infinite ease-in-out;
}

.mks-typing-dot:nth-child(1) { animation-delay: 0s; }
.mks-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.mks-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* Input Area */
.mks-input-area {
    background: white;
    border-top: 1px solid #e5e7eb;
    padding: 10px 12px;
}

.mks-input-container {
    display: flex;
    gap: 6px;
    align-items: flex-end;
}

.mks-input-wrapper {
    flex: 1;
    position: relative;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    padding: 6px 32px 6px 10px;
    min-height: 40px;
    display: flex;
    align-items: center;
}

.mks-input-wrapper:focus-within {
    border-color: #d3d3d3;
    background: white;
}

.mks-message-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    overflow: hidden;
    max-height: 80px;
}

.mks-message-input::placeholder {
    color: #6b7280;;
}

.mks-send-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: #000;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    font-weight: 600;
    transition: background 0.2s;
}

.mks-send-btn:hover {
    opacity: 0.8;
}

.mks-send-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}

/* Welcome message */
.mks-welcome-message {
    text-align: center;
    padding: 16px;
    color: #6b7280;
}

.mks-welcome-title {
    font-size: 14px;
    font-weight: 600;
    color: #000;
    margin-bottom: 6px;
}

.mks-welcome-subtitle {
    font-size: 12px;
}

/* PDF Viewers */
.mks-pdf-viewers {
    margin-top: 6px;
}

.mks-pdf-viewer-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 6px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.mks-pdf-viewer-item:hover {
    border-color: #3b82f6;
    box-shadow: 0 1px 3px rgba(59, 130, 246, 0.1);
}

.mks-pdf-viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3px;
}

.mks-pdf-viewer-title {
    font-weight: 500;
    color: #374151;
    font-size: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mks-pdf-viewer-page {
    font-size: 9px;
    color: #6b7280;
}

.mks-pdf-viewer-action {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 3px 6px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 9px;
    font-weight: 500;
    transition: background 0.2s;
    margin-top: 3px;
}

.mks-pdf-viewer-action:hover {
    background: #2563eb;
}

/* Page images display */
.mks-page-images {
    margin-top: 6px;
}

.mks-page-image-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 6px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.mks-page-image-item:hover {
    border-color: #3b82f6;
    box-shadow: 0 1px 3px rgba(59, 130, 246, 0.1);
}

.mks-page-image-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3px;
}

.mks-page-image-title {
    font-weight: 500;
    color: #374151;
    font-size: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mks-page-image-page {
    font-size: 9px;
    color: #6b7280;
}

.mks-page-image-action {
    background: #10b981;
    color: white;
    border: none;
    padding: 3px 6px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 9px;
    font-weight: 500;
    transition: background 0.2s;
    margin-top: 3px;
}

.mks-page-image-action:hover {
    background: #059669;
}

/* Image Modal */
.mks-image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.mks-image-modal.show {
    display: flex;
}

.mks-image-modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

.mks-image-modal img {
    width: 100%;
    height: auto;
    display: block;
    max-height: 80vh;
    object-fit: contain;
}

.mks-image-modal-header {
    padding: 12px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mks-image-modal-title {
    font-weight: 600;
    color: #374151;
    font-size: 14px;
}

.mks-image-modal-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #6b7280;
    padding: 4px;
}

.mks-image-modal-close:hover {
    color: #374151;
}

/* PDF Viewer Modal */
.mks-pdf-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.mks-pdf-modal.show {
    display: flex;
}

.mks-pdf-modal-content {
    position: relative;
    width: 100%;
    max-width: 900px;
    height: 90vh;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

.mks-pdf-modal-header {
    padding: 12px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mks-pdf-modal-title {
    font-weight: 600;
    color: #374151;
    font-size: 14px;
}

.mks-pdf-modal-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #6b7280;
    padding: 4px;
}

.mks-pdf-modal-close:hover {
    color: #374151;
}

.mks-pdf-iframe-container {
    position: relative;
    width: 100%;
    height: calc(90vh - 60px);
}

.mks-pdf-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.mks-pdf-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #374151;
}

.mks-loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #e0e0e0;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 6px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .mks-chat-widget {
        bottom: 15px;
        right: 15px;
    }
    
    .mks-chat-container {
        width: calc(100vw - 30px);
        height: calc(100vh - 120px);
        bottom: 70px;
        right: 15px;
        left: 15px;
    }

    .mks-message-content {
        max-width: 90%;
    }
}

