/* ============================================================================
   AI Chat - Modern Dark Theme
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
    /* Color Palette - Deep Space Theme */
    --bg-primary: #0a0e14;
    --bg-secondary: #0f1419;
    --bg-tertiary: #1a1f26;
    --bg-message-user: #1e3a5f;
    --bg-message-assistant: #1a2332;
    
    --text-primary: #e6e6e6;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    
    --accent-primary: #00d9ff;
    --accent-secondary: #7c3aed;
    --accent-gradient: linear-gradient(135deg, #00d9ff 0%, #7c3aed 100%);
    
    --border-color: #21262d;
    --border-active: #00d9ff;
    
    --success: #2ea043;
    --error: #f85149;
    --warning: #d29922;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(0, 217, 255, 0.3);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

/* ============================================================================
   Chat Container
   ============================================================================ */

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 900px;
    margin: 0 auto;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
}

/* ============================================================================
   Header
   ============================================================================ */

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.back-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 20px;
    transition: all var(--transition-fast);
}

.back-link:hover {
    background: var(--bg-primary);
    color: var(--accent-primary);
    transform: translateX(-2px);
}

.header-title h1 {
    font-size: 1.5rem;
    font-weight: 600;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.connection-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.connection-dot.connected {
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
}

.connection-dot.connecting {
    background: var(--warning);
    animation: pulse 1.5s infinite;
}

.connection-dot.disconnected {
    background: var(--error);
}

.remote-badge {
    font-size: 0.7em;
    opacity: 0.7;
    margin-left: 4px;
}

.header-right {
    display: flex;
    gap: 8px;
}

.header-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 18px;
    transition: all var(--transition-fast);
}

.header-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.session-btn {
    width: auto;
    padding: 0 10px;
    gap: 4px;
    font-size: 12px;
}

.session-label {
    color: var(--text-muted);
    font-size: 11px;
}

.session-id-code {
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent-primary);
    font-size: 12px;
}

/* ============================================================================
   Messages Area
   ============================================================================ */

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Welcome Message */
.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex: 1;
    padding: 40px;
    animation: fadeIn var(--transition-slow) ease;
}

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

.welcome-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.welcome-message h2 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 12px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-message p {
    color: var(--text-secondary);
    font-size: 1rem;
    max-width: 400px;
}

/* Message Bubbles */
.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: messageSlideIn var(--transition-normal) ease;
}

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

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

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

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--accent-gradient);
}

.message.assistant .message-avatar {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
}

.message-bubble {
    display: flex;
    flex-direction: column;
    max-width: 100%;
    min-width: 0;
}

.message-content {
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-size: 0.95rem;
    line-height: 1.6;
    position: relative;
}

.message.user .message-content {
    background: var(--bg-message-user);
    border-bottom-right-radius: var(--radius-sm);
}

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

.message-content code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9em;
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}

.message-content pre {
    background: var(--bg-primary);
    padding: 12px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 8px 0;
}

.message-content pre code {
    background: transparent;
    padding: 0;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-8px); }
}

/* ============================================================================
   Input Area
   ============================================================================ */

.chat-input-area {
    padding: 16px 24px 24px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 8px 12px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.message-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
    resize: none;
    max-height: 150px;
    padding: 8px 4px;
}

.message-input::placeholder {
    color: var(--text-muted);
}

.input-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 1.2rem;
    transition: all var(--transition-fast);
}

.mic-btn {
    background: transparent;
    color: var(--text-secondary);
}

.mic-btn:hover {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
}

.mic-btn.recording {
    background: var(--error);
    color: white;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.send-btn {
    background: var(--accent-gradient);
    color: white;
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

.send-btn:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* Recording Indicator */
.recording-indicator,
.transcribing-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    padding: 12px 16px;
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid var(--error);
    border-radius: var(--radius-md);
    color: var(--error);
}

.recording-indicator.hidden,
.transcribing-indicator.hidden {
    display: none;
}

.recording-pulse {
    width: 12px;
    height: 12px;
    background: var(--error);
    border-radius: 50%;
    animation: recordingPulse 1.5s infinite;
}

@keyframes recordingPulse {
    0%, 100% { 
        opacity: 1; 
        transform: scale(1);
    }
    50% { 
        opacity: 0.5; 
        transform: scale(1.2);
    }
}

.recording-text,
.transcribing-text {
    flex: 1;
    font-weight: 500;
}

.stop-recording-btn {
    background: var(--error);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.stop-recording-btn:hover {
    background: #d73a30;
    transform: scale(1.02);
}

.transcribing-indicator {
    background: rgba(0, 217, 255, 0.1);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.transcribing-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--accent-primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Auto-send toggle */
.input-settings {
    display: flex;
    justify-content: flex-end;
    padding: 8px 4px 0;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-muted);
    user-select: none;
    transition: color var(--transition-fast);
}

.toggle-label:hover {
    color: var(--text-secondary);
}

.toggle-label input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 36px;
    height: 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    position: relative;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.toggle-label input[type="checkbox"]::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all var(--transition-fast);
}

.toggle-label input[type="checkbox"]:checked {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.toggle-label input[type="checkbox"]:checked::before {
    left: 18px;
    background: white;
}

.toggle-text {
    font-weight: 500;
}

/* Error message in chat */
.message.error .message-content {
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid var(--error);
    color: var(--error);
}

/* ============================================================================
   Tool Message Display
   ============================================================================ */

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

.message.tool .message-avatar {
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
}

.message.tool.error .message-avatar {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.tool-message {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    border-bottom-left-radius: var(--radius-sm);
    overflow: hidden;
    min-width: 280px;
    max-width: 100%;
}

.message.tool.success .tool-message {
    border-left: 3px solid var(--success);
}

.message.tool.error .tool-message {
    border-left: 3px solid var(--error);
}

.tool-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background var(--transition-fast);
    user-select: none;
}

.tool-header:hover {
    background: var(--bg-secondary);
}

.tool-status {
    font-size: 1rem;
}

.tool-name {
    flex: 1;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--accent-primary);
}

.tool-toggle {
    color: var(--text-muted);
    font-size: 0.8rem;
    transition: transform var(--transition-fast);
}

.tool-body {
    border-top: 1px solid var(--border-color);
    padding: 16px;
    background: var(--bg-primary);
}

.tool-body.hidden {
    display: none;
}

.tool-section {
    margin-bottom: 14px;
}

.tool-section:last-child {
    margin-bottom: 0;
}

.tool-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tool-code {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    margin: 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--text-primary);
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 250px;
    overflow-y: auto;
    line-height: 1.5;
}

.tool-code.error-text {
    color: var(--error);
    background: rgba(248, 81, 73, 0.1);
    border-color: var(--error);
}

/* Tool loading state */
.message.tool.loading .tool-message {
    border-left: 3px solid var(--accent-primary);
}

.message.tool.loading .message-avatar {
    background: linear-gradient(135deg, var(--accent-primary) 0%, #3b82f6 100%);
    animation: pulse 1.5s infinite;
}

.tool-loading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    color: var(--accent-primary);
    font-weight: 500;
}

.tool-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.tool-message .message-time {
    padding: 8px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

/* ============================================================================
   Tool Result Display
   ============================================================================ */

.tool-result-container {
    margin-top: 8px;
}

.tool-result-empty {
    color: var(--text-muted);
    font-style: italic;
}

.tool-result-text {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    margin: 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 300px;
    overflow-y: auto;
}

.tool-result-json {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    margin: 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 200px;
    overflow-y: auto;
}

.tool-result-query {
    background: var(--bg-message-user);
    padding: 8px 12px;
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.tool-result-query strong {
    color: var(--text-primary);
}

.tool-result-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tool-result-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    transition: border-color var(--transition-fast);
}

.tool-result-item:hover {
    border-color: var(--accent-primary);
}

.tool-result-item-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--accent-primary);
    margin-bottom: 6px;
    word-break: break-word;
}

.tool-result-item-fields {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tool-result-field {
    font-size: 0.8rem;
    line-height: 1.4;
    word-break: break-word;
}

.tool-result-field .field-key {
    color: var(--text-muted);
}

.tool-result-field .field-value {
    color: var(--text-secondary);
}

.tool-result-more {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 8px;
    font-style: italic;
}

.tool-result-value {
    font-family: 'JetBrains Mono', monospace;
    color: var(--success);
}

/* ============================================================================
   Responsive Design
   ============================================================================ */

@media (max-width: 768px) {
    .chat-container {
        border: none;
    }
    
    .chat-header {
        padding: 12px 16px;
    }
    
    .header-title h1 {
        font-size: 1.2rem;
    }
    
    .chat-messages {
        padding: 16px;
    }
    
    .message {
        max-width: 90%;
    }
    
    .chat-input-area {
        padding: 12px 16px 16px;
    }
    
    .message-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* ============================================================================
   Loading State
   ============================================================================ */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 14, 20, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.loading-overlay.hidden {
    display: none;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ============================================================================
   Modal
   ============================================================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn var(--transition-fast) ease;
}

.modal.hidden {
    display: none;
}

.modal-wide .modal-content {
    max-width: 560px;
}

/* Events (debug) modal */
.events-section {
    margin-bottom: 24px;
}

.events-section:last-child {
    margin-bottom: 0;
}

.events-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.create-event-form .form-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.create-event-form label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.create-event-form input,
.create-event-form select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.create-event-form input[type="datetime-local"] {
    font-family: inherit;
}

.events-session-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.events-session-hint code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
}

.events-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 280px;
    overflow-y: auto;
}

.event-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
}

.event-type {
    flex-shrink: 0;
    color: var(--accent-primary);
}

.event-time {
    flex-shrink: 0;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.event-preview {
    flex: 1;
    min-width: 0;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hidden {
    display: none !important;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn var(--transition-normal) ease;
}

@keyframes modalSlideIn {
    from { 
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--error);
    border-color: var(--error);
    color: white;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* ============================================================================
   MCP Sections
   ============================================================================ */

.mcp-section {
    margin-bottom: 24px;
}

.mcp-section:last-child {
    margin-bottom: 0;
}

.mcp-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge {
    background: var(--accent-primary);
    color: var(--bg-primary);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

/* Add Server Form */
.add-server-form .form-row {
    display: flex;
    gap: 8px;
}

.add-server-form input {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
}

.add-server-form input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(0, 217, 255, 0.2);
}

.add-server-form input::placeholder {
    color: var(--text-muted);
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    min-width: 44px;
}

.btn-primary:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

.btn-danger {
    background: transparent;
    border: 1px solid var(--error);
    color: var(--error);
}

.btn-danger:hover {
    background: var(--error);
    color: white;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* Servers List */
.servers-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.server-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.server-item:hover {
    border-color: var(--accent-primary);
}

.server-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.server-status.connected {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.server-status.disconnected {
    background: var(--error);
}

.server-info {
    flex: 1;
    min-width: 0;
}

.server-name {
    font-weight: 500;
    color: var(--text-primary);
}

.server-url {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.server-tools-count {
    font-size: 0.75rem;
    color: var(--accent-primary);
}

.server-actions {
    display: flex;
    gap: 6px;
}

/* Tools List */
.tools-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 250px;
    overflow-y: auto;
}

.tool-item {
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.tool-item:hover {
    border-color: var(--accent-primary);
}

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

.tool-name {
    font-weight: 500;
    color: var(--accent-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
}

.tool-server {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-primary);
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.tool-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.tool-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
}

.tool-checkbox-label .tool-enable-cb {
    margin-top: 4px;
    flex-shrink: 0;
}

.tool-item.tool-disabled {
    opacity: 0.65;
}

.tool-item.tool-disabled .tool-name {
    color: var(--text-muted);
}

/* Prompt preview modal */
.prompt-preview-hint {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.prompt-preview-content {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 70vh;
    overflow: auto;
    padding: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
}

/* Placeholders */
.loading-placeholder,
.empty-placeholder {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Tools hint in welcome */
.tools-hint {
    margin-top: 16px;
    font-size: 0.85rem;
    color: var(--accent-primary);
    opacity: 0.8;
}

/* ============================================================================
   Responsive Modal
   ============================================================================ */

@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .modal-header {
        padding: 16px;
    }
    
    .modal-body {
        padding: 16px;
    }
    
    .add-server-form .form-row {
        flex-direction: column;
    }
    
    .add-server-form input {
        width: 100%;
    }
}
