/* ───────────────────────────────────────────────────────────────────────
   Kroner — Conversational AI web interface styles
   Built on top of PicoCSS (semantic-first)
   ─────────────────────────────────────────────────────────────────────── */

/* ── App layout: full viewport, three rows ───────────────────────────── */

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 100%;
  margin: 0;
  padding: 0;
}

/* ── Header ──────────────────────────────────────────────────────────── */

#header {
  flex-shrink: 0;
  padding: 0.75rem 1.25rem 0.5rem;
  border-bottom: var(--pico-muted-border-color) 1px solid;
}

#header hgroup {
  margin-bottom: 0;
}

#header h1 {
  margin-bottom: 0;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

#header p {
  margin-bottom: 0;
  font-size: 0.8rem;
  color: var(--pico-muted-color);
}

/* ── Connection status indicator ─────────────────────────────────────── */

#status {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 1rem;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-connected {
  background: #1a7f37;
  color: #fff;
}

.status-connecting {
  background: #9a6700;
  color: #fff;
  animation: pulse 1.2s ease-in-out infinite;
}

.status-disconnected {
  background: #6e7681;
  color: #fff;
}

.status-error {
  background: #cf222e;
  color: #fff;
}

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

/* ── Chat messages ──────────────────────────────────────────────────── */

#messages {
  flex: 1 1 0;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* ── Message bubble (base) ──────────────────────────────────────────── */

.msg {
  max-width: 72%;
  padding: 0.65rem 0.9rem;
  border-radius: 0.75rem;
  line-height: 1.45;
  font-size: 0.92rem;
  word-break: break-word;
}

/* User bubble — right-aligned */
.msg-user {
  align-self: flex-end;
  background: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
  border-bottom-right-radius: 0.2rem;
}

/* Assistant bubble — left-aligned */
.msg-assistant {
  align-self: flex-start;
  background: var(--pico-muted-border-color);
  color: var(--pico-color);
  border-bottom-left-radius: 0.2rem;
  white-space: pre-wrap;
}

/* ── Availability result (structured table output) ───────────────────── */

.msg-availability {
  align-self: flex-start;
  background: var(--pico-muted-border-color);
  color: var(--pico-color);
  font-family: var(--pico-font-family);
  padding: 0.75rem 1rem;
  border-bottom-left-radius: 0.2rem;
}

.msg-availability table {
  margin-bottom: 0;
  font-size: 0.88rem;
}

/* ── Heading label (model name, section title) ──────────────────────── */

.msg-heading {
  align-self: flex-start;
  max-width: 90%;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--pico-muted-color);
  padding: 0.2rem 0.5rem;
  border-radius: 0.35rem;
}

/* ── Muted text (reasoning, tool output, separators) ───────────────── */

.msg-muted {
  align-self: flex-start;
  max-width: 90%;
  font-size: 0.85rem;
  color: var(--pico-muted-color);
  padding: 0.35rem 0.6rem;
  font-family: monospace, var(--pico-font-family);
  white-space: pre-wrap;
  border-radius: 0.5rem;
  background: rgba(128, 128, 128, 0.06);
}

/* ── Highlight text (tool actions, approval notices) ────────────────── */

.msg-highlight {
  align-self: flex-start;
  max-width: 85%;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--pico-primary);
  padding: 0.4rem 0.7rem;
  border-radius: 0.5rem;
  background: rgba(128, 128, 128, 0.08);
}

/* ── Footer separator ───────────────────────────────────────────────── */

.msg-footer {
  align-self: flex-start;
  max-width: 60%;
  height: 1px;
  padding: 0;
  margin: 0.2rem 0;
  background: var(--pico-muted-border-color);
  border-radius: 0;
}

/* ── Error message ──────────────────────────────────────────────────── */

.msg-error {
  align-self: flex-start;
  max-width: 72%;
  color: #ff6b6b;
  background: rgba(255, 75, 75, 0.1);
  padding: 0.65rem 0.9rem;
  border-radius: 0.75rem;
  border-bottom-left-radius: 0.2rem;
}

/* ── Approval request ──────────────────────────────────────────────── */

.msg-approval {
  align-self: flex-start;
  max-width: 80%;
  background: rgba(128, 128, 128, 0.1);
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid var(--pico-muted-border-color);
}

.approval-info strong {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.92rem;
}

.approval-args {
  margin: 0 0 0.65rem 0;
  padding: 0.5rem 0.65rem;
  font-size: 0.78rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 0.4rem;
  overflow-x: auto;
  max-height: 10rem;
  overflow-y: auto;
}

.approval-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.approval-btn {
  font-size: 0.78rem;
  padding: 0.3rem 0.65rem;
  border-radius: 0.4rem;
  cursor: pointer;
  border: 1px solid var(--pico-muted-border-color);
  background: var(--pico-background-color);
  color: var(--pico-color);
  transition: background 0.15s, border-color 0.15s;
}

.approval-btn:hover {
  border-color: var(--pico-primary);
  background: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
}

.approval-btn.approve     { color: #3fb950; border-color: #3fb950; }
.approval-btn.approve:hover   { background: #1a7f37; color: #fff; }
.approval-btn.approve-all  { color: #3fb950; border-color: #3fb950; }
.approval-btn.approve-all:hover { background: #1a7f37; color: #fff; }
.approval-btn.approve-safe { color: #58a6ff; border-color: #58a6ff; }
.approval-btn.approve-safe:hover { background: #1f6feb; color: #fff; }
.approval-btn.reject       { color: #ff6b6b; border-color: #ff6b6b; }
.approval-btn.reject:hover { background: #cf222e; color: #fff; }
.approval-btn.abort        { color: #f47067; border-color: #f47067; }
.approval-btn.abort:hover  { background: #a40e26; color: #fff; }

/* ── Pprint color classes ──────────────────────────────────────────── */

.msg-assistant.color-white     { /* default — no override */ }
.msg-availability.color-white  { /* default — no override */ }

.msg-assistant.color-blue,
.msg-availability.color-blue   { color: #6ea8fe; }

.msg-assistant.color-green,
.msg-availability.color-green  { color: #81c995; }

.msg-assistant.color-cyan,
.msg-availability.color-cyan   { color: #78dce8; }

.msg-assistant.color-red,
.msg-availability.color-red    { color: #ff6b6b; }

.msg-assistant.color-yellow,
.msg-availability.color-yellow { color: #ffd166; }

.msg-assistant.color-dark_grey,
.msg-availability.color-dark_grey { color: #6e7681; }

.msg-assistant.color-magenta,
.msg-availability.color-magenta { color: #d2a8ff; }

/* ── Input area ──────────────────────────────────────────────────────── */

#input-area {
  flex-shrink: 0;
  padding: 0.75rem 1.25rem;
  border-top: var(--pico-muted-border-color) 1px solid;
}

#chat-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0;
  width: 100%;
}

#chat-form input {
  flex: 1 1 0;
  margin-bottom: 0;
}

#send-btn {
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
  padding: calc(var(--pico-spacing) * 0.5) calc(var(--pico-spacing) * 0.75);
  margin-bottom: 0;
  white-space: nowrap;
}

#reconnect-btn {
  width: 100%;
  margin-top: 0.5rem;
  margin-bottom: 0;
}

/* ── Scrollbar ──────────────────────────────────────────────────────── */

#messages::-webkit-scrollbar {
  width: 6px;
}

#messages::-webkit-scrollbar-thumb {
  background: var(--pico-muted-border-color);
  border-radius: 3px;
}

/* ── Responsive tweaks ──────────────────────────────────────────────── */

@media (max-width: 576px) {
  .msg {
    max-width: 88%;
  }

  #header h1 {
    font-size: 1.05rem;
  }

  .msg-approval {
    max-width: 92%;
  }
}
