/* ==========================================================================
   ИИ-секретарь: интерактивное демо (secretary.html)
   Окно чата стилизовано под Telegram (светлая тема), всё остальное страница
   берёт из style.css. Цвета пузырей и цитат намеренно «телеграмные», а не
   золотые акценты сайта, чтобы демо читалось как настоящий чат.
   ========================================================================== */

.sec-demo { padding: var(--space-6) 0 var(--space-7); background: var(--color-bg-elevated); border-bottom: 1px solid var(--color-border-soft); }
.sec-demo .section-title { margin-bottom: var(--space-3); max-width: none; }

/* ---------- scenario tabs ---------- */
.sec-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: var(--space-4);
}
.sec-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font: 500 14.5px/1.2 var(--font-sans);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 980px;
  cursor: pointer;
  transition: background-color 200ms var(--ease), border-color 200ms var(--ease), color 200ms var(--ease);
}
.sec-tab:hover { border-color: var(--color-accent); color: var(--color-accent); }
.sec-tab.is-active, .sec-tab[aria-selected="true"] {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-on-accent);
}
.sec-tab-icon { font-size: 15px; line-height: 1; }

/* ---------- layout: info left, chat right on desktop ---------- */
.sec-demo-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 440px;
  grid-template-areas: "info chat";
  gap: var(--space-6);
  align-items: start;
}
.sec-chat-col { grid-area: chat; min-width: 0; }
.sec-info { grid-area: info; align-self: center; }
.sec-info h3 { font-size: 24px; letter-spacing: -0.015em; margin-bottom: 12px; }
.sec-info p { font-size: 16.5px; }
.sec-info .sec-info-note {
  margin-top: var(--space-3);
  padding: 12px 16px;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--color-accent);
  background: rgba(var(--color-accent-rgb), 0.08);
  border: 1px solid rgba(var(--color-accent-rgb), 0.25);
  border-radius: var(--radius-sm);
}
.sec-info-item[hidden] { display: none; }

.sec-disclaimer {
  margin: 10px 4px 0;
  font-size: 12px;
  color: var(--color-text-faint);
  text-align: center;
}

/* ---------- Telegram window ---------- */
.tg-window {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 24px 50px -28px rgba(29, 29, 31, 0.35);
  font-family: var(--font-sans);
  scroll-margin-top: 175px;
}
.tg-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: #fff;
  border-bottom: 1px solid #e6e6ea;
}
.tg-avatar {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  font-size: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7bc4f0, #3a8fd9);
}
.tg-head-text { min-width: 0; flex: 1; }
.tg-name { font-size: 15.5px; font-weight: 600; color: #000; line-height: 1.25; }
.tg-status { font-size: 13px; color: #8a8a8f; line-height: 1.25; }
.tg-status.is-typing { color: #3390ec; }
.tg-head-dots { display: inline-flex; flex-direction: column; gap: 3px; padding: 0 6px; }
.tg-head-dots i { width: 3.5px; height: 3.5px; border-radius: 50%; background: #9a9aa0; }

.tg-body {
  height: clamp(400px, 64vh, 560px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 10px 14px;
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.35) 0, rgba(255, 255, 255, 0) 45%),
    radial-gradient(circle at 85% 80%, rgba(255, 255, 255, 0.25) 0, rgba(255, 255, 255, 0) 40%),
    linear-gradient(160deg, #b9d6a6 0%, #a5cda0 45%, #93c2a6 100%);
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.25) transparent;
}

.tg-chip {
  width: fit-content;
  margin: 6px auto 10px;
  padding: 3px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: #fff;
  background: rgba(60, 90, 70, 0.45);
  border-radius: 980px;
}

.tg-msg { display: flex; flex-direction: column; width: fit-content; margin-bottom: 6px; max-width: 88%; }
.tg-msg.in { align-items: flex-start; margin-right: auto; }
.tg-msg.out { align-items: flex-end; margin-left: auto; }
.tg-msg.is-new { animation: tg-pop 280ms var(--ease) both; }

.tg-bubble {
  position: relative;
  padding: 6px 10px 5px;
  font-size: 14.5px;
  line-height: 1.38;
  color: #000;
  border-radius: 14px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12);
  overflow-wrap: anywhere;
  min-width: 0;
  max-width: 100%;
}
.tg-msg.in .tg-bubble { background: #fff; border-bottom-left-radius: 4px; }
.tg-msg.out .tg-bubble { background: #eeffde; border-bottom-right-radius: 4px; }

.tg-line { min-height: 1.38em; }
.tg-gap { height: 0.6em; }
.tg-line b { font-weight: 600; }
.tg-nowrap { white-space: nowrap; }
.tg-up { color: #2e9e45; }
.tg-down { color: #e0453b; }

.tg-quote {
  position: relative;
  margin: 3px 0;
  padding: 3px 8px 3px 10px;
  border-left: 3px solid #3390ec;
  border-radius: 3px 8px 8px 3px;
  background: rgba(51, 144, 236, 0.1);
}
.tg-quote-exp {
  max-height: 4.1em;
  overflow: hidden;
  padding-right: 26px;
  cursor: pointer;
  -webkit-mask-image: linear-gradient(#000 55%, rgba(0, 0, 0, 0.25));
  mask-image: linear-gradient(#000 55%, rgba(0, 0, 0, 0.25));
}
.tg-quote-exp::after {
  content: "";
  position: absolute;
  right: 9px;
  top: 8px;
  width: 7px;
  height: 7px;
  border-right: 2px solid #3390ec;
  border-bottom: 2px solid #3390ec;
  transform: rotate(45deg);
}
.tg-quote-exp.is-open { max-height: none; -webkit-mask-image: none; mask-image: none; }
.tg-quote-exp.is-open::after { top: 11px; transform: rotate(-135deg); }

.tg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  margin-top: 1px;
  font-size: 11.5px;
  line-height: 1;
  color: #9aa0a6;
  user-select: none;
}
.tg-msg.out .tg-meta { color: #5ea859; }
.tg-checks { width: 17px; height: 10px; }
.tg-bubble.is-short { display: flex; align-items: flex-end; gap: 10px; }
.tg-bubble.is-short .tg-meta { margin: 0 0 2px; flex: none; }

/* voice message */
.tg-voice { display: flex; align-items: center; gap: 10px; min-width: 210px; padding: 2px 0 0; }
.tg-voice-play {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #4fae4e;
}
.tg-voice-play svg { width: 16px; height: 16px; margin-left: 2px; fill: #fff; }
.tg-voice-main { flex: 1; min-width: 0; }
.tg-wave { display: flex; align-items: center; gap: 2px; height: 22px; }
.tg-wave i { flex: 1; min-width: 2px; max-width: 3px; border-radius: 2px; background: #5ea859; opacity: 0.85; }
.tg-wave i.is-rest { opacity: 0.35; }
.tg-voice-dur { margin-top: 2px; font-size: 12px; color: #5ea859; }
.tg-voice-text {
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px solid rgba(94, 168, 89, 0.3);
  font-size: 13.5px;
  color: #2f3b2f;
}

/* inline keyboard */
.tg-kb { display: flex; gap: 4px; width: 100%; margin-top: 4px; }
.tg-kbtn {
  flex: 1;
  padding: 8px 6px;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  background: rgba(50, 80, 62, 0.55);
  border-radius: 8px;
  transition: background-color 150ms, transform 150ms;
  user-select: none;
}
.tg-kbtn.is-tapped { background: rgba(35, 110, 70, 0.9); transform: scale(0.96); }

/* typing bubble */
.tg-typing .tg-bubble { display: flex; align-items: center; gap: 4px; padding: 11px 14px; }
.tg-typing .tg-bubble i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9aa0a6;
  animation: tg-dot 1.1s infinite ease-in-out;
}
.tg-typing .tg-bubble i:nth-child(2) { animation-delay: 0.15s; }
.tg-typing .tg-bubble i:nth-child(3) { animation-delay: 0.3s; }

@keyframes tg-pop { from { opacity: 0; transform: translateY(8px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes tg-dot { 0%, 60%, 100% { transform: translateY(0); opacity: 0.45; } 30% { transform: translateY(-4px); opacity: 1; } }

/* footer: disabled input + replay */
.tg-foot { padding: 10px 12px 12px; background: #fff; border-top: 1px solid #e6e6ea; }
.tg-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 40px;
  color: #9a9aa0;
  background: #f1f1f4;
  border-radius: 20px;
}
.tg-input input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font: 400 15px var(--font-sans);
  color: #9a9aa0;
  cursor: not-allowed;
}
.tg-input input::placeholder { color: #9a9aa0; opacity: 1; }
.tg-input input:disabled { opacity: 1; }
.tg-input-icon { flex: none; }
.tg-replay {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin-top: 8px;
  padding: 9px 14px;
  font: 500 14px var(--font-sans);
  color: var(--color-accent);
  background: transparent;
  border: 1px solid rgba(var(--color-accent-rgb), 0.4);
  border-radius: 980px;
  cursor: pointer;
  transition: background-color 200ms var(--ease), border-color 200ms var(--ease);
}
.tg-replay:hover { background: rgba(var(--color-accent-rgb), 0.08); border-color: var(--color-accent); }

/* ---------- features ---------- */
.sec-features { padding: var(--space-7) 0; background: var(--color-bg); border-bottom: 1px solid var(--color-border-soft); }
.sec-feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
}
.sec-feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-bottom: var(--space-2);
  font-size: 21px;
  border-radius: 50%;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border-soft);
}
.sec-feature-wide {
  grid-column: 1 / -1;
  border-color: rgba(var(--color-accent-rgb), 0.35);
  background: rgba(var(--color-accent-rgb), 0.05);
}
.sec-feature-wide p { max-width: 80ch; }

/* ---------- connect ---------- */
.sec-connect { padding: var(--space-7) 0; background: var(--color-bg-elevated); }
.sec-connect .section-title { margin-bottom: var(--space-2); }
.sec-connect-lead { max-width: 62ch; font-size: 17px; color: var(--color-text-muted); margin-bottom: var(--space-5); }
.sec-steps { margin-bottom: var(--space-4); }
.sec-note {
  max-width: 70ch;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-sm);
}
.sec-cta { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-4); }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .sec-demo-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "chat" "info"; gap: var(--space-4); }
  .sec-info { align-self: stretch; }
  .sec-feature-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .sec-demo { padding: var(--space-5) 0 var(--space-6); }
  .sec-tabs { gap: 6px; }
  .sec-tab { padding: 9px 13px; font-size: 13.5px; gap: 6px; }
  .sec-feature-grid { grid-template-columns: minmax(0, 1fr); }
  .tg-body { height: clamp(380px, 62vh, 520px); padding: 10px 8px 12px; }
  .tg-msg { max-width: 94%; }
  .tg-bubble { font-size: 14px; }
  .sec-info h3 { font-size: 21px; }
  .sec-cta .btn { width: 100%; white-space: normal; text-align: center; }
}

/* reduced motion: no animation, everything is shown at once (see secretary.js) */
@media (prefers-reduced-motion: reduce) {
  .tg-msg.is-new { animation: none; }
  .tg-typing .tg-bubble i { animation: none; }
  .tg-kbtn { transition: none; }
}
