/* ═══════════════════════════════════════════════════════════
   Otto Chat — Stylesheet
   Clean, modern chat UI inspired by Copilot / Claude
   ═══════════════════════════════════════════════════════════ */

/* ── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-primary: #1e1e2e;
    --bg-secondary: #181825;
    --bg-surface: #252537;
    --bg-hover: #2a2a3c;
    --bg-input: #313145;
    --text-primary: #cdd6f4;
    --text-secondary: #a6adc8;
    --text-muted: #6c7086;
    --accent: #89b4fa;
    --accent-hover: #74c7ec;
    --border: #313244;
    --error: #f38ba8;
    --success: #a6e3a1;
    --radius: 8px;
    --sidebar-width: 280px;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
}

.hidden { display: none !important; }

/* ── App Layout ───────────────────────────────────────── */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.5px;
}

.btn-new-chat {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background 0.15s;
}
.btn-new-chat:hover { background: var(--bg-hover); }

.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.conversation-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-secondary);
    transition: background 0.15s;
    margin-bottom: 2px;
}
.conversation-item:hover { background: var(--bg-hover); }
.conversation-item.active {
    background: var(--bg-surface);
    color: var(--text-primary);
}
.conversation-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
}
.btn-delete-convo {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
    opacity: 0;
    transition: opacity 0.15s;
}
.conversation-item:hover .btn-delete-convo { opacity: 1; }
.btn-delete-convo:hover { color: var(--error); }

.no-conversations {
    text-align: center;
    color: var(--text-muted);
    padding: 24px 12px;
    font-size: 13px;
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 12px 16px;
}
.user-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-secondary);
}
.btn-link {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
}
.btn-link:hover { color: var(--accent); }

/* ── Mobile sidebar toggle ────────────────────────────── */
.btn-sidebar-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 100;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 8px;
    cursor: pointer;
}

/* ── Chat Pane ────────────────────────────────────────── */
.chat-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}
.chat-title {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.model-selector select {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 5px 10px;
    font-size: 12px;
    cursor: pointer;
}

/* ── Messages ─────────────────────────────────────────── */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--text-muted);
    gap: 8px;
}
.welcome-icon { font-size: 48px; }
.welcome-screen h2 { font-size: 22px; color: var(--text-primary); }
.welcome-screen p { font-size: 15px; }

.message {
    display: flex;
    gap: 12px;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
}
.message-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    background: var(--bg-surface);
}
.message-body { flex: 1; min-width: 0; }
.message-role {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.message-content {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
}
.message-content.error { color: var(--error); }

.message-user .message-avatar { background: var(--accent); color: #1e1e2e; }

/* ── Reasoning Panel ──────────────────────────────────── */
.reasoning-panel {
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    max-height: 200px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.btn-toggle-reasoning {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.btn-toggle-reasoning:hover { color: var(--accent); }
.reasoning-content {
    padding: 0 20px 12px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-muted);
    overflow-y: auto;
    white-space: pre-wrap;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}
.reasoning-content.collapsed { display: none; }

/* ── Input Area ───────────────────────────────────────── */
.input-area {
    border-top: 1px solid var(--border);
    padding: 12px 20px 16px;
    background: var(--bg-secondary);
}
.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 12px;
    transition: border-color 0.15s;
}
.input-wrapper:focus-within {
    border-color: var(--accent);
}

#message-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    outline: none;
    max-height: 200px;
    font-family: inherit;
}
#message-input::placeholder { color: var(--text-muted); }

.btn-send {
    background: var(--accent);
    color: var(--bg-primary);
    border: none;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: opacity 0.15s;
}
.btn-send:disabled { opacity: 0.3; cursor: default; }
.btn-send:not(:disabled):hover { background: var(--accent-hover); }

.input-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
    padding: 0 4px;
}
.model-badge {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-surface);
    padding: 2px 8px;
    border-radius: 4px;
}
.status-indicator {
    font-size: 11px;
    color: var(--accent);
}

/* ── Login Page ───────────────────────────────────────── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
}
.login-container { width: 100%; max-width: 400px; padding: 20px; }
.login-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px;
}
.login-header {
    text-align: center;
    margin-bottom: 28px;
}
.login-header .logo { font-size: 28px; }
.login-subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 4px;
}

.auth-form { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.form-group input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}
.form-group input:focus { border-color: var(--accent); }

.btn { cursor: pointer; font-size: 14px; font-family: inherit; }
.btn-primary {
    background: var(--accent);
    color: var(--bg-primary);
    border: none;
    border-radius: var(--radius);
    padding: 10px;
    font-weight: 600;
    transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-full { width: 100%; }

.form-error {
    color: var(--error);
    font-size: 13px;
    text-align: center;
    padding: 8px;
    background: rgba(243, 139, 168, 0.1);
    border-radius: var(--radius);
}

.auth-switch {
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-muted);
}
.auth-switch a { color: var(--accent); text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

/* ── Responsive / Mobile ──────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }
    .sidebar.open { transform: translateX(0); }
    .btn-sidebar-toggle { display: flex; }

    .chat-header { padding-left: 52px; }

    .message { max-width: 100%; }
}

/* ── Scrollbar ────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
