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

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

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    background: white;
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

h1 {
    font-size: 2.5em;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 10px;
}

.subtitle {
    color: #666;
    font-size: 1.1em;
}

.filters {
    background: white;
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.filters h2 {
    font-size: 1.3em;
    margin-bottom: 20px;
    color: #667eea;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 15px;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-group label {
    font-weight: 600;
    margin-bottom: 8px;
    color: #555;
    font-size: 0.9em;
}

.filter-group input,
.filter-group select {
    padding: 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    transition: all 0.3s ease;
}

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

.stats {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid #f0f0f0;
}

.stat-item {
    font-size: 0.95em;
    color: #666;
}

.stat-item strong {
    color: #667eea;
    font-weight: 700;
}

.conversations {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.conversation-card {
    background: white;
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.conversation-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.15);
}

.conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.conversation-meta {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.meta-badge {
    padding: 6px 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
}

.meta-info {
    font-size: 0.9em;
    color: #888;
}

.toggle-btn {
    padding: 8px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s ease;
}

.toggle-btn:hover {
    background: #5568d3;
}

.action-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    font-size: 0.9em;
    flex: 1;
}

.clear-btn {
    background: #fc8181;
    color: white;
}

.clear-btn:hover {
    background: #f56565;
}

.toggle-btn-action {
    background: #48bb78;
    color: white;
}

.toggle-btn-action:hover {
    background: #38a169;
}

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

.message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: slideIn 0.3s ease;
}

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

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

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

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.role-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 700;
    text-transform: uppercase;
}

.role-badge.user {
    background: #667eea;
    color: white;
}

.role-badge.assistant {
    background: #48bb78;
    color: white;
}

.timestamp {
    font-size: 0.75em;
    color: #999;
}

.message-content {
    padding: 15px 18px;
    border-radius: 12px;
    line-height: 1.6;
    word-wrap: break-word;
}

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

.message.assistant .message-content {
    background: #f7fafc;
    color: #333;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

.message-content h3 {
    margin: 10px 0;
    font-size: 1.1em;
}

.message-content ul, .message-content ol {
    margin-left: 20px;
    margin-top: 10px;
}

.message-content li {
    margin: 5px 0;
}

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

.loading {
    text-align: center;
    padding: 60px 20px;
    color: white;
    font-size: 1.2em;
}

.loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

.error {
    background: #fed7d7;
    color: #c53030;
    padding: 20px;
    border-radius: 12px;
    margin: 20px 0;
    border: 2px solid #fc8181;
}

.no-results {
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: 16px;
    color: #666;
}

.no-results h3 {
    font-size: 1.5em;
    margin-bottom: 10px;
    color: #667eea;
}

.collapsed {
    display: none;
}

@media (max-width: 768px) {
    h1 {
        font-size: 1.8em;
    }

    .filter-grid {
        grid-template-columns: 1fr;
    }

    .conversation-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

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

/* Markdown-like styling for assistant messages */
.message.assistant .message-content h1,
.message.assistant .message-content h2,
.message.assistant .message-content h3,
.message.assistant .message-content h4 {
    color: #667eea;
    margin-top: 15px;
    margin-bottom: 10px;
}

.message.assistant .message-content a {
    color: #667eea;
    text-decoration: none;
    border-bottom: 1px solid #667eea;
}

.message.assistant .message-content a:hover {
    border-bottom: 2px solid #667eea;
}

.message.assistant .message-content code {
    background: #edf2f7;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

/* Login Form Styles */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    background: white;
    border-radius: 16px;
    padding: 40px;
    max-width: 450px;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.login-box h1 {
    font-size: 2em;
    margin-bottom: 10px;
}

.login-box .subtitle {
    color: #666;
    margin-bottom: 30px;
}

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

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #555;
    font-size: 0.9em;
}

.form-group input[type="password"] {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.form-group input[type="password"]:focus {
    outline: none;
    border-color: #667eea;
}

#loginBtn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.3s ease;
}

#loginBtn:hover {
    opacity: 0.9;
}

#loginBtn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.login-error {
    margin-top: 15px;
    padding: 12px;
    background: #fed7d7;
    color: #c53030;
    border-radius: 8px;
    border: 1px solid #fc8181;
    font-size: 0.9em;
}
