/* CSS Reset and Base Styles */

/* NHRL Color Scheme Variables */
:root {
    /* Primary NHRL Colors */
    --nhrl-primary: #291C5E;         /* Dark purple/blue - main brand color */
    --nhrl-background: #F4F4F4;      /* Light gray - primary background */
    --nhrl-accent: #666FE5;          /* Bright purple/blue - accent color */
    --nhrl-secondary: #C9CCF0;       /* Light purple - secondary backgrounds */
    
    /* Player Colors */
    --nhrl-player1: #CF23CA;         /* Pink - Player 1 */
    --nhrl-player2: #00DAD8;         /* Cyan - Player 2 */
    
    /* Derived Colors */
    --nhrl-text-primary: #291C5E;    /* Main text color using primary */
    --nhrl-text-secondary: #666;     /* Secondary text */
    --nhrl-border: #e5e5e5;          /* Border color */
    --nhrl-hover: rgba(102, 111, 229, 0.1); /* Hover state using accent */
    
    /* Status Colors */
    --status-ready: #10b981;         /* Green */
    --status-thinking: var(--nhrl-accent); /* Using accent color */
    --status-error: #dc2626;         /* Red */
    
    /* UI Element Colors */
    --button-primary: var(--nhrl-accent);
    --button-hover: #5560d6;         /* Darker shade of accent */
    --input-focus: var(--nhrl-accent);
    --input-focus-shadow: rgba(102, 111, 229, 0.2);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--nhrl-text-primary);
    background-color: var(--nhrl-background);
    overflow: hidden;
}

/* Main App Container */
.app-container {
    display: flex;
    height: 100vh;
    background: var(--nhrl-background);
    overflow: hidden;
    position: relative;
}

/* Chat Panel (Left - 450px) */
.chat-panel {
    width: 450px;
    min-width: 450px;
    display: flex;
    flex-direction: column;
    background: white;
    border-right: 1px solid var(--nhrl-border);
    box-shadow: 2px 0 10px rgba(41, 28, 94, 0.1);
    z-index: 10;
}

.chat-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--nhrl-border);
    background: var(--nhrl-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

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

.chat-header h1 {
    font-size: 24px;
    font-weight: 600;
    color: white;
}

.chat-header .subtitle {
    font-size: 0.8em;
    color: var(--nhrl-secondary);
    margin-left: 10px;
}

.sparky-logo {
    width: 40px;
    height: 40px;
    margin-right: 8px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--status-ready);
    animation: pulse 2s infinite;
}

.status-text {
    font-size: 14px;
    color: var(--nhrl-secondary);
    font-weight: 500;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #d1d5db #f3f4f6;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.message {
    padding: 16px 24px;
    border-bottom: 1px solid #f3f4f6;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.message-sender {
    font-weight: 600;
    font-size: 14px;
}

.user-message .message-sender {
    color: var(--nhrl-player1);
}

.assistant-message .message-sender {
    color: var(--nhrl-player2);
}

.message-time {
    font-size: 12px;
    color: #9ca3af;
}

.message-content {
    font-size: 14px;
    line-height: 1.5;
}

.message-content p {
    margin-bottom: 12px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul, .message-content ol {
    margin-left: 20px;
    margin-bottom: 12px;
}

.message-content li {
    margin-bottom: 4px;
}

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

.message-content pre {
    background: #f3f4f6;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
}

.user-message {
    background: #f8fafc;
}

.assistant-message {
    background: white;
}

.welcome-message {
    background: var(--nhrl-secondary);
    border-left: 4px solid var(--nhrl-accent);
}

.typing-indicator {
    padding: 16px 24px;
    background: white;
    border-bottom: 1px solid #f3f4f6;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9ca3af;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Chat Input Container */
.chat-input-container {
    padding: 16px 24px 24px;
    border-top: 1px solid var(--nhrl-border);
    background: #fff;
}

.chat-form {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--nhrl-background);
    border: 1px solid var(--nhrl-border);
    border-radius: 12px;
    padding: 8px;
    transition: border-color 0.2s ease;
}

.chat-form:focus-within {
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px var(--input-focus-shadow);
}

.message-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-size: 14px;
    line-height: 1.5;
    outline: none;
    font-family: inherit;
    padding: 4px 8px;
    min-height: 36px;
    max-height: 120px;
}

.message-input::placeholder {
    color: #9ca3af;
}

.message-input:disabled {
    color: #9ca3af;
    cursor: not-allowed;
}

.input-wrapper {
    position: relative;
    background: var(--nhrl-background);
    border: 1px solid var(--nhrl-border);
    border-radius: 12px;
    overflow: hidden;
    transition: border-color 0.2s ease;
}

.input-wrapper:focus-within {
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px var(--input-focus-shadow);
}

#message-input {
    width: 100%;
    padding: 12px 50px 12px 16px;
    border: none;
    background: transparent;
    resize: none;
    font-size: 14px;
    line-height: 1.5;
    outline: none;
    font-family: inherit;
}

#message-input::placeholder {
    color: #9ca3af;
}

#message-input:disabled {
    background: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
}

#message-input:disabled::placeholder {
    color: #d1d5db;
}

.input-wrapper:has(#message-input:disabled) {
    background: #f3f4f6;
    border-color: #e5e7eb;
    cursor: not-allowed;
}

.send-button {
    background: var(--button-primary);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}

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

.send-button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.input-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

.character-count {
    font-size: 12px;
    color: #9ca3af;
}

/* Artifact Panel (Right) */
.artifact-panel {
    flex: 1;
    background: var(--nhrl-background);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.artifact-panel.collapsed {
    display: none;
}

.artifact-panel.maximized {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    z-index: 1000;
    background: white;
}

.artifact-panel.maximized .artifact-header {
    background: var(--nhrl-primary);
    color: white;
}

.artifact-panel.maximized .artifact-header h2 {
    color: white;
}

.artifact-panel.maximized .icon-button {
    color: white;
    opacity: 0.8;
}

.artifact-panel.maximized .icon-button:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    opacity: 1;
}

.artifact-panel.maximized .context-indicator-artifact {
    background: rgba(255, 255, 255, 0.15);
}

.artifact-panel.maximized .context-text {
    color: white;
}

.artifact-panel.maximized .context-bar {
    background: rgba(255, 255, 255, 0.3);
}

.artifact-header {
    padding: 20px;
    border-bottom: 1px solid var(--nhrl-border);
    background: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.artifact-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--nhrl-primary);
    margin: 0;
    flex-shrink: 0;
}

.artifact-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.control-button {
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    color: #6b7280;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-button:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
    color: #374151;
}

/* Artifact Content */
.artifact-content {
    flex: 1;
    overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: #d1d5db #f3f4f6;
}

.artifact-content::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.artifact-content::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.artifact-content::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

.artifact-content::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.artifact-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 40px;
    color: #9ca3af;
}

.placeholder-icon {
    margin-bottom: 20px;
}

.artifact-placeholder h3 {
    font-size: 18px;
    font-weight: 600;
    color: #4b5563;
    margin: 0 0 8px 0;
}

.artifact-placeholder p {
    font-size: 14px;
    margin: 0;
    color: #9ca3af;
}

/* Artifact Items */
.artifact-item {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin: 16px 16px 0 16px;
    overflow: hidden;
}

.artifact-item:last-child {
    margin-bottom: 16px;
}

/* Artifact header styles moved to JavaScript for dynamic functionality */
.artifact-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

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

.artifact-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.artifact-title {
    font-weight: 600;
    font-size: 16px;
    color: #1a1a1a;
}

.artifact-type {
    background: var(--nhrl-secondary);
    color: var(--nhrl-primary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

.artifact-permalink-btn {
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    color: #6b7280;
    padding: 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.artifact-permalink-btn:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
    color: #374151;
}

.artifact-collapse-btn {
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    color: #6b7280;
    padding: 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.artifact-collapse-btn:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
    color: #374151;
}

.artifact-building {
    background: #fef3c7;
    color: #92400e;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    animation: pulse 1.5s infinite;
}

/* Collapsible artifact states */
.artifact-item.collapsed .artifact-item-content {
    display: none;
}

.artifact-item.expanded .artifact-item-content {
    display: block;
}

.artifact-item.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.artifact-item.expanded .collapse-icon {
    transform: rotate(0deg);
}

.artifact-item-content {
    position: relative;
}

/* HTML Artifacts */
.artifact-html {
    width: 100%;
    height: 600px;
    border: none;
    background: white;
    border-radius: 4px;
}

.artifact-html-loading {
    width: 100%;
    height: 600px;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    background: #f9fafb;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #6b7280;
}

.artifact-html-loading .loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

.artifact-html-error {
    width: 100%;
    height: 600px;
    border: 1px solid #fecaca;
    border-radius: 4px;
    background: #fef2f2;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #b91c1c;
    padding: 20px;
    text-align: center;
}

.artifact-html-error .error-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.artifact-html-error .retry-button {
    background: #dc2626;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 12px;
    font-size: 14px;
}

.artifact-html-error .retry-button:hover {
    background: #b91c1c;
}

/* Code Artifacts */
.artifact-code {
    background: var(--nhrl-primary);
    color: var(--nhrl-secondary);
    padding: 20px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre-wrap;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(41, 28, 94, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--nhrl-secondary);
    border-top: 4px solid var(--nhrl-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .chat-panel {
        width: 100%;
        min-width: auto;
        height: 60vh;
        border-right: none;
        border-bottom: 1px solid #e5e5e5;
    }
    
    .artifact-panel {
        height: 40vh;
    }
}

@media (max-width: 480px) {
    .chat-header, .artifact-header {
        padding: 16px 20px;
    }
    
    .chat-header h1 {
        font-size: 20px;
    }
    
    .artifact-header h2 {
        font-size: 18px;
    }
    
    .message {
        padding: 12px 20px;
    }
    
    .chat-input-container {
        padding: 16px 20px;
    }
}

/* API Key Button */
.api-key-button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--nhrl-secondary);
    border: 1px solid var(--nhrl-accent);
    border-radius: 6px;
    color: var(--nhrl-primary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.api-key-button:hover {
    background: var(--nhrl-accent);
    color: white;
}

.api-key-button.has-key {
    background: #dcfce7;
    border-color: #bbf7d0;
    color: #166534;
}

.api-key-button.has-key:hover {
    background: #bbf7d0;
    border-color: #86efac;
}

.api-key-button:not(.has-key) {
    animation: api-key-pulse 2s infinite;
    border-color: #f59e0b;
}

@keyframes api-key-pulse {
    0%, 100% { 
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
    }
    50% { 
        box-shadow: 0 0 0 6px rgba(245, 158, 11, 0);
    }
}

.api-key-status {
    font-size: 11px;
}

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

.modal-overlay.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e5e5;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
}

.modal-close {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #f3f4f6;
    color: #374151;
}

.modal-body {
    padding: 24px;
}

.modal-body p {
    margin-bottom: 16px;
    color: #6b7280;
    line-height: 1.5;
}

.input-group {
    position: relative;
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #374151;
    font-size: 14px;
}

.input-group input {
    width: 100%;
    padding: 12px 40px 12px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.input-group input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.toggle-visibility {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: color 0.2s ease;
    margin-top: 13px;
}

.toggle-visibility:hover {
    color: #374151;
}

.modal-info {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    padding: 12px;
}

.modal-info p {
    margin: 0;
    font-size: 13px;
    color: #0369a1;
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid #e5e5e5;
    background: #f9fafb;
}

.btn-primary {
    background: var(--button-primary);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

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

.btn-secondary {
    background: var(--nhrl-player1);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-secondary:hover {
    background: #b91dba;
}

.btn-cancel {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: auto;
}

.btn-cancel:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

/* Tool Use Display Blocks - Claude Style */
.tool-use-block {
    background: var(--nhrl-background);
    border: 1px solid var(--nhrl-border);
    border-radius: 8px;
    margin: 12px 0;
    overflow: hidden;
    font-size: 14px;
}

.tool-use-header {
    background: var(--nhrl-secondary);
    color: var(--nhrl-primary);
    padding: 12px 16px;
    font-weight: 500;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--nhrl-border);
    transition: background-color 0.2s ease;
}

.tool-use-header:hover {
    background: var(--nhrl-accent);
    color: white;
}

.tool-label {
    color: #6b7280;
    font-weight: 500;
}

.expand-caret {
    color: #9ca3af;
    transition: transform 0.2s ease;
}

.tool-use-block.expanded .expand-caret {
    transform: rotate(180deg);
}

.tool-use-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: white;
}

.tool-use-block.expanded .tool-use-content {
    max-height: 600px;
    overflow-y: auto;
}

.tool-details {
    padding: 16px;
}

.tool-name-section,
.tool-input-section,
.tool-output-section {
    margin-bottom: 16px;
}

.tool-name-section:last-child,
.tool-input-section:last-child,
.tool-output-section:last-child {
    margin-bottom: 0;
}

.tool-details strong {
    color: #374151;
    font-weight: 600;
    display: block;
    margin-bottom: 8px;
}

.tool-data {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 12px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.4;
    color: #1f2937;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-x: auto;
    max-height: 200px;
    overflow-y: auto;
}

.tool-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-left: 4px solid #dc2626;
    border-radius: 8px;
    margin: 12px 0;
    padding: 12px;
    color: #dc2626;
}

.tool-error .error-icon {
    display: inline-block;
    margin-right: 8px;
    font-size: 16px;
}

/* Status indicator updates for MCP */
.status-dot.status-mcp {
    background-color: var(--nhrl-player2);
    animation: pulse 2s infinite;
}

.status-dot.status-mcp-error {
    background-color: var(--status-error);
    animation: pulse 2s infinite;
}

/* Version display */
.version-display {
    position: fixed;
    bottom: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.1);
    color: #6b7280;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Consolas', monospace;
    z-index: 100;
    backdrop-filter: blur(4px);
    transition: all 0.2s ease;
    user-select: none;
    pointer-events: none;
}

.version-display:hover {
    background: rgba(0, 0, 0, 0.15);
    color: #374151;
}

/* HTML Source View (while building) */
.artifact-source-view {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    background: #f9fafb;
}

.source-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f3f4f6;
    border-bottom: 1px solid #e5e7eb;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

.source-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.source-progress {
    display: flex;
    align-items: center;
}

.progress-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.artifact-html-source {
    background: var(--nhrl-primary);
    color: var(--nhrl-secondary);
    padding: 16px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.4;
    overflow-x: auto;
    white-space: pre-wrap;
    margin: 0;
    max-height: 400px;
    overflow-y: auto;
}

.artifact-html-source code {
    background: none;
    padding: 0;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

/* Artifact Error Messages */
.artifact-save-error {
    border-left: 4px solid #f59e0b;
    background: #fffbeb;
    margin: 12px 0;
}

.artifact-save-error .error-icon {
    color: #f59e0b;
    font-size: 24px;
}

.artifact-save-error .error-content {
    color: #92400e;
}

.artifact-save-error .error-content strong {
    color: #78350f;
}

.artifact-processing-error {
    border-left: 4px solid #ef4444;
    background: #fef2f2;
    margin: 12px 0;
}

.artifact-processing-error .error-icon {
    color: #ef4444;
    font-size: 24px;
}

.artifact-processing-error .error-content {
    color: #b91c1c;
}

.artifact-processing-error .error-content strong {
    color: #991b1b;
}

/* HAML Artifact Error Display */
.artifact-error {
    border: 1px solid #fecaca;
    border-left: 4px solid #dc2626;
    background: #fef2f2;
    border-radius: 8px;
    padding: 16px;
    margin: 12px 0;
}

.artifact-error .error-icon {
    font-size: 24px;
    color: #dc2626;
    margin-bottom: 8px;
    display: block;
}

.artifact-error .error-message {
    color: #b91c1c;
    margin-bottom: 12px;
}

.artifact-error .error-message strong {
    color: #991b1b;
    font-weight: 600;
}

.error-details {
    margin-top: 12px;
}

.error-details summary {
    cursor: pointer;
    font-weight: 500;
    color: #dc2626;
    padding: 8px 0;
    outline: none;
    user-select: none;
}

.error-details summary:hover {
    color: #b91c1c;
}

.artifact-source-error {
    background: var(--nhrl-primary);
    color: var(--nhrl-secondary);
    padding: 12px;
    border-radius: 6px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
    line-height: 1.4;
    overflow-x: auto;
    white-space: pre-wrap;
    margin: 8px 0 0 0;
    max-height: 300px;
    overflow-y: auto;
}

.artifact-source-error code {
    background: none;
    padding: 0;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

/* Context Window Indicator */
.context-indicator {
    position: absolute;
    right: 150px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    transition: all 0.3s ease;
}

/* Context indicator in artifact panel */
.context-indicator-artifact {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 16px;
    transition: all 0.3s ease;
    flex: 1;
    margin: 0 10px;
    min-width: 0;
}

.context-bar {
    width: 100px;
    height: 6px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
    overflow: hidden;
    flex-shrink: 0;
}

.context-fill {
    height: 100%;
    background: #4ade80;
    transition: width 0.5s ease, background 0.3s ease;
}

.context-text {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #374151;
}

.context-percentage {
    font-weight: 600;
    min-width: 35px;
    text-align: right;
}

.context-label {
    opacity: 0.8;
}

/* Context status states */
.context-normal .context-fill {
    background: #4ade80;
}

.context-caution .context-fill {
    background: #fbbf24;
}

.context-warning .context-fill {
    background: #fb923c;
}

.context-critical .context-fill {
    background: #ef4444;
}

.context-caution {
    background: rgba(251, 191, 36, 0.1);
}

.context-warning {
    background: rgba(251, 146, 60, 0.1);
    animation: contextPulse 2s infinite;
}

.context-critical {
    background: rgba(239, 68, 68, 0.1);
    animation: contextPulse 1s infinite;
}

@keyframes contextPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Context management messages */
.context-message {
    background: #f3f4f6;
    border-left: 4px solid #3b82f6;
    margin: 10px 0;
}

.context-notice {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: #1f2937;
    font-size: 14px;
}

.context-message.context-warning .context-notice {
    border-left-color: #fb923c;
    background: rgba(251, 146, 60, 0.1);
}

.context-message.context-critical .context-notice {
    border-left-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

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

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #111827;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #f3f4f6;
    color: #111827;
}

.modal-body {
    padding: 24px;
}

.context-modal-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-item {
    text-align: center;
    padding: 16px;
    background: #f9fafb;
    border-radius: 8px;
}

.stat-label {
    font-size: 12px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 24px;
    font-weight: 600;
    color: #111827;
}

.stat-value.normal {
    color: #10b981;
}

.stat-value.caution {
    color: #f59e0b;
}

.stat-value.warning {
    color: #f97316;
}

.stat-value.critical {
    color: #ef4444;
}

.context-modal-bar {
    width: 100%;
    height: 12px;
    background: #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 24px;
}

.context-modal-fill {
    height: 100%;
    transition: width 0.5s ease;
}

.context-modal-fill.normal {
    background: #10b981;
}

.context-modal-fill.caution {
    background: #f59e0b;
}

.context-modal-fill.warning {
    background: #f97316;
}

.context-modal-fill.critical {
    background: #ef4444;
}

.context-modal-info {
    margin-bottom: 24px;
}

.context-modal-info p {
    margin: 0;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 14px;
}

.context-modal-info p.success {
    background: #d1fae5;
    color: #065f46;
}

.context-modal-info p.info {
    background: #dbeafe;
    color: #1e40af;
}

.context-modal-info p.caution {
    background: #fef3c7;
    color: #92400e;
}

.context-modal-info p.warning {
    background: #fee2e2;
    color: #991b1b;
}

.context-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: #2563eb;
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
}

.btn-secondary:hover {
    background: #e5e7eb;
}

.system-notice {
    padding: 8px 12px;
    background: #f3f4f6;
    border-radius: 6px;
    color: #4b5563;
    font-size: 14px;
}

.icon-button {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #6b7280;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-button:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--nhrl-primary);
} 