/* BarnacleBoy Chat - Minimal Dark Theme */

:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #141414;
    --bg-tertiary: #1a1a1a;
    --text-primary: #e0e0e0;
    --text-secondary: #888;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --error: #ef4444;
    --success: #22c55e;
    --border: #2a2a2a;
    --user-bg: #1e3a5f;
    --assistant-bg: #1a1a1a;
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-primary);
    background-image: url('/static/chat-background.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    color: var(--text-primary);
}

/* Login Page */

.login-container {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.mascot-splash {
    margin-bottom: 1.5rem;
}

.splash-img {
    width: 192px;
    height: 192px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.login-card h1 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.tagline {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

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

.form-group {
    text-align: left;
}

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

.form-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 1rem;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
}

.error-message {
    color: var(--error);
    font-size: 0.875rem;
    display: none;
}

.login-btn {
    padding: 0.75rem 1.5rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.login-btn:hover {
    background: var(--accent-hover);
}

/* Chat Page */

.chat-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    background: transparent;
}

/* Mascot Section (in input area) */

.mascot-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-right: 1rem;
}

.mascot-image {
    width: 96px;
    height: 96px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.mascot-status-box {
    width: 96px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg-tertiary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--border);
    margin-top: 0.25rem;
}

.mascot-status {
    font-size: 1rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

/* Chat Header */

.chat-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header h1 {
    font-size: 1.25rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.connection-status {
    font-size: 0.75rem;
}

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

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

.logout-btn {
    padding: 0.4rem 0.75rem;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
}

.logout-btn:hover {
    border-color: var(--error);
    color: var(--error);
}

/* Messages Area */

.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.welcome-message {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

.message {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    word-wrap: break-word;
}

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

.message.assistant {
    align-self: flex-start;
    background: var(--assistant-bg);
    border: 1px solid var(--border);
}

.message.error {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid var(--error);
    color: var(--error);
}

.message-content {
    white-space: pre-wrap;
}

.message-content.markdown-body {
    white-space: normal;
    overflow-x: auto;
}

/* Ensure code blocks don't overflow */
.markdown-body pre {
    max-width: 100%;
    overflow-x: auto;
}

/* Input Area */

.input-area {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: flex-end;
    gap: 1rem;
}

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

.chat-form textarea {
    flex: 1;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    min-height: 9rem;
    max-height: 12rem;
}

.chat-form textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.send-btn {
    padding: 0.75rem;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.send-btn svg {
    fill: white;
    width: 24px;
    height: 24px;
}

/* Scrollbar */

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

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

.messages-area::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* Markdown Content Styles */

.markdown-body {
    line-height: 1.6;
}

.markdown-body p {
    margin: 0 0 1em 0;
}

.markdown-body p:last-child {
    margin-bottom: 0;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
    margin: 1em 0 0.5em 0;
    font-weight: 600;
    line-height: 1.3;
}

.markdown-body h1 { font-size: 1.5em; }
.markdown-body h2 { font-size: 1.3em; }
.markdown-body h3 { font-size: 1.1em; }
.markdown-body h4 { font-size: 1em; }

.markdown-body ul, .markdown-body ol {
    margin: 0.5em 0;
    padding-left: 2em;
    list-style-position: outside;
}

.markdown-body li {
    margin: 0.25em 0;
    display: list-item;
}

.markdown-body ul {
    list-style-type: disc;
}

.markdown-body ol {
    list-style-type: decimal;
}

.markdown-body ul ul {
    list-style-type: circle;
}

.markdown-body ul ul ul {
    list-style-type: square;
}

.markdown-body code {
    background: var(--bg-tertiary);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-family: 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
    font-size: 0.9em;
}

.markdown-body pre {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1em;
    margin: 0.75em 0;
    overflow-x: auto;
}

.markdown-body pre code {
    background: transparent;
    padding: 0;
    font-size: 0.875em;
    line-height: 1.5;
}

.markdown-body blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1em;
    margin: 0.75em 0;
    color: var(--text-secondary);
}

.markdown-body a {
    color: var(--accent);
    text-decoration: none;
}

.markdown-body a:hover {
    text-decoration: underline;
}

.markdown-body table {
    border-collapse: collapse;
    margin: 0.75em 0;
}

.markdown-body th, .markdown-body td {
    border: 1px solid var(--border);
    padding: 0.5em 0.75em;
}

.markdown-body th {
    background: var(--bg-tertiary);
    font-weight: 600;
}

.markdown-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1em 0;
}

/* Code syntax highlighting overrides for dark theme */
.hljs {
    background: transparent !important;
    padding: 0 !important;
}

/* Mobile Responsive */

@media (max-width: 768px) {
    .message {
        max-width: 90%;
    }

    .mascot-section {
        margin-right: 0.5rem;
    }

    .mascot-image {
        width: 64px;
        height: 64px;
    }

    .mascot-status-box {
        width: 64px;
    }

    .mascot-status {
        font-size: 0.75rem;
    }

    .chat-header h1 {
        font-size: 1rem;
    }

    .input-area {
        padding: 0.75rem;
    }

    .chat-form textarea {
        min-height: 3.5rem;
    }
}