/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

/* Main chat container */
.chat-container {
    max-width: 800px;
    margin: 0 auto;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.1);
}

/* Header */
.chat-header {
    background: linear-gradient(135deg, #2c3e50, #3498db);
    color: white;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

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

.chat-header p {
    opacity: 0.9;
    font-size: 0.9rem;
    margin-bottom: 15px;
}

.source-indicators {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.source-badge {
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

.source-badge.active {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
}

.source-badge.inactive {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
}

.source-badge.active:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

.message {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
}

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

.assistant-message {
    align-items: flex-start;
}

.message-content {
    max-width: 85%;
    padding: 15px 20px;
    border-radius: 18px;
    line-height: 1.5;
    word-wrap: break-word;
}

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

.assistant-message .message-content {
    background: white;
    color: #333;
    border: 1px solid #e1e5e9;
    border-bottom-left-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.message-timestamp {
    font-size: 0.75rem;
    opacity: 0.6;
    margin-top: 5px;
}

/* Welcome message */
.welcome-message .message-content {
    background: linear-gradient(135deg, #e8f5e8, #f0f8f0);
    border-left: 4px solid #28a745;
}

.welcome-message h3 {
    color: #28a745;
    margin-bottom: 10px;
}

.welcome-message ul {
    margin: 15px 0;
    padding-left: 20px;
}

.welcome-message li {
    margin-bottom: 5px;
}

.data-note {
    margin: 15px 0;
    padding: 10px;
    background: rgba(255, 193, 7, 0.1);
    border-left: 4px solid #ffc107;
    border-radius: 4px;
}

.data-note p {
    color: #856404;
    margin: 0;
    font-size: 0.9rem;
}

/* Example queries */
.example-queries {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid rgba(40, 167, 69, 0.2);
}

.example-queries h4 {
    margin-bottom: 10px;
    color: #495057;
    font-size: 0.9rem;
}

.example-query {
    display: inline-block;
    margin: 5px 5px;
    padding: 8px 12px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 15px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #495057;
}

.example-query:hover {
    background: #667eea;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

/* Chat input */
.chat-input-container {
    background: white;
    border-top: 1px solid #e1e5e9;
    padding: 20px;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 10px;
    opacity: 0.8;
}

.typing-indicator span {
    width: 4px;
    height: 4px;
    background: #667eea;
    border-radius: 50%;
    animation: typing 1.5s infinite;
}

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

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

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

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: #f8f9fa;
    border: 2px solid #e1e5e9;
    border-radius: 12px;
    padding: 10px;
    transition: border-color 0.3s ease;
}

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

#chat-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
    max-height: 120px;
    outline: none;
}

#chat-input::placeholder {
    color: #adb5bd;
}

#send-button {
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#send-button:hover:not(:disabled) {
    background: #5a6fd8;
    transform: translateY(-1px);
}

#send-button:disabled {
    background: #ced4da;
    cursor: not-allowed;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    font-size: 0.8rem;
    color: #6c757d;
}

.char-count {
    color: #adb5bd;
}

.input-actions {
    display: flex;
    gap: 10px;
}

.clear-button, .export-button {
    background: none;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #6c757d;
}

.clear-button:hover, .export-button:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.modal-content h3 {
    margin-bottom: 15px;
    color: #dc3545;
}

.modal-content p {
    margin-bottom: 20px;
    color: #6c757d;
}

.modal-content button {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.modal-content button:hover {
    background: #5a6fd8;
}

/* Responsive design */
@media (max-width: 768px) {
    .chat-container {
        height: 100vh;
        border-radius: 0;
    }

    .chat-header {
        padding: 15px;
    }

    .chat-header h1 {
        font-size: 1.5rem;
    }

    .source-indicators {
        flex-direction: column;
        align-items: center;
    }

    .message-content {
        max-width: 95%;
    }

    .example-queries {
        text-align: center;
    }

    .example-query {
        display: block;
        margin: 5px 0;
        width: 100%;
    }
}

/* Content Management Response Styling */
.content-management-response {
    border-left: 4px solid #17a2b8;
    padding-left: 15px;
    background: linear-gradient(135deg, #e8f7f9, #f0f9fa);
    border-radius: 8px;
    margin: 10px 0;
}

.command-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(23, 162, 184, 0.2);
}

.command-icon {
    font-size: 1.2em;
}

.command-type {
    font-weight: 600;
    color: #17a2b8;
    font-size: 0.9em;
}

.success-indicator {
    color: #28a745;
    font-weight: bold;
}

.error-indicator {
    color: #dc3545;
    font-weight: bold;
}

.command-content {
    white-space: pre-wrap;
    line-height: 1.5;
    color: #333;
}

.command-metadata {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(23, 162, 184, 0.1);
    color: #6c757d;
}

.command-metadata small {
    font-size: 0.8em;
}

/* Content Management Response in Dark Mode */
@media (prefers-color-scheme: dark) {
    .content-management-response {
        background: linear-gradient(135deg, #1a4a52, #2a3f42);
        border-left-color: #20c997;
    }

    .command-header {
        border-bottom-color: rgba(32, 201, 151, 0.2);
    }

    .command-type {
        color: #20c997;
    }

    .command-content {
        color: #e9ecef;
    }

    .command-metadata {
        border-top-color: rgba(32, 201, 151, 0.1);
        color: #adb5bd;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    }

    .chat-container {
        background: rgba(44, 62, 80, 0.95);
        color: #ecf0f1;
    }

    .chat-messages {
        background: #34495e;
    }

    .assistant-message .message-content {
        background: #2c3e50;
        color: #ecf0f1;
        border-color: #4a6741;
    }

    .input-wrapper {
        background: #2c3e50;
        border-color: #4a6741;
    }

    #chat-input {
        color: #ecf0f1;
    }

    #chat-input::placeholder {
        color: #95a5a6;
    }
}