/* Inbox-specific styles */

/* Reading-lane width when the contact panel is hidden.
   Picked to keep message lines around 70ch for comfortable reading
   (ux-guidelines: line-length / container-width). */
:root {
  --inbox-lane: 920px;
  --inbox-lane-gutter: 32px;
}

.inbox-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr) 320px;
  height: 100%;
  min-height: 0;
  transition: grid-template-columns 240ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.inbox-layout.contact-hidden {
  grid-template-columns: 340px minmax(0, 1fr) 0;
}

.col-list, .col-thread, .col-contact {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}
.col-list { border-right: 1px solid var(--border); }
.col-contact {
  border-left: 1px solid var(--border);
  background: var(--surface-2);
  overflow: hidden;
  transition: border-color 200ms ease;
}
.inbox-layout.contact-hidden .col-contact {
  border-left-color: transparent;
}
.col-thread { background: var(--bg); }

@media (prefers-reduced-motion: reduce) {
  .inbox-layout,
  .inbox-layout .col-contact,
  .inbox-layout .thread-header,
  .inbox-layout .thread-body,
  .inbox-layout .composer,
  .inbox-layout .ai-banner { transition: none !important; }
}

.col-list-header {
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.col-list-body {
  flex: 1;
  overflow: auto;
  padding: 4px 6px;
}

/* Conv list items */
.conv-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  border-radius: var(--r-md);
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  width: 100%;
  text-align: left;
  margin-bottom: 2px;
  transition: background 100ms;
}
.conv-item:hover { background: var(--surface-2); }
.conv-item.active { background: var(--accent-soft); border-color: var(--accent-soft-2); }
.conv-meta { flex: 1; min-width: 0; }
.conv-name { font-weight: 500; font-size: 13.5px; }
.conv-time { font-size: 11.5px; color: var(--text-subtle); flex-shrink: 0; margin-left: 6px; }
.conv-preview { font-size: 12.5px; color: var(--text-muted); }
.conv-unread {
  background: var(--accent);
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  border-radius: 999px;
  padding: 0 6px;
  min-width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  font-variant-numeric: tabular-nums;
  margin-left: 6px;
}

/* === Thread === */
.thread {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.thread-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  transition: padding 240ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.thread-header-id {
  min-width: 0;
  flex: 1 1 0%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}
.thread-header-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.thread-header-name {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  min-width: 0;
  flex: 0 1 auto;
}
.thread-header-sub {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  min-width: 0;
}
.thread-header-sub .mono { font-size: 11.5px; }
.thread-header-room { color: var(--text); font-weight: 600; }
.thread-header-dot { color: var(--text-subtle); }
.thread-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}
.thread-header-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 2px;
  display: inline-block;
}
.panel-restore {
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-color: var(--accent-soft-2);
  transition: color 140ms ease, background 140ms ease, border-color 140ms ease;
}
.panel-restore:hover {
  background: var(--accent-soft-2);
  color: var(--accent-ink);
  border-color: var(--accent-soft-2);
}
.panel-restore:focus-visible {
  outline: 2px solid var(--accent-soft-2);
  outline-offset: 1px;
}

.ai-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  background: var(--ai-soft);
  border-bottom: 1px solid var(--ai-soft-2);
  font-size: 12.5px;
  color: var(--ai-ink);
  transition: padding 240ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* === Reading-lane: when the contact panel is hidden, center the thread
   content into a comfortable reading column. Keeps the scroll on the
   parent so the scrollbar stays at the right edge, while content sits
   inside a balanced max-width column. */
.inbox-layout.contact-hidden .thread-header,
.inbox-layout.contact-hidden .ai-banner {
  padding-inline: max(18px, calc((100% - var(--inbox-lane)) / 2));
}
.inbox-layout.contact-hidden .thread-body {
  padding-inline: max(var(--inbox-lane-gutter), calc((100% - var(--inbox-lane)) / 2));
}
.inbox-layout.contact-hidden .composer {
  padding-inline: max(14px, calc((100% - var(--inbox-lane)) / 2));
}
.inbox-layout.contact-hidden .bubble,
.inbox-layout.contact-hidden .note-bubble { max-width: 620px; }
.inbox-layout.contact-hidden .ai-suggestion { max-width: 660px; }

.thread-body {
  flex: 1;
  overflow: auto;
  padding: 16px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: padding 240ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.thread-day {
  text-align: center;
  margin: 12px 0 8px;
  position: relative;
}
.thread-day span {
  font-size: 11px;
  color: var(--text-subtle);
  background: var(--bg);
  padding: 2px 10px;
  border-radius: 999px;
  position: relative;
  z-index: 1;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.thread-day::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
}

.msg-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-top: 4px;
}
.msg-row.agent { justify-content: flex-end; }

.bubble {
  max-width: 560px;
  padding: 9px 13px 7px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  position: relative;
  box-shadow: var(--shadow-sm);
}
.bubble.client {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  color: var(--text);
}
.bubble.agent {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.bubble.agent.ai {
  background: linear-gradient(135deg, var(--ai), oklch(0.5 0.19 270));
}

.msg-time {
  font-size: 10.5px;
  margin-top: 4px;
  opacity: 0.7;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.bubble.client .msg-time { color: var(--text-muted); opacity: 1; }
.msg-ai-tag {
  display: inline-flex; align-items: center; gap: 3px;
  background: rgba(255,255,255,0.2);
  padding: 1px 5px; border-radius: 4px; font-weight: 500;
}

.note-bubble {
  background: oklch(0.97 0.04 75);
  border: 1px solid oklch(0.9 0.06 75);
  color: oklch(0.34 0.06 75);
  border-radius: 10px;
  padding: 9px 12px 7px;
  font-size: 13px;
  line-height: 1.5;
  max-width: 560px;
}
.note-head {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex; align-items: center; gap: 4px;
  margin-bottom: 4px;
  color: oklch(0.45 0.08 75);
}

.ai-suggestion {
  background: var(--ai-soft);
  border: 1px solid var(--ai-soft-2);
  border-radius: 12px;
  padding: 12px;
  margin: 12px 0 4px;
  color: var(--ai-ink);
  max-width: 600px;
  align-self: flex-end;
}

/* === Composer === */
.composer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 8px 14px 12px;
  transition: padding 240ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.composer.note-mode {
  background: oklch(0.99 0.02 75);
  border-top-color: oklch(0.9 0.06 75);
}
.composer-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0 6px;
}
.composer-tab {
  padding: 5px 10px;
  font-size: 12.5px;
  color: var(--text-muted);
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.composer-tab:hover { background: var(--surface-2); color: var(--text); }
.composer-tab.active { background: var(--surface-3); color: var(--text); font-weight: 500; }
.composer-tab.active.note { background: oklch(0.93 0.05 75); color: oklch(0.34 0.08 75); }

.composer-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--surface);
  font-size: 13.5px;
  resize: none;
  min-height: 80px;
  max-height: 200px;
  line-height: 1.55;
}
.composer.note-mode .composer-input {
  background: oklch(0.98 0.04 75);
  border-color: oklch(0.9 0.06 75);
}
.composer-input:focus { outline: 2px solid var(--accent-soft-2); border-color: var(--accent); }
.composer.note-mode .composer-input:focus { outline-color: oklch(0.88 0.08 75); border-color: oklch(0.7 0.1 75); }

.composer-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.qr-popover {
  position: absolute;
  bottom: 36px;
  left: 0;
  width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 10;
  max-height: 320px;
  overflow: auto;
}
.qr-head {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 10px 4px;
}
.qr-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
}
.qr-item:hover { background: var(--surface-2); }
.qr-title { font-size: 12.5px; font-weight: 500; margin-bottom: 2px; }
.qr-body { font-size: 12px; color: var(--text-muted); }

/* === Contact panel (right column) === */
.contact-panel {
  overflow: auto;
  padding-bottom: 24px;
  min-width: 320px;
}
.contact-head {
  position: relative;
  padding: 24px 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.contact-head-close {
  position: absolute;
  top: 10px;
  right: 10px;
  color: var(--text-subtle);
}
.contact-head-close:hover {
  color: var(--text);
  background: var(--surface-3);
}
.contact-head-close:focus-visible {
  outline: 2px solid var(--accent-soft-2);
  outline-offset: 1px;
}
.cp-section {
  padding: 14px 20px 6px;
  border-bottom: 1px solid var(--border);
}
.cp-section-title {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}
.cp-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 13px;
  color: var(--text);
}
.cp-row svg { color: var(--text-muted); flex-shrink: 0; }
.cp-attr {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 12.5px;
}
.cp-conv {
  display: flex;
  gap: 8px;
  padding: 8px;
  border-radius: var(--r-sm);
  cursor: pointer;
  align-items: center;
  margin: 2px 0;
}
.cp-conv:hover { background: var(--surface-3); }

/* === Generic page layouts === */
.page {
  padding: 24px 28px;
  max-width: 100%;
}
.page-head {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 22px;
}
.page-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0;
}
.page-sub {
  font-size: 13.5px;
  color: var(--text-muted);
  margin: 2px 0 0;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

/* === Metric card === */
.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
}
.metric-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.01em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.metric-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-sans);
}
.metric-delta {
  font-size: 11.5px;
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.metric-delta.up { color: var(--ok); }
.metric-delta.down { color: var(--busy); }

/* === Settings === */
.settings-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  height: 100%;
}
.settings-nav {
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  padding: 14px 8px;
  overflow: auto;
}
.settings-nav-item {
  width: 100%;
  text-align: left;
  padding: 7px 12px;
  font-size: 13px;
  color: var(--text);
  border-radius: var(--r-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.settings-nav-item:hover { background: var(--surface-3); }
.settings-nav-item.active { background: var(--surface); font-weight: 500; box-shadow: var(--shadow-sm); }
.settings-content { overflow: auto; }

/* AI agent cards */
.ai-agent-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  cursor: pointer;
  transition: border-color 120ms, box-shadow 120ms;
}
.ai-agent-card:hover { border-color: var(--ai-soft-2); box-shadow: var(--shadow-sm); }
.ai-agent-card.active { border-color: var(--ai); box-shadow: 0 0 0 3px var(--ai-soft); }
.ai-avatar {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, var(--ai), oklch(0.5 0.19 270));
  color: #fff; font-weight: 700;
  display: grid; place-items: center;
  font-size: 16px;
  letter-spacing: -0.02em;
}

/* Schedule grid */
.sched-grid {
  display: grid;
  grid-template-columns: 80px repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.sched-cell {
  background: var(--surface);
  padding: 6px 8px;
  font-size: 11.5px;
  min-height: 32px;
  position: relative;
}
.sched-head { background: var(--surface-2); font-weight: 500; text-align: center; color: var(--text-muted); }
.sched-row-head { background: var(--surface-2); display: flex; align-items: center; gap: 6px; }
.sched-shift {
  display: block;
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-left: 3px solid var(--accent);
  padding: 4px 6px;
  margin: 2px 0;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* Bar chart */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 180px;
  padding: 8px 0;
}
.bar {
  flex: 1;
  background: var(--accent-soft);
  border-radius: 4px 4px 0 0;
  position: relative;
  min-height: 4px;
  transition: background 120ms;
}
.bar:hover { background: var(--accent); }
.bar-label {
  position: absolute;
  bottom: -22px;
  left: 0; right: 0;
  text-align: center;
  font-size: 10.5px;
  color: var(--text-subtle);
}
.bar-value {
  position: absolute;
  top: -16px;
  left: 0; right: 0;
  text-align: center;
  font-size: 10.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
