* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    height: 100vh;
    overflow: hidden;
    background-color: #f5f5f5;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 100%;
    margin: 0 auto;
    background-color: #ffffff;
    position: relative;
}

.new-chat-button {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
    z-index: 100;
}

.new-chat-button:hover:not(:disabled) {
    background-color: #0056b3;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.4);
    transform: scale(1.05);
}

.new-chat-button:active:not(:disabled) {
    background-color: #004085;
    transform: scale(0.95);
}

.new-chat-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
}

.new-chat-button svg {
    width: 20px;
    height: 20px;
    stroke: white;
}

/* Tooltip on hover */
.new-chat-button::after {
    content: attr(title);
    position: absolute;
    right: 50px;
    top: 50%;
    transform: translateY(-50%);
    background-color: #333;
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.new-chat-button:hover::after {
    opacity: 1;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: #fafafa;
}

.message {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
}

.message-header {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
    font-size: 12px;
    color: #666;
}

.message-sender {
    font-weight: 600;
    margin-right: 10px;
}

.message-time {
    color: #999;
}

.message-content {
    padding: 12px 16px;
    border-radius: 8px;
    max-width: 80%;
    word-wrap: break-word;
    line-height: 1.5;
}

.message.user .message-content {
    background-color: #007bff;
    color: white;
    align-self: flex-end;
    margin-left: auto;
}

.message.ai .message-content {
    background-color: #e9ecef;
    color: #212529;
    align-self: flex-start;
}

.message.system .message-content {
    background-color: #fff3cd;
    color: #856404;
    align-self: center;
    max-width: 90%;
    text-align: center;
}

.message.error .message-content {
    background-color: #f8d7da;
    color: #721c24;
    align-self: center;
    max-width: 90%;
}

/* Markdown Headings - Improved styling */
.message-content h1, .message-content h2, .message-content h3,
.message-content h4, .message-content h5, .message-content h6,
.message-content .markdown-heading {
    margin-top: 20px;
    margin-bottom: 12px;
    font-weight: 600;
    line-height: 1.3;
    color: #212529;
}

.message-content h1, .message-content .markdown-h1 { 
    font-size: 24px; 
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 8px;
}

.message-content h2, .message-content .markdown-h2 { 
    font-size: 20px; 
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 6px;
}

.message-content h3, .message-content .markdown-h3 { 
    font-size: 18px; 
    color: #495057;
    margin-top: 18px;
}

.message-content h4, .message-content .markdown-h4 { 
    font-size: 16px; 
    color: #6c757d;
}

.message-content h5, .message-content .markdown-h5 { 
    font-size: 14px; 
    color: #6c757d;
}

.message-content h6, .message-content .markdown-h6 { 
    font-size: 13px; 
    color: #6c757d;
}

/* Markdown Paragraphs - Better spacing */
.message-content p, .message-content .markdown-paragraph {
    margin-bottom: 14px;
    line-height: 1.6;
    color: #212529;
}

.message-content p:first-child, .message-content .markdown-paragraph:first-child {
    margin-top: 0;
}

.message-content p:last-child, .message-content .markdown-paragraph:last-child {
    margin-bottom: 0;
}

/* Markdown Lists - Improved styling */
.message-content ul, .message-content ol,
.message-content .markdown-list {
    margin-left: 24px;
    margin-bottom: 16px;
    margin-top: 8px;
    padding-left: 8px;
}

.message-content ul, .message-content .markdown-list {
    list-style-type: disc;
}

.message-content ol, .message-content .markdown-list[type="1"] {
    list-style-type: decimal;
}

.message-content li, .message-content .markdown-list-item {
    margin-bottom: 8px;
    line-height: 1.6;
    padding-left: 4px;
}

.message-content li p, .message-content .markdown-list-item p {
    margin-bottom: 6px;
    margin-top: 4px;
}

/* Nested lists */
.message-content li ul, .message-content li ol,
.message-content .markdown-list-item .markdown-list {
    margin-top: 6px;
    margin-bottom: 6px;
}

/* Strong/Bold text */
.message-content strong, .message-content .markdown-strong {
    font-weight: 700;
    color: #212529;
}

/* Code blocks and inline code */
.message-content code {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    color: #d63384;
}

.message-content pre code {
    color: #212529;
}

.message-content pre {
    background-color: #f4f4f4;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 12px;
    overflow-x: auto;
    margin: 12px 0;
}

.message-content pre code {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    font-size: 0.85em;
}

.message-content blockquote {
    border-left: 4px solid #007bff;
    padding-left: 16px;
    margin: 12px 0;
    color: #666;
    font-style: italic;
}

.message-content a {
    color: #007bff;
    text-decoration: none;
}

.message-content a:hover {
    text-decoration: underline;
}

.message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
}

.message-content table th,
.message-content table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

.message-content table th {
    background-color: #f8f9fa;
    font-weight: 600;
}

.message-content hr {
    border: none;
    border-top: 1px solid #ddd;
    margin: 20px 0;
}

/* Better spacing for markdown content overall */
.message.ai .message-content {
    line-height: 1.6;
}

/* Ensure proper spacing between markdown elements */
.message-content > *:first-child {
    margin-top: 0;
}

.message-content > *:last-child {
    margin-bottom: 0;
}

.input-container {
    display: flex;
    padding: 12px;
    background-color: #ffffff;
    border-top: 1px solid #e0e0e0;
    align-items: flex-end;
    gap: 8px;
}

.message-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-family: inherit;
    font-size: 14px;
    resize: none;
    max-height: 150px;
    min-height: 40px;
    line-height: 1.5;
    outline: none;
}

.message-input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.message-input:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
}

.send-button {
    padding: 10px 24px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    min-width: 80px;
}

.send-button:hover:not(:disabled) {
    background-color: #0056b3;
}

.send-button:active:not(:disabled) {
    background-color: #004085;
}

.send-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.loading-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #666;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Scrollbar styling */
.messages-container::-webkit-scrollbar {
    width: 8px;
}

.messages-container::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.messages-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Configuration Form Styles */
.config-form-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.config-form-container {
    background-color: white;
    border-radius: 8px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.config-form-container h2 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #333;
}

.config-form-description {
    color: #666;
    margin-bottom: 20px;
    font-size: 14px;
}

.config-form-note {
    background-color: #e7f3ff;
    border-left: 4px solid #007bff;
    padding: 10px;
    margin-bottom: 20px;
    font-size: 13px;
    color: #333;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
}

.form-group input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.form-actions {
    margin-top: 20px;
    text-align: right;
}

.btn-primary {
    padding: 10px 24px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background-color: #0056b3;
}

.btn-primary:active {
    background-color: #004085;
}
