* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.chat-container {
    width: 100%;
    max-width: 700px;
    height: 85vh;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    text-align: center;
    position: relative;
}

.chat-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 5px;
}

.chat-header p {
    font-size: 0.9rem;
    opacity: 0.9;
}

.refresh-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.refresh-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.refresh-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.refresh-btn.loading svg {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    display: block;
    max-width: 95%;
    animation: fadeIn 0.3s ease;
}

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

.user-message {
    align-self: flex-end;
}

.bot-message {
    align-self: flex-start;
    max-width: 100%;
    width: 100%;
}

.message-content {
    padding: 16px 20px;
    border-radius: 18px;
    line-height: 1.4;
    font-size: 0.95rem;
    display: block !important;
    width: 100%;
}

.message-content p {
    margin: 0 0 6px 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content h2, .message-content h3, .message-content h4 {
    margin: 10px 0 4px 0;
    font-weight: 600;
}

.message-content h2 {
    font-size: 1.1rem;
}

.message-content h3 {
    font-size: 1rem;
}

.message-content h4 {
    font-size: 0.95rem;
}

.message-content ul, .message-content ol {
    margin: 2px 0 6px 0;
    padding-left: 18px;
    line-height: 1.4;
}

.message-content li {
    margin: 1px 0;
    padding: 0;
    line-height: 1.35;
}

.message-content li p {
    margin: 0;
}

.message-content hr {
    border: none;
    border-top: 1px solid #ccc;
    margin: 8px 0;
}

.message-content strong {
    font-weight: 600;
}

.message-content em {
    font-style: italic;
}

.pdf-images {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.pdf-image-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.pdf-screenshot {
    max-width: 200px;
    max-height: 280px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    cursor: pointer;
    transition: transform 0.2s;
}

.pdf-screenshot:hover {
    transform: scale(1.05);
}

.pdf-image-label {
    font-size: 0.75rem;
    color: #666;
    margin-top: 4px;
}

.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    cursor: pointer;
}

.modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
}

.modal-content img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 8px;
}

.close-modal {
    position: absolute;
    top: -30px;
    right: 0;
    color: white;
    font-size: 28px;
    cursor: pointer;
}

.feedback-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(0,0,0,0.1);
}

.feedback-label {
    font-size: 0.8rem;
    color: #666;
}

.feedback-btn {
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.feedback-btn:hover {
    background: #f0f0f0;
}

.feedback-btn.positive:hover {
    border-color: #4CAF50;
    background: #e8f5e9;
}

.feedback-btn.negative:hover {
    border-color: #f44336;
    background: #ffebee;
}

.feedback-thanks {
    font-size: 0.8rem;
    color: #666;
}

.confluence-images {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

.confluence-image-container {
    background: #f5f5f5;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.confluence-screenshot {
    max-width: 100%;
    max-height: 300px;
    cursor: pointer;
    transition: transform 0.2s;
}

.confluence-screenshot:hover {
    transform: scale(1.02);
}

.header-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.settings-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 6px;
    padding: 6px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background 0.2s;
}

.settings-btn svg {
    width: 14px;
    height: 14px;
}

.settings-btn:hover {
    background: rgba(255,255,255,0.3);
}

.settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.settings-modal.hidden {
    display: none;
}

.settings-content {
    background: white;
    padding: 25px;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.settings-content h3 {
    margin: 0 0 5px 0;
    color: #333;
}

.settings-hint {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 15px;
}

#promptEditor {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
    min-height: 150px;
}

#promptEditor:focus {
    outline: none;
    border-color: #667eea;
}

.settings-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    justify-content: flex-end;
}

.save-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
}

.save-btn:hover {
    opacity: 0.9;
}

.cancel-btn {
    background: #f0f0f0;
    color: #333;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
}

.settings-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.tab-btn {
    background: none;
    border: none;
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 6px;
    color: #666;
    font-weight: 500;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: #f0f0f0;
}

.tab-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.95rem;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.form-group small {
    display: block;
    margin-top: 4px;
    color: #888;
    font-size: 0.8rem;
}

.test-btn {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
}

.datasource-status {
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 15px;
    display: none;
}

.datasource-status.success {
    display: block;
    background: #e8f5e9;
    color: #2e7d32;
}

.datasource-status.error {
    display: block;
    background: #ffebee;
    color: #c62828;
}

.video-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
    color: white;
    padding: 8px 14px;
    border-radius: 20px;
    margin: 8px 0;
    font-size: 0.9rem;
}

.video-link a {
    color: white;
    text-decoration: none;
    font-weight: 500;
}

.video-link a:hover {
    text-decoration: underline;
}

.video-icon {
    font-size: 0.8rem;
}

.user-message .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.bot-message .message-content {
    background: #f0f2f5;
    color: #1a1a1a;
    border-bottom-left-radius: 4px;
}

.chat-input-container {
    padding: 20px;
    background: #ffffff;
    border-top: 1px solid #e0e0e0;
}

.chat-form {
    display: flex;
    gap: 12px;
}

#userInput {
    flex: 1;
    padding: 15px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s ease;
}

#userInput:focus {
    border-color: #667eea;
}

#sendButton {
    width: 50px;
    height: 50px;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#sendButton:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

#sendButton:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 15px 20px;
    background: #f0f2f5;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

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

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

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

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

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a0a0a0;
}

@media (max-width: 600px) {
    body {
        padding: 0;
    }
    
    .chat-container {
        height: 100vh;
        border-radius: 0;
        max-width: 100%;
    }
    
    .message {
        max-width: 90%;
    }
}

.typing-cursor {
    animation: blink 1s infinite;
    color: #667eea;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.thinking-indicator {
    background: linear-gradient(135deg, #f0f0f0 0%, #e8e8e8 100%);
}

.thinking-animation {
    display: flex;
    align-items: center;
    gap: 2px;
}

.thinking-text {
    color: #667eea;
    font-weight: 500;
}

.thinking-dots {
    display: inline-flex;
}

.thinking-dots span {
    color: #667eea;
    font-weight: bold;
    animation: dotPulse 1.4s infinite;
}

.thinking-dots span:nth-child(1) { animation-delay: 0s; }
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
    0%, 60%, 100% { opacity: 0.3; transform: scale(1); }
    30% { opacity: 1; transform: scale(1.2); }
}
