/* Moltonhim Chat Interface */

:root {
    --bg-color: #1a1a2e;
    --surface-color: #16213e;
    --primary-color: #0f3460;
    --accent-color: #e94560;
    --text-color: #eee;
    --text-muted: #888;
    --border-color: #333;
    --code-bg: #0d1117;
    --success-color: #4caf50;
    --error-color: #f44336;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

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

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--accent-color);
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.clock {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
}

#clockTime {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-color);
    letter-spacing: 1px;
}

.clock-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
    letter-spacing: 0.5px;
}

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

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background-color: #d63850;
}

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

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

.btn-secondary:hover {
    background-color: #1a4a7a;
}

/* Main content */
main {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Chat container */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Welcome message */
.welcome-message {
    background-color: var(--surface-color);
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    max-width: 500px;
    margin: 2rem auto;
}

.welcome-message h2 {
    margin-bottom: 1rem;
    color: var(--accent-color);
}

.welcome-message ul {
    list-style: none;
    margin: 1rem 0;
}

.welcome-message li {
    padding: 0.25rem 0;
    color: var(--text-muted);
}

/* Messages */
.message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    padding: 1rem;
    border-radius: 12px;
    animation: fadeIn 0.2s ease;
}

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

.message.user {
    align-self: flex-end;
    background-color: var(--primary-color);
}

.message.assistant {
    align-self: flex-start;
    background-color: var(--surface-color);
}

.message-header {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.message-content {
    line-height: 1.6;
    word-wrap: break-word;
}

.message-content p {
    margin-bottom: 0.5rem;
}

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

/* Code blocks */
.message-content pre {
    background-color: var(--code-bg);
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0.5rem 0;
}

.message-content code {
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 0.875rem;
}

.message-content :not(pre) > code {
    background-color: var(--code-bg);
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
}

/* Tool use indicator */
.tool-use {
    background-color: var(--code-bg);
    border-left: 3px solid var(--accent-color);
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    border-radius: 0 6px 6px 0;
    font-size: 0.875rem;
}

.tool-use .tool-name {
    color: var(--accent-color);
    font-weight: 600;
}

.tool-use .tool-command {
    color: var(--text-muted);
    font-family: monospace;
    margin-top: 0.25rem;
}

.tool-result {
    background-color: var(--code-bg);
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    border-radius: 6px;
    font-size: 0.8rem;
    max-height: 200px;
    overflow-y: auto;
    color: var(--text-muted);
    font-family: monospace;
    white-space: pre-wrap;
}

/* Thinking/streaming indicator */
.thinking {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

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

.thinking-dots span {
    width: 6px;
    height: 6px;
    background-color: var(--accent-color);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.thinking-dots span:nth-child(1) { animation-delay: -0.32s; }
.thinking-dots span:nth-child(2) { animation-delay: -0.16s; }

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

/* Footer / Input */
footer {
    padding: 1rem 0;
    border-top: 1px solid var(--border-color);
}

.chat-form {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

#messageInput {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background-color: var(--surface-color);
    color: var(--text-color);
    font-size: 1rem;
    resize: none;
    min-height: 44px;
    max-height: 200px;
    font-family: inherit;
}

#messageInput:focus {
    outline: none;
    border-color: var(--accent-color);
}

#messageInput::placeholder {
    color: var(--text-muted);
}

.status {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    text-align: center;
}

.status.connected {
    color: var(--success-color);
}

.status.error {
    color: var(--error-color);
}

/* Sessions panel */
.sessions-panel {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.sessions-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.session-item {
    padding: 1rem;
    background-color: var(--surface-color);
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.session-item:hover {
    background-color: var(--primary-color);
}

.session-item .session-id {
    font-family: monospace;
    font-size: 0.875rem;
    color: var(--accent-color);
}

.session-item .session-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

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

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: var(--surface-color);
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.modal-header h2 {
    font-size: 1.25rem;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
}

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

/* Utility classes */
.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0.5rem;
    }

    header h1 {
        font-size: 1.25rem;
    }

    .header-center .clock {
        display: none; /* Hide clock on mobile to save space */
    }

    .message {
        max-width: 95%;
    }

    .welcome-message {
        padding: 1.5rem;
        margin: 1rem auto;
    }
}
