:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --bg-color: #f9fafb;
    --chat-bg: #ffffff;
    --border-color: #e5e7eb;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --user-message-bg: #eef2ff;
    --assistant-message-bg: #ffffff;
    --internal-message-bg: #f3f4f6;
    --tool-block-bg: #fef3c7;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* Changed from hidden to allow scrolling */
}

#chatContainer {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    width: 100%;
    position: relative;
    min-height: 100vh;
    padding-top: calc(4rem + 20px);
    padding-bottom: calc(4rem + 30px);
}

.header {
    margin-bottom: 0;
    background: var(--chat-bg);
    border-radius: var(--radius-md);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    max-width: 1000px;
    width: calc(100% - 2rem);
    margin-top: 1rem;
    margin-left: auto;
    margin-right: auto;
}

/* This is for the backgroung for the top of the header */
.header::before {
    content: '';
    position: absolute;
    top: -1rem;
    left: 0;
    right: 0;
    height: 1rem;
    background: var(--bg-color);
    z-index: -1;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-icon {
    width: 1.5rem;
    height: 1.5rem;
    vertical-align: middle;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.modal-buttons,
.action-buttons {
    display: flex;
    gap: 0.5rem;
}

/* Add a visual separator between button groups */
.action-buttons {
    position: relative;
    padding-left: 1rem;
}

.action-buttons::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 70%;
    width: 1px;
    background-color: var(--border-color);
}

.icon-btn {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-color);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: var(--chat-bg);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Different hover states for different button types */
.modal-buttons .icon-btn:hover {
    background: var(--chat-bg);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.action-buttons .icon-btn:hover {
    background: var(--chat-bg);
    color: #ef4444; /* Red for destructive actions */
    border-color: #ef4444;
}

/* Special hover for clear button */
#clearBtn:hover {
    color: #ef4444;
    border-color: #ef4444;
}

/* Reconnect button states */
#reconnectMcpServerButton.connected {
    color: #10b981;
    border-color: #10b981;
}

#reconnectMcpServerButton.disconnected {
    color: #ef4444;
    border-color: #ef4444;
}

.info-panels {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.info-panel {
    background: var(--chat-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.info-panel summary {
    padding: 1rem;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background-color 0.2s ease;
}

.info-panel summary:hover {
    background: var(--bg-color);
}

.panel-content {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.panel-content ul {
    list-style: none;
    margin-top: 0.5rem;
}

.panel-content li {
    padding: 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
}

#chatLog {
    flex: 1;
    background: var(--chat-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-top: 1rem;
    box-shadow: var(--shadow-sm);
    width: 100%;
    position: relative;
    overflow-y: visible;
}

.message-row {
    margin: 0.75rem 0;
    display: flex;
    gap: 0.75rem;
}

.message-row.user-message {
    justify-content: flex-end;
}

.bubble {
    max-width: 85%;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    border-radius: var(--radius-lg);
    line-height: 1.5;
    animation: fadeIn 0.3s ease;
}

.bubble.user {
    background: var(--user-message-bg);
    border: 1px solid #e0e7ff;
    border-bottom-right-radius: var(--radius-sm);
}

.bubble.assistant {
    background: var(--assistant-message-bg);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: var(--radius-sm);
}

.bubble.internal {
    background: var(--internal-message-bg);
    font-size: 0.875rem;
    color: var(--text-secondary);
    max-width: 100%;
    text-align: center;
    padding: 0.5rem 1rem;
}

.tool-block {
    background: var(--chat-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0;
    margin: 0.75rem 0;
    font-size: 0.875rem;
    max-width: 100%;
    width: 100%;
    animation: slideIn 0.3s ease;
    overflow: hidden;
}

.tool-details {
    width: 100%;
}

.tool-details summary {
    list-style: none;
    cursor: pointer;
    padding: 0;
}

.tool-details summary::-webkit-details-marker {
    display: none;
}

.tool-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
}

.tool-icon {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
}

.tool-icon i {
    font-size: 1rem;
}

.tool-icon i.error {
    color: #ef4444;
}

.tool-icon i.success {
    color: #10b981;
}

.tool-info {
    flex: 1;
}

.tool-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.tool-id {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.tool-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    background: var(--bg-color);
}

.tool-status.error {
    color: #ef4444;
    background: #fee2e2;
}

.tool-status.success {
    color: #10b981;
    background: #d1fae5;
}

.tool-status i {
    transition: transform 0.2s ease;
}

.tool-content {
    padding: 1rem;
    background: var(--chat-bg);
}

.tool-label {
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tool-input,
.tool-result {
    background: var(--bg-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
}

.tool-result pre {
    margin: 0;
    background: transparent;
}

.tool-result-content .image-result {
    margin: 10px 0;
    padding: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #f9f9f9;
}

.tool-result-content .text-result {
    margin: 5px 0;
}

.tool-icon.success {
    color: #28a745;
}

.tool-icon.error {
    color: #dc3545;
}

.tool-result-content img {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.tool-result-content img:hover {
    cursor: pointer;
}

#inputRow {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-color);
    padding: 0 1rem 1rem 1rem;
    z-index: 10;
    width: 100%;
    display: flex;
    justify-content: center;
    margin: 0 auto;
}

.input-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    background: var(--chat-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 0.5rem;
    box-shadow: var(--shadow-sm);
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
}

#queryInput {
    flex: 1;
    padding: 0.75rem;
    font-size: 0.9375rem;
    min-height: 45px;
    height: auto;
    max-height: 150px;
    border: none;
    resize: none;
    overflow-y: auto;
    line-height: 1.5;
    border-radius: var(--radius-md);
    box-shadow: none;
}

#queryInput:focus {
    outline: none;
}

.send-btn {
    width: 45px;
    height: 45px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease, opacity 0.2s ease;
}

.send-btn:hover {
    background: var(--primary-hover);
}

.send-btn:disabled {
    background: var(--border-color);
    cursor: not-allowed;
    opacity: 0.7;
}

.send-btn:disabled:hover {
    background: var(--border-color);
}

.send-btn i {
    font-size: 1.2rem;
}

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

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

pre {
    background: var(--bg-color);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
}

code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
}

@media (max-width: 640px) {
    #chatContainer {
        margin: 0;
        padding: 0.5rem;
        padding-top: calc(4rem + 10px);
        padding-bottom: calc(3.5rem + 10px);
    }

    .bubble {
        max-width: 90%;
    }

    .bubble.user {
        max-width: 85%;
    }

    #inputRow {
        padding: 0 0.5rem 0.5rem 0.5rem;
    }

    .send-btn {
        width: 40px;
        height: 40px;
    }

    .tool-block {
        padding: 0.75rem;
    }

    .header {
        width: calc(100% - 1rem);
    }

    #chatLog {
        margin-left: 0.5rem;
        margin-right: 0.5rem;
    }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.modal-content {
    position: relative;
    background-color: var(--chat-bg);
    margin: 6% auto;
    padding: 1.25rem;
    width: clamp(300px, 80%, 1000px);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text-primary);
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    line-height: 1;
}

.close-modal:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1rem 0;
}

.modal-body ul li {
    list-style-type: none;
}

/* Header Actions */
.header-actions {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: #666;
    border-radius: 4px;
    transition: background-color 0.2s;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn i {
    font-size: 1.1rem;
}

.icon-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: #333;
}

/* Settings Form Styles */
.settings-form {
    width: 100%;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.8rem;
    font-size: 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: var(--chat-bg);
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

select.form-control {
    height: auto;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
    line-height: 1.5;
}

.form-text {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.btn {
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    font-size: 0.9rem;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-secondary {
    background-color: var(--chat-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: var(--bg-color);
    border-color: #d1d5db;
}

.notification {
    padding: 0.75rem 1rem;
    margin: 1rem 0 0;
    border-radius: var(--radius-sm);
    border-left-width: 4px;
    border-left-style: solid;
    font-size: 0.9rem;
}

.notification.success {
    background-color: #dcfce7;
    border-left-color: #22c55e;
    color: #166534;
}

.notification.error {
    background-color: #fee2e2;
    border-left-color: #ef4444;
    color: #991b1b;
}

/* Modal Styling - General */
.modal-body h4 {
    margin-bottom: 1rem;
    color: var(--primary-color);
    font-size: 1rem;
}

.modal-header h3 i {
    color: var(--primary-color);
    margin-right: 0.5rem;
}

/* Quick Start Modal Styling */
#quickStartModal .modal-body ul {
    padding-left: 0.5rem;
}

#quickStartModal .modal-body ul li {
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    background: var(--bg-color);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    border: 1px solid var(--border-color);
}

/* Make only the first list (example questions) clickable */
#quickStartModal .modal-body h4:first-of-type + ul li {
    cursor: pointer;
    transition: all 0.2s ease;
}

#quickStartModal .modal-body h4:first-of-type + ul li:hover {
    background: #f8f9ff;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

#quickStartModal .modal-body ul li i {
    color: var(--primary-color);
    margin-right: 0.75rem;
    font-size: 0.875rem;
}

#quickStartModal .modal-header h3 i {
    color: var(--primary-color);
    margin-right: 0.5rem;
}
