/* Hearth frontend — minimal, warm-tones styling
 *
 * Design intent: feels like a home-control app, not an enterprise
 * dashboard.  Warmer palette than barkend (which is JCDP green).
 */

:root {
    --bg:        #faf7f2;
    --surface:   #ffffff;
    --primary:   #c84d2a;   /* hearth-orange */
    --primary-dark: #a23d20;
    --text:      #2c2826;
    --text-mute: #7a716a;
    --border:    #e3dcd2;
    --error:     #c0392b;
    --success:   #2d8b3c;
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, sans-serif;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

body.pwa-standalone { padding-top: env(safe-area-inset-top); }

.hidden { display: none !important; }

/* ─── Auth panels ─── */
.auth-panel {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 24px;
}
.auth-card {
    background: var(--surface); padding: 40px 32px;
    border-radius: 14px; box-shadow: 0 4px 24px rgba(40, 25, 15, 0.08);
    width: 100%; max-width: 420px; text-align: center;
}
.brand {
    font-size: 36px; font-weight: 700; color: var(--primary);
    letter-spacing: -0.02em;
}
.brand-sub {
    color: var(--text-mute); margin-top: 4px; margin-bottom: 32px;
}
.auth-card input[type="text"] {
    width: 100%; padding: 12px 14px; font-size: 16px;
    border: 1px solid var(--border); border-radius: 8px;
    margin-bottom: 16px; background: var(--bg);
}
.auth-card input:focus { outline: 2px solid var(--primary); }
#login-help {
    margin-top: 16px; color: var(--text-mute); font-size: 14px;
}

/* ─── Buttons ─── */
button.primary {
    background: var(--primary); color: white;
    padding: 12px 24px; font-size: 16px; font-weight: 600;
    border: none; border-radius: 8px; cursor: pointer;
    transition: background 0.15s;
}
button.primary:hover { background: var(--primary-dark); }
button.primary:disabled { opacity: 0.5; cursor: not-allowed; }

button.link {
    background: none; border: none; color: var(--text-mute);
    cursor: pointer; font-size: 14px; padding: 4px 8px;
}
button.link:hover { color: var(--primary); }

/* ─── Main app layout ─── */
#app {
    display: flex; flex-direction: column;
    height: 100vh; max-height: 100vh; overflow: hidden;
}

#topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 20px; background: var(--surface);
    border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.brand-small {
    font-weight: 700; color: var(--primary); font-size: 20px;
}
.topbar-right {
    display: flex; align-items: center; gap: 12px;
    color: var(--text-mute); font-size: 14px;
}

.scope-indicator {
    display: flex; align-items: center; gap: 6px; font-size: 14px;
}
.scope-label { color: var(--text-mute); }
.scope-button {
    background: var(--bg); border: 1px solid var(--border);
    padding: 4px 10px; border-radius: 6px;
    font-family: ui-monospace, monospace; font-size: 13px;
    color: var(--text); cursor: pointer;
}
.scope-button:hover { border-color: var(--primary); }

/* ─── Main layout (sidebar + chat) ─── */
#main {
    flex: 1; display: flex; overflow: hidden;
}

/* ─── Sidebar ─── */
#sidebar {
    width: 260px; background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    padding: 16px 12px; gap: 12px;
    overflow-y: auto;
}
#new-convo-btn {
    width: 100%; font-size: 14px; padding: 10px;
}
#convo-list { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.convo-item {
    width: 100%; background: transparent; border: none;
    padding: 10px 12px; border-radius: 8px;
    text-align: left; cursor: pointer; color: var(--text);
    display: flex; justify-content: space-between; align-items: center;
    gap: 8px; transition: background 0.15s;
}
.convo-item:hover { background: var(--bg); }
#convo-list li.active .convo-item {
    background: var(--bg); border-left: 3px solid var(--primary);
    padding-left: 9px;
}
.convo-preview {
    flex: 1; overflow: hidden; white-space: nowrap;
    text-overflow: ellipsis; font-size: 13px;
}
.convo-time {
    color: var(--text-mute); font-size: 11px; flex-shrink: 0;
}

@media (max-width: 700px) {
    #sidebar { display: none; }   /* mobile: hide sidebar; new-chat via menu TBD */
}

/* ─── Chat ─── */
#chat {
    flex: 1; display: flex; flex-direction: column;
    overflow: hidden;
}
#messages {
    flex: 1; overflow-y: auto; padding: 20px;
    display: flex; flex-direction: column; gap: 16px;
    max-width: 900px; width: 100%; margin: 0 auto;
}

.message { display: flex; gap: 12px; align-items: flex-start; }
.message.user { justify-content: flex-end; }
.message.assistant { justify-content: flex-start; }

.message-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--primary); color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px; flex-shrink: 0;
}

.message-content {
    background: var(--surface); padding: 12px 16px;
    border-radius: 12px; max-width: 70%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.message.user .message-content {
    background: var(--primary); color: white;
}
.message-sender {
    font-size: 12px; font-weight: 600; color: var(--text-mute);
    margin-bottom: 4px;
}
.message-text {
    line-height: 1.5; white-space: pre-wrap; word-wrap: break-word;
}

.pills {
    display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px;
}
.pill {
    padding: 3px 10px; border-radius: 12px; font-size: 12px;
    background: var(--bg); color: var(--text-mute);
    border: 1px solid var(--border);
}
.pill.tool { color: var(--primary); border-color: var(--primary); }
.pill.scope {
    color: var(--success); border-color: var(--success);
    font-family: ui-monospace, monospace;
}

.message.streaming .message-text::after {
    content: '▌'; color: var(--primary);
    animation: blink 0.8s steps(2, start) infinite;
}
@keyframes blink { to { visibility: hidden; } }

.error-note {
    color: var(--error); font-size: 13px; margin-top: 6px;
}

/* ─── Composer ─── */
#composer {
    display: flex; gap: 8px; padding: 16px 20px;
    background: var(--surface); border-top: 1px solid var(--border);
    max-width: 900px; width: 100%; margin: 0 auto;
}
#message-input {
    flex: 1; padding: 12px 14px; font-size: 16px;
    border: 1px solid var(--border); border-radius: 24px;
    background: var(--bg);
}
#message-input:focus { outline: 2px solid var(--primary); }
#send-btn { border-radius: 24px; padding: 12px 24px; }

/* ─── Error banner ─── */
.error-banner {
    position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
    background: var(--error); color: white; padding: 10px 20px;
    border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 100; font-size: 14px;
}

/* ─── Modal ─── */
.modal {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 50; padding: 24px;
}
.modal-card {
    background: var(--surface); padding: 24px; border-radius: 12px;
    min-width: 320px; max-width: 480px;
}
.modal-card h2 { margin-bottom: 16px; font-size: 18px; }
.modal-card ul { list-style: none; }
.modal-card li button {
    width: 100%; text-align: left; padding: 10px 12px;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: 6px; margin-bottom: 6px; cursor: pointer;
    font-family: ui-monospace, monospace; font-size: 14px;
}
.modal-card li button:hover { border-color: var(--primary); color: var(--primary); }
.modal-note {
    margin-top: 12px; padding: 10px; background: var(--bg);
    border-radius: 6px; font-size: 13px; color: var(--text-mute);
}
