/* F20.W8 — SetupChat premium styles.
 * Canon: Linear Copilot / Cal.com AI scheduler. Без эмодзи, lucide-icons.
 * Использует существующие tokens из tokens.css — без новых переменных.
 */

.sc-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #f8fafc;
  color: var(--text, #0f172a);
  font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
}

.sc-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  background: var(--surface, #fff);
}

.sc-header-icon {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  color: #fff;
  background: var(--brand-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sc-header-title {
  flex: 1;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0;
}

.sc-close {
  border: 0;
  background: transparent;
  color: var(--muted, #64748b);
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms ease-out;
}
.sc-close:hover { background: var(--surface-muted, #f1f5f9); }

.sc-icon-btn {
  border: 0;
  background: transparent;
  color: var(--muted, #64748b);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sc-icon-btn:hover,
.sc-icon-btn.is-active {
  background: var(--surface-muted, #f1f5f9);
  color: var(--brand-primary, #2563eb);
}

.sc-thread {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(248, 250, 252, 0.96)),
    #f8fafc;
}

.sc-empty-workbench {
  align-self: center;
  width: min(420px, 100%);
  margin: auto 0;
  padding: 22px 20px;
  border: 1px solid rgba(203, 213, 225, 0.8);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 18px 42px -34px rgba(15, 23, 42, 0.45);
  text-align: center;
}

.sc-empty-workbench[hidden] { display: none; }

.sc-empty-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 14px;
  background: #eff6ff;
  color: var(--brand-primary);
  margin-bottom: 12px;
}

.sc-empty-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0;
  color: #0f172a;
  margin-bottom: 6px;
}

.sc-empty-text {
  color: #64748b;
  font-size: 13px;
  line-height: 1.5;
}

.sc-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.sc-msg.is-user {
  align-self: flex-end;
  background: var(--brand-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 10px 24px -18px rgba(37, 99, 235, 0.9);
}

.sc-msg.is-assistant {
  align-self: flex-start;
  background: #fff;
  color: var(--text, #0f172a);
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 10px 28px -24px rgba(15, 23, 42, 0.55);
}

/* F516.W1 — markdown-рендер пузыря ассистента. .sc-md отключает pre-wrap
   (родитель .sc-msg имеет white-space: pre-wrap) — переносы и списки задаёт
   сам HTML (<br>, <ul>/<li>). Подмножество premium-style: жирный/курсив/списки. */
.sc-md { white-space: normal; }
.sc-md strong { font-weight: 650; }
.sc-md em { font-style: italic; }
.sc-md .sc-md-list {
  margin: 6px 0;
  padding-left: 18px;
  list-style: disc;
}
.sc-md .sc-md-list li { margin: 2px 0; }

.sc-tool-card {
  align-self: flex-start;
  max-width: 88%;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.sc-tool-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--text, #0f172a);
  font-size: 13px;
  text-align: left;
}

.sc-tool-icon { color: var(--success, #10b981); display: inline-flex; }
.sc-tool-icon.is-error { color: var(--danger, #ef4444); }

.sc-tool-label { flex: 1; }

.sc-tool-chevron {
  color: var(--muted, #64748b);
  transition: transform 150ms ease-out;
  display: inline-flex;
}
.sc-tool-card.is-open .sc-tool-chevron { transform: rotate(180deg); }

.sc-tool-detail {
  padding: 8px 12px 10px;
  border-top: 1px solid var(--border, #e2e8f0);
  font-family: var(--font-mono, ui-monospace, "SF Mono", monospace);
  font-size: 12px;
  color: var(--muted, #64748b);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow-y: auto;
}

.sc-pending {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--muted, #64748b);
}

.sc-pending-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand-primary, #2563eb);
  animation: scPulse 1.2s ease-in-out infinite;
}

@keyframes scPulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

.sc-done-banner {
  align-self: stretch;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 10px;
  font-size: 14px;
}

.sc-done-banner .sc-done-icon { color: var(--success, #10b981); display: inline-flex; }
.sc-done-banner-text { flex: 1; }

.sc-error-banner {
  align-self: stretch;
  padding: 10px 14px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 8px;
  font-size: 13px;
  color: var(--danger, #ef4444);
}
.sc-error-text {
  margin-bottom: 8px;
}
.sc-error-retry {
  appearance: none;
  border: 1px solid rgba(239, 68, 68, 0.4);
  background: #fff;
  color: var(--danger, #ef4444);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 150ms ease-out, border-color 150ms ease-out;
}
.sc-error-retry:hover {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.6);
}
.sc-error-retry:active {
  background: rgba(239, 68, 68, 0.16);
}

.sc-budget-exhausted-banner {
  align-self: stretch;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 10px;
  font-size: 13px;
}

.sc-budget-exhausted-banner .sc-budget-icon {
  color: var(--warning, #f59e0b);
  display: inline-flex;
  flex-shrink: 0;
  margin-top: 2px;
}

.sc-budget-exhausted-banner .sc-budget-body { flex: 1; min-width: 0; }

.sc-budget-exhausted-banner .sc-budget-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text, #0f172a);
  margin-bottom: 4px;
}

.sc-budget-exhausted-banner .sc-budget-text {
  color: var(--muted, #64748b);
  line-height: 1.5;
}

.sc-budget-exhausted-banner .sc-pristine-btn {
  flex-shrink: 0;
  align-self: center;
}

.sc-input-area {
  border-top: 1px solid var(--border, #e2e8f0);
  padding: 12px 18px 14px;
  background: var(--surface, #fff);
  box-shadow: 0 -18px 38px -34px rgba(15, 23, 42, 0.45);
}

.sc-input-hint {
  font-size: 13px;
  color: var(--muted, #64748b);
  margin-bottom: 8px;
  line-height: 1.45;
}

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

.sc-composer {
  flex: 1;
  min-width: 0;
  border: 1px solid #dbe4ef;
  border-radius: 13px;
  background: var(--surface, #fff);
  overflow: hidden;
  box-shadow: 0 10px 30px -26px rgba(15, 23, 42, 0.45);
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out, transform 150ms ease-out;
}

.sc-composer:focus-within {
  border-color: var(--brand-primary);
  box-shadow:
    0 0 0 4px rgba(37, 99, 235, 0.12),
    0 18px 34px -26px rgba(37, 99, 235, 0.8);
}

.sc-composer .sc-textarea {
  display: block;
  width: 100%;
  box-sizing: border-box;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  min-height: 52px;
  max-height: 156px;
  padding: 13px 14px 9px;
  line-height: 22px;
  overflow-y: hidden;
}

.sc-composer .sc-textarea:focus {
  border-color: transparent;
  box-shadow: none;
}

.sc-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 38px;
  padding: 5px 8px 7px;
  border-top: 1px solid rgba(226, 232, 240, 0.75);
}

.sc-toolbar-left,
.sc-toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.sc-tool-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted, #64748b);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms ease-out, color 150ms ease-out, border-color 150ms ease-out, opacity 150ms ease-out;
}

.sc-tool-btn:hover:not(:disabled),
.sc-tool-btn.is-active {
  background: var(--surface-muted, #f1f5f9);
  color: var(--brand-primary);
  border-color: rgba(37, 99, 235, 0.22);
}

.sc-tool-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}


.sc-textarea {
  flex: 1;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  background: var(--surface, #fff);
  color: var(--text, #0f172a);
  outline: none;
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out;
  max-height: 140px;
}
.sc-textarea:focus {
  border-color: var(--brand-primary, #2563eb);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 12%, transparent);
}
.sc-textarea:disabled { opacity: 0.5; cursor: not-allowed; }

.sc-send {
  border: 0;
  background: var(--brand-primary);
  color: #fff;
  padding: 0;
  width: 44px;
  height: 36px;
  border-radius: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 150ms ease-out, transform 100ms ease-out;
}
.sc-send:hover:not(:disabled) { opacity: 0.9; }
.sc-send:active:not(:disabled) { transform: scale(0.96); }
.sc-send:disabled { opacity: 0.4; cursor: not-allowed; }


.sc-footer {
  padding: 6px 18px 10px;
  font-size: 12px;
  color: var(--muted, #64748b);
  text-align: right;
}
.sc-footer[hidden] { display: none; }

.sc-undo-banner {
  align-self: stretch;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  font-size: 13px;
  color: #9a3412;
}

.sc-undo-icon { display: inline-flex; flex-shrink: 0; }
.sc-undo-text { flex: 1; min-width: 0; }

/* Pristine empty-state */
.sc-pristine {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 40px 24px;
  text-align: center;
}

.sc-pristine-icon {
  color: var(--muted, #94a3b8);
  margin-bottom: 18px;
}

.sc-pristine-title {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0;
  margin-bottom: 8px;
  color: var(--text, #0f172a);
}

.sc-pristine-subtitle {
  font-size: 14px;
  color: var(--muted, #64748b);
  max-width: 440px;
  margin-bottom: 28px;
  line-height: 1.55;
}

.sc-pristine-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.sc-pristine-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 150ms ease-out, transform 100ms ease-out;
}
.sc-pristine-btn.is-primary {
  background: var(--brand-primary, #2563eb);
  color: #fff;
}
.sc-pristine-btn.is-primary:hover { opacity: 0.92; }
.sc-pristine-btn.is-secondary {
  background: var(--surface, #fff);
  color: var(--text, #0f172a);
  border-color: var(--border, #e2e8f0);
}
.sc-pristine-btn.is-secondary:hover { background: var(--surface-muted, #f1f5f9); }

/* Nav button "AI помощник" в toolbar */
.sc-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: color-mix(in srgb, var(--brand-primary) 8%, transparent);
  color: var(--brand-primary, #2563eb);
  border: 1px solid color-mix(in srgb, var(--brand-primary) 20%, transparent);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms ease-out;
}
.sc-nav-btn:hover { background: color-mix(in srgb, var(--brand-primary) 14%, transparent); }

@media (max-width: 760px) {
  .sc-header { padding: 12px 14px; }
  .sc-thread { padding: 12px 14px 10px; }
  .sc-input-area { padding: 10px 14px 12px; }
  .sc-msg { max-width: 92%; }
}

/* F87.W2 — карточка подтверждения плана действий */
.sc-confirm-card {
  margin: 8px 0;
  border: 1px solid #c7d2fe;
  border-radius: 10px;
  background: #f5f6ff;
  padding: 12px 14px;
}
.sc-confirm-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #3730a3;
  margin-bottom: 10px;
}
.sc-confirm-rows { display: flex; flex-direction: column; gap: 6px; }
.sc-confirm-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: #1e293b;
  line-height: 1.4;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}
.sc-confirm-row:hover { background: color-mix(in srgb, var(--brand-primary) 8%, transparent); }
.sc-confirm-cb { margin-top: 2px; accent-color: var(--brand-primary); flex-shrink: 0; }
.sc-confirm-desc { flex: 1; }
.sc-confirm-actions { display: flex; gap: 8px; margin-top: 12px; }
.sc-confirm-exec,
.sc-confirm-cancel {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 150ms ease-out, border-color 150ms ease-out;
}
.sc-confirm-exec { background: var(--brand-primary); color: #fff; }
.sc-confirm-exec:hover { background: var(--brand-primary-hover); }
.sc-confirm-cancel { background: #fff; color: #475569; border-color: #cbd5e1; }
.sc-confirm-cancel:hover { background: #f1f5f9; }

/* F87.W5 — кнопки шапки (история/новый) + панель истории чатов */
.sc-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  transition: background 150ms ease-out, color 150ms ease-out;
}
.sc-icon-btn:hover { background: color-mix(in srgb, var(--brand-primary) 12%, transparent); color: var(--brand-primary); }

.chp-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10050;
}
.chp-panel {
  width: min(440px, 92vw);
  max-height: 78vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.28);
  overflow: hidden;
}
.chp-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid #eef2f7;
}
.chp-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
  flex: 1;
}
.chp-new {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid #c7d2fe;
  background: #eef2ff;
  color: var(--brand-primary-hover);
  cursor: pointer;
}
.chp-new:hover { background: #e0e7ff; }
.chp-close {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border: none; border-radius: 8px;
  background: transparent; color: #94a3b8; cursor: pointer;
}
.chp-close:hover { background: #f1f5f9; color: #475569; }
.chp-search-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid #eef2f7;
  color: #94a3b8;
}
.chp-search {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  background: transparent;
  color: #0f172a;
}
.chp-list { overflow-y: auto; padding: 8px; }
.chp-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  transition: background 150ms ease-out;
}
.chp-item:hover { background: #f5f6ff; }
.chp-item.is-current { background: #eef2ff; }
.chp-item-title {
  font-size: 13px;
  font-weight: 500;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chp-item-date { font-size: 11px; color: #94a3b8; }
.chp-empty { padding: 24px 16px; text-align: center; font-size: 13px; color: #94a3b8; }
