/* Cat Chat — the 1c bubble chat surface.
   All colour comes from ui/css/tokens.css custom properties. The only
   literal colour words here are the CSS keyword "white" for text/knobs
   that sit on a solid brand-blue background — there is no separate
   "on-blue text" token, and the handoff spells this out as literal white. */

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--cc-font);
  color: var(--cc-text-hi);
  background: var(--cc-page-bg);
}

button {
  font-family: inherit;
}

/* ---------------------------------------------------------------------- */
/* Mock OS chrome — demo-only, disappears in the Tauri shell.              */
/* ---------------------------------------------------------------------- */

.os-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 32px;
  padding: 0 12px;
  background: var(--cc-page-bg);
  border-bottom: 1px solid var(--cc-border);
  font-size: 12px;
  color: var(--cc-text-mid);
}

.tray-icon {
  position: relative;
  width: 26px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cc-card-bg);
  border: 1px solid var(--cc-border);
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
}

.tray-bubble svg {
  display: block;
}

.tray-badge {
  position: absolute;
  top: -3px;
  right: -4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cc-blue);
  box-shadow: 0 0 0 1.5px var(--cc-page-bg);
}

.tray-badge[hidden] {
  display: none;
}

/* ---------------------------------------------------------------------- */
/* Popover                                                                 */
/* ---------------------------------------------------------------------- */

.popover {
  position: absolute;
  top: 40px;
  right: 12px;
  width: 320px;
  max-height: 480px;
  border-radius: 12px;
  border: 1px solid var(--cc-border);
  box-shadow: var(--cc-popover-shadow);
  background: var(--cc-card-bg);
  overflow: hidden;
  flex-direction: column;
  animation: cc-pop 180ms ease-out;
}

.popover[hidden] {
  display: none;
}

.popover:not([hidden]) {
  display: flex;
}

/* ---------------------------------------------------------------------- */
/* Brand band — stays light in both themes.                               */
/* ---------------------------------------------------------------------- */

.brand-band {
  flex-shrink: 0;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: var(--cc-brand-band-bg);
  border-bottom: 1px solid var(--cc-brand-band-border);
}

.brand-mark svg {
  display: block;
}

.wordmark {
  margin-right: auto;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -0.01em;
  color: var(--cc-text-hi);
}

.wordmark b {
  font-weight: 700;
  color: var(--cc-blue-text);
}

.band-action {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--cc-text-mid);
  padding: 4px 6px;
  border-radius: 6px;
}

.band-action:hover {
  background: var(--cc-elevated-bg);
}

/* ---------------------------------------------------------------------- */
/* Body — swapped wholesale per view.                                      */
/* ---------------------------------------------------------------------- */

.body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--cc-card-bg);
}

/* ---------------------------------------------------------------------- */
/* Status strip                                                           */
/* ---------------------------------------------------------------------- */

.status-strip {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--cc-border);
}

.status-pill {
  flex-shrink: 0;
  background: var(--cc-blue-pale);
  color: var(--cc-blue-text);
  border-radius: 11px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.status-pill.resolved {
  background: var(--cc-ok-fill);
  color: var(--cc-ok);
}

.thread-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 11.5px;
  color: var(--cc-text-mid);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-num {
  flex-shrink: 0;
  margin-left: auto;
  border: 1px solid var(--cc-border);
  border-radius: 6px;
  padding: 2px 7px;
  font-family: var(--cc-font-mono);
  font-size: 11.5px;
  color: var(--cc-text-mid);
  white-space: nowrap;
}

/* ---------------------------------------------------------------------- */
/* Reconnecting banner                                                    */
/* ---------------------------------------------------------------------- */

.reconnect-banner {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--cc-warn-fill);
  font-size: 11px;
  color: var(--cc-text-mid);
}

.reconnect-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cc-warn);
  animation: cc-pulse 1.8s ease-in-out infinite;
}

/* ---------------------------------------------------------------------- */
/* Transcript — column-reverse, message array reversed in JS. No scroll   */
/* scripting, ever.                                                        */
/* ---------------------------------------------------------------------- */

.transcript {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column-reverse;
  overflow-y: auto;
  padding: 10px 12px;
  gap: 8px;
}

.msg-row {
  display: flex;
}

.msg-row.mine {
  justify-content: flex-end;
}

.msg-row.theirs {
  justify-content: flex-start;
}

.msg-group {
  display: flex;
  flex-direction: column;
  max-width: 81%;
  gap: 3px;
}

.msg-row.mine .msg-group {
  align-items: flex-end;
}

.bubble {
  font-size: 13.5px;
  line-height: 1.45;
  padding: 8px 12px;
  overflow-wrap: break-word;
  animation: cc-in 160ms ease-out;
}

.bubble.mine {
  background: var(--cc-blue);
  color: white;
  border-radius: 15px 15px 4px 15px;
}

.bubble.theirs {
  background: var(--cc-elevated-bg);
  color: var(--cc-text-hi);
  border-radius: 15px 15px 15px 4px;
}

/* Queued: dashed outline, transparent fill, never a delivered indicator. */
.bubble.queued {
  background: transparent;
  border: 1px dashed var(--cc-blue-dim);
  color: var(--cc-text-hi);
}

.meta {
  font-size: 10.5px;
  color: var(--cc-text-lo);
}

.sys-chip {
  align-self: center;
  font-size: 10.5px;
  color: var(--cc-text-lo);
  margin: 4px 0;
}

/* ---------------------------------------------------------------------- */
/* Empty state — 42px mark at full strength, never faded.                  */
/* ---------------------------------------------------------------------- */

.empty-state {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  padding: 24px 20px;
}

.empty-mark {
  color: var(--cc-text-hi);
}

.empty-mark svg {
  display: block;
}

.empty-heading {
  font-size: 14px;
  font-weight: 600;
  color: var(--cc-text-hi);
}

.empty-body {
  max-width: 220px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--cc-text-mid);
}

/* ---------------------------------------------------------------------- */
/* Resolved confirmation footer                                           */
/* ---------------------------------------------------------------------- */

.resolved-actions {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--cc-border);
}

.resolved-btn {
  flex: 1;
  border-radius: 14px;
  border: 1px solid var(--cc-border);
  padding: 8px 10px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--cc-card-bg);
  color: var(--cc-text-hi);
  cursor: pointer;
}

.resolved-btn.primary {
  background: var(--cc-blue);
  border-color: var(--cc-blue);
  color: white;
}

/* ---------------------------------------------------------------------- */
/* Composer                                                                */
/* ---------------------------------------------------------------------- */

.composer-wrap {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--cc-border);
  background: var(--cc-card-bg);
}

.new-request-hint {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--cc-blue-text);
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.composer-input {
  flex: 1;
  min-width: 0;
  background: var(--cc-elevated-bg);
  border: 1px solid var(--cc-border);
  border-radius: 17px;
  padding: 10px 13px;
  font-family: var(--cc-font);
  font-size: 13.5px;
  line-height: 1.35;
  color: var(--cc-text-hi);
  max-height: 90px;
  resize: none;
  outline: none;
}

.composer-input:focus {
  border-color: var(--cc-blue);
}

.send-btn {
  flex-shrink: 0;
  border: none;
  border-radius: 16px;
  padding: 9px 15px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--cc-blue);
  color: white;
  cursor: pointer;
}

.send-btn.is-empty {
  background: var(--cc-blue-dim);
  opacity: 0.45;
  cursor: default;
}

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.diag-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px dashed var(--cc-border);
  border-radius: 11px;
  padding: 3px 9px;
  font-size: 10.5px;
  font-weight: 600;
  opacity: 0.5;
  cursor: not-allowed;
  background: transparent;
  color: var(--cc-text-mid);
}

.diag-pill .glyph {
  width: 9px;
  height: 9px;
  border: 1px solid currentColor;
  display: inline-block;
}

.hint-line {
  font-size: 10.5px;
  color: var(--cc-text-lo);
  white-space: nowrap;
}

/* ---------------------------------------------------------------------- */
/* Settings                                                                */
/* ---------------------------------------------------------------------- */

.settings {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  background: var(--cc-page-bg);
}

.settings-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.back-btn {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--cc-text-mid);
  padding: 2px 4px;
}

.settings-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--cc-text-hi);
}

.card {
  background: var(--cc-card-bg);
  border: 1px solid var(--cc-border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.identity-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--cc-blue-pale);
  color: var(--cc-blue-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
}

.identity-text .name {
  font-size: 13px;
  font-weight: 600;
  color: var(--cc-text-hi);
}

.identity-text .sub {
  font-size: 11.5px;
  color: var(--cc-text-mid);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.toggle-label .title {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--cc-text-hi);
}

.toggle-label .sub {
  margin-top: 2px;
  font-size: 10.5px;
  color: var(--cc-text-lo);
}

.toggle {
  position: relative;
  flex-shrink: 0;
  width: 38px;
  height: 22px;
  border-radius: 11px;
  border: none;
  padding: 0;
  background: var(--cc-border);
  cursor: pointer;
}

.toggle.on {
  background: var(--cc-blue);
}

.toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  transition: transform 0.15s ease;
}

.toggle.on .toggle-knob {
  transform: translateX(16px);
}

.about-mono {
  font-family: var(--cc-font-mono);
  font-size: 11px;
  line-height: 1.6;
  color: var(--cc-text-mid);
}

.link-btn {
  align-self: flex-start;
  border: none;
  background: none;
  padding: 0;
  font-size: 11.5px;
  color: var(--cc-blue-text);
  cursor: pointer;
}

.danger-btn {
  border: 1px solid var(--cc-bad);
  background: var(--cc-bad-fill);
  color: var(--cc-bad);
  border-radius: 10px;
  padding: 9px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.settings-footnote {
  text-align: center;
  font-size: 11px;
  color: var(--cc-text-lo);
}

/* ---------------------------------------------------------------------- */
/* First-run sign-in (1a) — email + admin-issued code only; the Microsoft   */
/* PKCE button and OTP boxes 1a also shows are phase-2 real auth, not built */
/* here. Panel colors are the theme-invariant brand tokens (the brand      */
/* panel stays light in both themes, same rule as the brand band).        */
/* ---------------------------------------------------------------------- */

.signin-wrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 14px;
}

.signin-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--cc-brand-panel-bg);
  color: var(--cc-brand-panel-text);
  border-radius: 10px;
  padding: 22px 18px 18px;
  box-shadow: var(--cc-brand-glow);
}

.signin-brand-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* .wordmark's plain text color otherwise follows the theme (--cc-text-hi),
   which would go pale-on-pale here since this panel never darkens. */
.signin-panel .wordmark {
  color: var(--cc-brand-panel-text);
}

.signin-body {
  font-size: 13px;
  line-height: 1.5;
}

.signin-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.signin-input {
  background: var(--cc-elevated-bg);
  border: 1px solid var(--cc-border);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: var(--cc-font);
  font-size: 13.5px;
  color: var(--cc-text-hi);
  outline: none;
}

.signin-input:focus {
  border-color: var(--cc-blue);
}

.signin-error {
  font-size: 12px;
  line-height: 1.4;
  color: var(--cc-bad);
}

.signin-footnote {
  text-align: center;
  font-size: 11.5px;
  color: var(--cc-text-lo);
}

/* ---------------------------------------------------------------------- */
/* Auth-expired re-auth panel — thread dims to 35%, panel slides up.        */
/* ---------------------------------------------------------------------- */

.signedout-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dimmed-thread {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  opacity: 0.35;
  pointer-events: none;
}

.reauth-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--cc-card-bg);
  border-top: 1px solid var(--cc-border);
  border-radius: 12px 12px 0 0;
  box-shadow: var(--cc-popover-shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: cc-pop 180ms ease-out;
}

.reauth-heading {
  font-size: 13px;
  font-weight: 600;
  color: var(--cc-text-hi);
}

.reauth-body {
  font-size: 12px;
  line-height: 1.5;
  color: var(--cc-text-mid);
}

.primary-btn {
  width: 100%;
  border: none;
  border-radius: 10px;
  padding: 10px;
  font-size: 13px;
  font-weight: 600;
  background: var(--cc-blue);
  color: white;
  cursor: pointer;
}

/* ---------------------------------------------------------------------- */
/* Toast — reuses cc-pop, auto-dismiss handled in JS.                      */
/* ---------------------------------------------------------------------- */

.toast-host {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--cc-card-bg);
  border: 1px solid var(--cc-border);
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: var(--cc-popover-shadow);
  font-size: 12px;
  color: var(--cc-text-hi);
  animation: cc-pop 180ms ease-out;
}

/* ---------------------------------------------------------------------- */
/* Spinner — reserved for the 1a auth round-trip (not rendered by this     */
/* task's views); declared so the four required keyframes are all in one  */
/* stylesheet and available to reuse later without adding a fifth.        */
/* ---------------------------------------------------------------------- */

.spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--cc-border);
  border-top-color: var(--cc-blue);
  animation: cc-spin 900ms linear infinite;
}

/* ---------------------------------------------------------------------- */
/* Animations — exactly these four, nothing else animates.                 */
/* ---------------------------------------------------------------------- */

@keyframes cc-pulse { 0%, 100% { opacity: 1 } 50% { opacity: .35 } }
@keyframes cc-pop   { from { opacity: 0; transform: translateY(-4px) scale(.98) } to { opacity: 1; transform: none } }
@keyframes cc-in    { from { opacity: 0; transform: translateY(3px) } to { opacity: 1; transform: none } }
@keyframes cc-spin  { to { transform: rotate(360deg) } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
