/* ============================================================
   Экскурс по интерфейсу (frontend/js/onboarding.js)

   Затемнение делает не отдельный слой, а огромная box-shadow у «прожектора»:
   так вырез вокруг подсвеченного элемента получается без масок и SVG и плавно
   переезжает от шага к шагу одним transition.

   z-index 50 — ниже .settings-overlay (60): окно заявки на доступ и настройки
   1С должны открываться ПОВЕРХ экскурса.
   ============================================================ */

.tour-root {
  position: fixed;
  inset: 0;
  z-index: 50;
}
.tour-root[hidden] { display: none; }

.tour-scrim {
  position: absolute;
  inset: 0;
  background: transparent;
  transition: background var(--dur-slow, 280ms) var(--ease, ease);
}
/* Шаги без цели (приветствие, финал): затемняет сам слой — прожектора нет. */
.tour-root.is-dimmed .tour-scrim {
  background: rgba(2, 6, 23, 0.62);
  backdrop-filter: blur(2px);
}

.tour-spot {
  position: fixed;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  border-radius: 14px;
  pointer-events: none;
  box-shadow:
    0 0 0 9999px rgba(2, 6, 23, 0.62),
    0 0 0 2px rgba(129, 140, 248, 0.95),
    0 10px 34px rgba(79, 70, 229, 0.35);
  transition:
    left 420ms cubic-bezier(0.32, 0.72, 0, 1),
    top 420ms cubic-bezier(0.32, 0.72, 0, 1),
    width 420ms cubic-bezier(0.32, 0.72, 0, 1),
    height 420ms cubic-bezier(0.32, 0.72, 0, 1),
    opacity 200ms var(--ease, ease);
}
.tour-spot.is-hidden {
  opacity: 0;
  box-shadow: none;
}
.tour-spot::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 18px;
  border: 2px solid rgba(129, 140, 248, 0.55);
  animation: tourPulse 2.6s ease-out infinite;
}
.tour-spot.is-hidden::after { display: none; }

@keyframes tourPulse {
  0%   { opacity: 0.75; transform: scale(1); }
  70%  { opacity: 0;    transform: scale(1.045); }
  100% { opacity: 0;    transform: scale(1.045); }
}

/* ==================== Карточка-подсказка ==================== */

.tour-card {
  position: fixed;
  left: 0;
  top: 0;
  width: min(360px, calc(100vw - 24px));
  /* overflow остаётся visible: хвостик карточки — абсолютный псевдоэлемент за
     её границей, и любой overflow:auto превращал бы его в лишнюю прокрутку.
     Длинный текст скроллится внутри .tour-body. */
  padding: 15px 17px 13px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 18px;
  box-shadow: var(--shadow-xl, 0 30px 60px rgba(15, 23, 42, 0.18));
  font-family: var(--font, 'Inter', sans-serif);
  opacity: 0;
  transform: translateY(6px) scale(0.985);
}
.tour-card:focus { outline: none; }
.tour-card.is-in { animation: tourCardIn 280ms cubic-bezier(0.2, 0, 0, 1) forwards; }
@keyframes tourCardIn {
  to { opacity: 1; transform: none; }
}
.tour-card.is-hero { width: min(440px, calc(100vw - 24px)); }

/* Хвостик к подсвеченному элементу: повёрнутый квадрат с фоном карточки. */
.tour-card::before {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  transform: rotate(45deg);
}
.tour-card[data-side="center"]::before,
.tour-card[data-side="sheet"]::before { display: none; }
.tour-card[data-side="right"]::before {
  left: -7px;
  top: var(--tour-arrow, 28px);
  margin-top: -6px;
  clip-path: polygon(0 0, 0 100%, 100% 100%);
}
.tour-card[data-side="left"]::before {
  right: -7px;
  top: var(--tour-arrow, 28px);
  margin-top: -6px;
  clip-path: polygon(100% 0, 0 0, 100% 100%);
}
.tour-card[data-side="bottom"]::before {
  top: -7px;
  left: var(--tour-arrow, 28px);
  margin-left: -6px;
  clip-path: polygon(0 0, 100% 0, 100% 100%);
}
.tour-card[data-side="top"]::before {
  bottom: -7px;
  left: var(--tour-arrow, 28px);
  margin-left: -6px;
  clip-path: polygon(0 0, 0 100%, 100% 100%);
}

/* ==================== Шапка ==================== */

.tour-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.tour-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--accent-gradient, linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%));
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}
.tour-badge [data-lucide], .tour-badge .lucide { width: 17px; height: 17px; }

.tour-titles {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-top: 2px;
}

.tour-title {
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.011em;
  color: var(--text, #0f172a);
  line-height: 1.3;
}
.tour-card.is-hero .tour-title { font-size: 20px; }

.tour-counter {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-tertiary, #94a3b8);
  font-variant-numeric: tabular-nums;
}

.tour-close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-tertiary, #94a3b8);
  cursor: pointer;
  transition: background var(--dur-fast, 120ms) var(--ease, ease), color var(--dur-fast, 120ms) var(--ease, ease);
}
.tour-close:hover { background: var(--surface-3, #f1f5f9); color: var(--text-secondary, #64748b); }
.tour-close [data-lucide], .tour-close .lucide { width: 15px; height: 15px; }

/* ==================== Тело ==================== */

.tour-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: min(60vh, 540px);
  overflow-y: auto;
}
/* Кнопка-действие в теле — по содержимому, а не во всю ширину карточки. */
.tour-body > .tour-btn { align-self: flex-start; }

.tour-lead {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-secondary, #475569);
}
.tour-text {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-secondary, #475569);
}
.tour-text b { color: var(--text, #0f172a); font-weight: 650; }
.tour-note {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-tertiary, #94a3b8);
}
.tour-text code, .tour-body code {
  font-family: var(--font-mono, monospace);
  font-size: 12.5px;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-3, #f1f5f9);
  color: var(--indigo-700, #4338ca);
}

/* Список «что покажу» на приветственном экране. */
.tour-preview {
  list-style: none;
  display: grid;
  gap: 7px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-2, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
}
.tour-preview li {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--text-secondary, #475569);
}
.tour-preview [data-lucide], .tour-preview .lucide {
  width: 15px;
  height: 15px;
  color: var(--primary, #4f46e5);
  flex-shrink: 0;
}

/* Легенда статусов чата — точки повторяют список слева. */
.tour-legend {
  list-style: none;
  display: grid;
  gap: 6px;
}
.tour-legend-item {
  display: grid;
  grid-template-columns: 8px 1fr;
  align-items: baseline;
  gap: 9px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-secondary, #64748b);
}
.tour-legend-item b { color: var(--text, #0f172a); font-weight: 600; }
.tour-legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  transform: translateY(-1px);
}
.tour-legend-item[data-tone="open"]      .tour-legend-dot { color: #059669; }
.tour-legend-item[data-tone="live"]      .tour-legend-dot { color: #6366f1; }
.tour-legend-item[data-tone="attention"] .tour-legend-dot { color: #d97706; }
.tour-legend-item[data-tone="done"]      .tour-legend-dot { color: #64748b; }
.tour-legend-item[data-tone="muted"]     .tour-legend-dot { color: #cbd5e1; }
.tour-legend-item[data-tone="handoff"]   .tour-legend-dot { color: #0ea5e9; }

/* Тот же список без цветной точки (шпаргалка «куда идти») и с иконками
   вместо неё (лестница помощи). */
.tour-legend-plain .tour-legend-item { grid-template-columns: 1fr; }
.tour-legend-icons .tour-legend-item { grid-template-columns: 16px 1fr; align-items: start; }
.tour-legend-icons .tour-legend-item svg { width: 14px; height: 14px; color: #6366f1; }

/* Врезка «режим закрыт» с кнопкой заявки. */
.tour-callout {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--amber-100, #fef3c7);
  background: var(--amber-50, #fffbeb);
}
.tour-callout-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 650;
  color: var(--amber-700, #b45309);
}
.tour-callout-head [data-lucide], .tour-callout-head .lucide { width: 14px; height: 14px; }
.tour-callout p {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-secondary, #64748b);
}

.tour-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }

/* ==================== Подвал ==================== */

.tour-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 13px;
  padding-top: 11px;
  border-top: 1px solid var(--border, #e2e8f0);
}
.tour-card.is-hero .tour-foot { justify-content: flex-end; }

.tour-dots { display: flex; align-items: center; gap: 5px; }
.tour-dot {
  width: 6px;
  height: 6px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: var(--slate-300, #cbd5e1);
  cursor: pointer;
  transition: width 280ms var(--ease, ease), background 280ms var(--ease, ease);
}
.tour-dot:hover { background: var(--slate-400, #94a3b8); }
.tour-dot.is-active { width: 18px; background: var(--primary, #4f46e5); }

.tour-foot-buttons { display: flex; align-items: center; gap: 7px; margin-left: auto; }

.tour-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-fast, 120ms) var(--ease, ease),
              color var(--dur-fast, 120ms) var(--ease, ease),
              border-color var(--dur-fast, 120ms) var(--ease, ease),
              scale var(--dur-fast, 120ms) var(--ease, ease);
}
.tour-btn:active { scale: 0.97; }
.tour-btn:focus-visible { outline: 2px solid var(--indigo-200, #c7d2fe); outline-offset: 2px; }
.tour-btn [data-lucide], .tour-btn .lucide { width: 14px; height: 14px; }
.tour-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.tour-btn-primary {
  background: var(--primary, #4f46e5);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.28);
}
.tour-btn-primary:hover:not(:disabled) { background: var(--primary-hover, #4338ca); }

.tour-btn-ghost {
  background: var(--surface, #fff);
  border-color: var(--border, #e2e8f0);
  color: var(--text-secondary, #475569);
}
.tour-btn-ghost:hover:not(:disabled) { background: var(--surface-2, #f8fafc); color: var(--text, #0f172a); }

.tour-btn-text {
  background: transparent;
  color: var(--text-tertiary, #94a3b8);
  padding-left: 8px;
  padding-right: 8px;
}
.tour-btn-text:hover { color: var(--text-secondary, #64748b); }

.tour-btn-small { padding: 6px 11px; font-size: 12.5px; }

/* ==================== Узкий экран ==================== */

@media (max-width: 760px) {
  .tour-card[data-side="sheet"] {
    left: 12px;
    right: 12px;
    top: auto;
    bottom: 12px;
    width: auto;
    max-height: 70vh;
    border-radius: 20px;
  }
  .tour-card.is-hero { width: auto; }
}

/* Пользователь просил меньше движения — оставляем только смену содержимого. */
@media (prefers-reduced-motion: reduce) {
  .tour-spot { transition: opacity 120ms linear; }
  .tour-spot::after { animation: none; }
  .tour-card { opacity: 1; transform: none; }
  .tour-card.is-in { animation: none; }
  .tour-dot { transition: none; }
}
