/* ── Layout ── */
body { overflow: hidden; }

.workspace {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: calc(100vh - 111px); /* subtract header */
}

@media (max-width: 800px) {
  .workspace { grid-template-columns: 1fr; height: auto; }
  body { overflow: auto; }
}

/* ── Header KPI chips ── */
.kpi-chips {
  display: flex;
  gap: 8px;
  align-items: center;
}

.kpi-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  min-width: 52px;
}

.kpi-chip > span:first-child {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}

.kpi-label {
  font-size: 10px;
  color: var(--muted);
}

.kpi-chip.danger > span:first-child { color: var(--red); }
.kpi-chip.success > span:first-child { color: var(--green); }

/* ── Queue sidebar ── */
.queue-sidebar {
  background: var(--surface);
  border-inline-end: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fdfaf4;
  flex-shrink: 0;
}

.sidebar-header h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--gold-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  background: var(--red);
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  padding: 0 5px;
}

.queue-list {
  flex: 1;
  overflow-y: auto;
}

.queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.1s;
}

.queue-item:hover { background: var(--bg); }
.queue-item.active { background: #fdf6e8; border-inline-start: 3px solid var(--gold); }
.queue-item:last-child { border-bottom: none; }

.escalation-score {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.score-high   { background: #fef2f2; color: var(--red);    border: 2px solid #fca5a5; }
.score-medium { background: #fffbeb; color: #d97706;        border: 2px solid #fcd34d; }
.score-low    { background: #f0fdf4; color: var(--green);  border: 2px solid #86efac; }

.queue-item-body { flex: 1; min-width: 0; }

.queue-item-id {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-item-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-channel-icon { font-size: 14px; flex-shrink: 0; }

/* ── Customer 360 main ── */
.customer360 {
  overflow-y: auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

/* Empty state */
.empty360 {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 24px;
  flex: 1;
}

.empty360-icon {
  font-size: 40px;
  margin-bottom: 10px;
  opacity: 0.4;
}

.empty360 > p {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 28px;
}

.live-feed-section {
  width: 100%;
  max-width: 860px;
}

.section-header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-header-row h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.section-sub {
  font-size: 12px;
  color: var(--muted);
}

.live-feed {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

/* ── View 360 ── */
.view360 {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 20px 24px;
  gap: 16px;
}

/* Profile strip */
.profile-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 18px;
  border-top: 3px solid var(--gold);
}

.profile-main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.profile-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fdf6e8;
  border: 2px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.profile-name {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.profile-id {
  font-size: 12px;
  color: var(--muted);
  display: block;
}

.profile-meta {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.channel-chips-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.ch-chip {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
}

.ch-chip.web      { border-color: #93c5fd; color: #1d4ed8; background: #eff6ff; }
.ch-chip.whatsapp { border-color: #86efac; color: #15803d; background: #f0fdf4; }
.ch-chip.call     { border-color: #fcd34d; color: #92400e; background: #fffbeb; }
.ch-chip.system   { border-color: #c4b5fd; color: #6d28d9; background: #f5f3ff; }

.sentiment-badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 10px;
}

.sentiment-badge.positive  { background: #d1fae5; color: #065f46; }
.sentiment-badge.neutral   { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.sentiment-badge.frustrated { background: #fef3c7; color: #92400e; }
.sentiment-badge.angry     { background: #fee2e2; color: #991b1b; }

.close-btn { margin-inline-start: auto; }

/* 360 grid */
.view360-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  flex: 1;
  min-height: 0;
}

@media (max-width: 1100px) {
  .view360-grid { grid-template-columns: 1fr; }
}

/* Timeline */
.timeline-section,
.copilot-section-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.customer-timeline {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 4px;
}

.tl-event {
  display: flex;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  position: relative;
}

.tl-event:last-child { border-bottom: none; }

.tl-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: var(--bg);
  margin-top: 1px;
}

.tl-dot.web      { background: #eff6ff; border-color: #93c5fd; }
.tl-dot.whatsapp { background: #f0fdf4; border-color: #86efac; }
.tl-dot.call     { background: #fffbeb; border-color: #fcd34d; }
.tl-dot.system   { background: #f5f3ff; border-color: #c4b5fd; }

.tl-body { flex: 1; min-width: 0; }

.tl-meta {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 3px;
}

.tl-text {
  font-size: 13px;
  color: var(--ink);
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.tl-score {
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 8px;
  background: #fee2e2;
  color: #991b1b;
  margin-top: 3px;
  display: inline-block;
}

/* Co-pilot trigger */
.copilot-trigger {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 28px 16px;
}

.copilot-focus-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.copilot-focus-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}

.copilot-focus-row input[type="radio"] {
  accent-color: var(--gold);
}

.run-copilot-btn {
  background: var(--gold);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.run-copilot-btn:hover { opacity: 0.88; }

/* Co-pilot panel */
.copilot-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 0;
  color: var(--muted);
  font-size: 14px;
}

.copilot-error {
  padding: 16px;
  background: #fef2f2;
  border-radius: 8px;
  color: var(--red);
  font-size: 13px;
}

.copilot-result {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 8px;
}

.cp-section { display: flex; flex-direction: column; gap: 6px; }

.cp-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.cp-text {
  font-size: 13px;
  color: var(--ink);
  line-height: 1.6;
}

.risk-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.risk-pill {
  text-align: center;
  padding: 8px 4px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
}

.risk-pill-label {
  display: block;
  font-size: 10px;
  font-weight: 400;
  opacity: 0.7;
  margin-bottom: 2px;
}

.risk-high   { background: #fef2f2; color: var(--red); }
.risk-medium { background: #fffbeb; color: #d97706; }
.risk-low    { background: #f0fdf4; color: var(--green); }

.action-box {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  color: #92400e;
  line-height: 1.6;
}

.reply-box {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--ink);
  line-height: 1.7;
  position: relative;
}

.copy-btn {
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
  font-size: 11px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  color: var(--muted);
  font-family: inherit;
}

.copy-btn:hover { border-color: var(--gold); color: var(--gold-dark); }

.must-not-list {
  margin: 0;
  padding-inline-start: 16px;
  font-size: 12px;
  color: var(--red);
  line-height: 1.7;
}

.cp-model-note {
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
}

/* Live feed rows */
.feed-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.1s;
}

.feed-row:hover { background: var(--bg); }
.feed-row:last-child { border-bottom: none; }

.feed-icon { font-size: 16px; padding-top: 1px; }

.feed-intent { font-weight: 600; color: var(--ink); }
.feed-cid    { color: var(--muted); margin-top: 1px; }
.feed-msg    { color: var(--muted); font-style: italic; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.feed-right  { text-align: end; color: var(--muted); white-space: nowrap; }
.feed-score  { display: inline-block; margin-top: 3px; font-size: 10px; padding: 1px 6px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); }

/* Shared */
.ghost-button {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.ghost-button.small { padding: 4px 10px; font-size: 12px; }
.ghost-button:hover { border-color: var(--gold); color: var(--gold-dark); }

.model-tag {
  font-size: 11px;
  font-weight: 600;
  background: #e8f5e9;
  color: var(--green);
  padding: 3px 8px;
  border-radius: 8px;
  border: 1px solid #b2dfdb;
}

.officer-badge {
  font-size: 12px;
  font-weight: 600;
  background: #fff7e6;
  color: var(--gold-dark);
  padding: 5px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 32px 20px;
  font-size: 14px;
}

.empty-state.small { padding: 20px; font-size: 13px; }

.spinner {
  width: 18px;
  height: 18px;
  border: 3px solid var(--line);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }
