/* Otto chat dock — companion stylesheet.
 *
 * The dock's JS auto-injects its own <style> tag on first mount, so this
 * file is OPTIONAL. It's published alongside the JS for two reasons:
 *
 *   1. Build pipelines that prefer bundled CSS over runtime-injected
 *      <style> tags can opt in by linking this file from the host page
 *      head and stripping the inline injection (set
 *      `window.__OTTO_DOCK_SKIP_INLINE = true` before loading the JS).
 *
 *   2. Authoring tooling (Stylelint, design-system audits) can introspect
 *      a real CSS file rather than parse a JS string literal.
 *
 * The selectors must stay byte-for-byte identical to the inline string in
 * otto-dock.js so the runtime fallback and this stylesheet produce the
 * same visual result.
 *
 * Theme contract: every color routes through tokens from global.css per
 * packages/shared/THEME_RULES.md. Both themes adapt automatically.
 */

.otto-dock-root {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  background: var(--bg-glass);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-left: 1px solid var(--cyan-bg-hover);
  color: var(--text-primary);
  font-family: Inter, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  transition: width 0.18s ease;
}

.otto-dock-root.is-collapsed { width: 56px; }
.otto-dock-root.is-collapsed .otto-dock-body,
.otto-dock-root.is-collapsed .otto-dock-input-row,
.otto-dock-root.is-collapsed .otto-dock-eyebrow,
.otto-dock-root.is-collapsed .otto-dock-chips { display: none; }

.otto-dock-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 10px;
  gap: 8px;
}

.otto-dock-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cyan-text-action);
}

.otto-dock-toggle {
  background: transparent;
  border: 1px solid var(--cyan-border);
  color: var(--cyan);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.otto-dock-toggle svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.otto-dock-chips {
  padding: 0 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.otto-dock-chip {
  text-align: left;
  font: inherit;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--cyan-bg-faint);
  border: 1px solid var(--cyan-border-faint);
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.otto-dock-chip:hover {
  background: var(--cyan-bg-soft);
  border-color: var(--cyan-border);
}
.otto-dock-chip:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.otto-dock-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.otto-dock-msg {
  font-size: 14px;
  line-height: 1.5;
  padding: 10px 12px;
  border-radius: 12px;
  max-width: 100%;
  word-wrap: break-word;
}
.otto-dock-msg.is-user {
  align-self: flex-end;
  background: var(--cyan-bg-soft);
  border: 1px solid var(--cyan-border);
  color: var(--text-primary);
}
.otto-dock-msg.is-otto {
  align-self: flex-start;
  background: var(--surface-soft);
  border: 1px solid var(--surface-border);
  color: var(--text-primary);
}
.otto-dock-msg.is-pending { opacity: 0.78; font-style: italic; }
.otto-dock-msg.is-error {
  align-self: flex-start;
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-text);
}

/* Cyan-tinted "✓ Paused campaign" badge that sits below Otto's reply
 * after a tool call ran. 11px italic, cyan accent — same family as
 * the chips and eyebrow. */
.otto-dock-action-badge {
  align-self: flex-start;
  font-size: 11px;
  font-style: italic;
  color: var(--cyan-text-action);
  letter-spacing: 0.04em;
  margin-top: -4px;
  padding: 0 4px;
}

.otto-dock-empty {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  padding: 6px 2px;
}

.otto-dock-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 16px 18px;
  border-top: 1px solid var(--surface-border-faint);
}
.otto-dock-input {
  flex: 1;
  min-width: 0;
  background: var(--surface-soft);
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  color: inherit;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.12s ease;
}
.otto-dock-input:focus { border-color: var(--cyan-border-strong); }
.otto-dock-send {
  background: var(--cyan);
  color: var(--on-cyan);
  border: none;
  border-radius: 10px;
  padding: 0 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease;
}
.otto-dock-send:hover { background: var(--cyan-hover); }
.otto-dock-send:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 1100px) {
  .otto-dock-root { width: 300px; }
}
@media (max-width: 880px) {
  /* Otto Chat v1 Phase 1: mobile = full-screen modal when expanded.
     Was a 50vh bottom sheet — too cramped for general chat on every
     page. Full-screen matches busy-operator target (long-form chat
     while on phone). Collapsed state stays as a thin 48px bottom bar
     so the dock is one-tap away without claiming any screen space. */
  .otto-dock-root {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    border-left: none;
    z-index: 95;  /* above sidebar (90) so the modal covers it cleanly */
  }
  .otto-dock-root.is-collapsed {
    /* Collapsed mobile = thin bottom bar with cyan accent.
       Width stays 100% so the chevron is centered + tappable.
       Border + z-index: token-routed per packages/shared/THEME_RULES.md
       (no rgba literals — PRs #613/#615/#616/#631 sweep). */
    width: 100%;
    height: 48px;
    top: auto;
    bottom: 0;
    border-left: none;
    border-top: 1px solid var(--cyan-bg-hover);
    z-index: 90;  /* below the expanded modal (z-index: 95) so toggling cleanly layers */
  }
  /* Mobile expanded header gets more breathing room since it's a
     full-screen modal (the "tap to close" affordance needs to be
     obvious — toggle button stays in the header top-right). */
  .otto-dock-root:not(.is-collapsed) .otto-dock-header {
    padding: 22px 20px 14px;
  }
  /* Mobile chip rail spans more of the screen comfortably. */
  .otto-dock-root:not(.is-collapsed) .otto-dock-chips {
    padding: 0 20px 14px;
  }
  /* Mobile send button gets a comfortable hit-target. */
  .otto-dock-send { min-height: 44px; }
  .otto-dock-input { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .otto-dock-root { transition: none; }
  .otto-dock-step-icon.is-active { animation: none; }
}

/* Content reflow — when the dock is mounted, the .ro-main-content column
   pads right by the dock's width so the dock doesn't overlap page
   content. The body.is-dock-collapsed class is toggled by the auto-mount
   in shared-sidebar.js (and by per-page reflow binders for the explicit
   mounts) to track the dock's collapsed/expanded state.

   Pages without a .ro-main-content shell are unaffected — the rule is
   scoped so embedded surfaces or lightweight layouts that don't use the
   .ro-layout grid don't inherit unexpected padding. */
body.has-otto-dock .ro-main-content {
  padding-right: 360px;
  transition: padding 0.18s ease;
}
body.has-otto-dock.is-dock-collapsed .ro-main-content {
  padding-right: 56px;
}
@media (max-width: 1100px) {
  body.has-otto-dock .ro-main-content { padding-right: 300px; }
  body.has-otto-dock.is-dock-collapsed .ro-main-content { padding-right: 56px; }
}
@media (max-width: 880px) {
  /* On mobile the dock is a full-screen modal when expanded (covers
     content entirely) or a thin 48px bottom bar when collapsed. The
     expanded state needs no content padding (modal is fully on top);
     the collapsed state pads bottom by 48px so the bar doesn't overlap
     the last bit of page content. */
  body.has-otto-dock .ro-main-content {
    padding-right: 0;
    padding-bottom: 48px;
  }
  body.has-otto-dock.is-dock-collapsed .ro-main-content {
    padding-right: 0;
    padding-bottom: 48px;
  }
}

/* Publish progress block (AI_CREATE_FIX1_SPEC §5.6) — replaces the chat
   empty placeholder during the AI Create publish flow. Four steps with
   cyan-stroke icons; clinical, no celebration shouting. */
.otto-dock-publish {
  margin: 8px 4px;
  padding: 14px;
  background: var(--cyan-bg-faint);
  border: 1px solid var(--cyan-bg-hover);
  border-radius: 14px;
}
.otto-dock-publish-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cyan-text-action);
  margin-bottom: 10px;
}
.otto-dock-publish-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.otto-dock-publish-steps li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  line-height: 1.3;
}
.otto-dock-publish-steps li.is-pending { color: var(--text-tertiary); }
.otto-dock-publish-steps li.is-active  { color: var(--text-primary); }
.otto-dock-publish-steps li.is-done    { color: var(--text-secondary); }
.otto-dock-publish-steps li.is-failed  { color: var(--text-primary); }

.otto-dock-step-icon.is-done    { color: var(--cyan); }
.otto-dock-step-icon.is-active  { color: var(--cyan); animation: otto-dock-spin 0.9s linear infinite; }
.otto-dock-step-icon.is-pending { color: var(--icon-muted); }
.otto-dock-step-icon.is-failed  { color: var(--text-primary); }

@keyframes otto-dock-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.otto-dock-publish-footer {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--surface-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.otto-dock-publish-footer:empty { display: none; }

.otto-dock-publish-cta {
  display: inline-block;
  padding: 9px 14px;
  background: var(--cyan);
  color: var(--on-cyan);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  border-radius: 10px;
  border: 1px solid var(--cyan);
  text-align: center;
  transition: background 0.15s ease;
}
.otto-dock-publish-cta:hover { background: var(--cyan-hover); }
.otto-dock-publish-cta.is-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--cyan-border);
}
.otto-dock-publish-cta.is-outline:hover {
  background: var(--cyan-bg-soft);
}

.otto-dock-publish-error {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* ─── Phase 2 PR A: header action row + thread panel ───────────── */

.otto-dock-header-actions {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.otto-dock-iconbtn {
  background: transparent;
  border: 1px solid var(--cyan-border);
  color: var(--cyan);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.otto-dock-iconbtn:hover {
  background: var(--cyan-bg-soft);
  border-color: var(--cyan-border-strong);
}
.otto-dock-iconbtn:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}
.otto-dock-iconbtn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.otto-dock-root.is-collapsed .otto-dock-header-actions { display: none; }

.otto-dock-thread-panel {
  position: absolute;
  top: 64px;
  left: 0;
  right: 0;
  bottom: 62px;
  background: var(--bg-glass);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--cyan-bg-hover);
  z-index: 5;
  display: flex;
  flex-direction: column;
}
.otto-dock-thread-panel[hidden] { display: none; }

.otto-dock-thread-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 10px;
  border-bottom: 1px solid var(--surface-border-faint);
}
.otto-dock-thread-panel-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cyan-text-action);
}

.otto-dock-thread-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.otto-dock-thread-row {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  color: inherit;
  font: inherit;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.otto-dock-thread-row:hover {
  background: var(--cyan-bg-faint);
  border-color: var(--cyan-border-faint);
}
.otto-dock-thread-row.is-active {
  background: var(--cyan-bg-soft);
  border-color: var(--cyan-border);
}
.otto-dock-thread-row.is-proactive .otto-dock-thread-row-title:before {
  content: "✨ ";
  color: var(--cyan-text-action);
}
.otto-dock-thread-row-title {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.3;
}
.otto-dock-thread-row-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ─── Phase 2 PR D: voice mic button ─────────────────────────────── */

.otto-dock-mic {
  background: transparent;
  border: 1px solid var(--cyan-border);
  color: var(--cyan);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
}
.otto-dock-mic:hover {
  background: var(--cyan-bg-soft);
  border-color: var(--cyan-border-strong);
}
.otto-dock-mic:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}
.otto-dock-mic svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Recording state — cyan-tinted, gentle pulse. */
.otto-dock-mic.is-recording {
  background: var(--cyan-bg-soft);
  border-color: var(--cyan);
  animation: otto-dock-mic-pulse 1.4s ease-in-out infinite;
}
@keyframes otto-dock-mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--cyan-bg-hover); }
  50%      { box-shadow: 0 0 0 6px transparent; }
}

/* Mobile: 44pt tap target per Q-P2-1 acceptance criteria. */
@media (max-width: 880px) {
  .otto-dock-mic {
    width: 44px;
    height: 44px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .otto-dock-mic.is-recording { animation: none; }
}
