/**
 * mtk-chat.css — стили AI-чат-виджета.
 * Подключается через <link rel="stylesheet" href="mtk-chat.css?v=N">.
 */

/* ── FAB кнопка ─────────────────────────────────────────── */
.mtk-chat-fab {
  position: fixed;
  bottom: 22px;
  right: 22px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #1d5c3a;
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(15,35,23,0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  transition: transform 0.15s, box-shadow 0.15s;
}
.mtk-chat-fab:hover { transform: scale(1.06); box-shadow: 0 8px 28px rgba(15,35,23,0.35); }
.mtk-chat-fab:active { transform: scale(0.96); }
.mtk-chat-fab svg { width: 22px; height: 22px; }
.mtk-chat-fab.mtk-chat-open { background: #6b6862; }

/* ── Panel (drawer) ─────────────────────────────────────── */
.mtk-chat-panel {
  position: fixed;
  bottom: 88px;
  right: 22px;
  width: 420px;
  max-width: calc(100vw - 32px);
  height: 70vh;
  max-height: 720px;
  min-height: 440px;
  background: #fff;
  border: 1px solid #e2e0da;
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(15,35,23,0.18);
  z-index: 200;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Golos Text', system-ui, sans-serif;
}
.mtk-chat-panel.mtk-chat-open { display: flex; }

/* ── Header ─────────────────────────────────────────────── */
.mtk-chat-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 12px 16px;
  padding-right: 44px; /* место для абсолютного крестика */
  border-bottom: 1px solid #e2e0da;
  background: #faf9f7;
  flex-shrink: 0;
}
.mtk-chat-icon-btn[data-act="close"] {
  position: absolute;
  top: 8px;
  right: 8px;
}
.mtk-chat-title { font-size: 14px; font-weight: 600; color: #1a1917; flex: 1; }
.mtk-chat-sub { font-size: 11px; color: #9e9b96; font-family: 'JetBrains Mono', monospace; }
.mtk-chat-icon-btn {
  background: none; border: none; cursor: pointer;
  width: 28px; height: 28px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  color: #9e9b96; border-radius: 6px;
  transition: background 0.12s, color 0.12s;
}
.mtk-chat-icon-btn:hover { background: #f2f1ee; color: #1a1917; }
.mtk-chat-icon-btn svg { width: 16px; height: 16px; }

/* ── Messages ────────────────────────────────────────────── */
.mtk-chat-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fff;
  min-width: 0;
}
.mtk-chat-msg {
  max-width: 92%;
  min-width: 0;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
}
.mtk-chat-msg-user {
  align-self: flex-end;
  background: #edf5f0;
  color: #1a1917;
  border-bottom-right-radius: 4px;
}
.mtk-chat-msg-assistant {
  align-self: flex-start;
  background: #f7f6f3;
  color: #1a1917;
  border-bottom-left-radius: 4px;
}
.mtk-chat-msg-tool {
  align-self: stretch;
  max-width: 100%;
  min-width: 0;
  background: transparent;
  color: #9e9b96;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 4px 8px;
  border-left: 2px solid #d0cec8;
  border-radius: 0;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-wrap: anywhere;
}
.mtk-chat-msg-error {
  align-self: stretch;
  background: #fef2f2;
  color: #b91c1c;
  border-radius: 8px;
  font-size: 12px;
}
.mtk-chat-msg-table {
  align-self: stretch;
  background: #fff;
  border: 1px solid #e2e0da;
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
  font-size: 12px;
}
.mtk-chat-msg-table table { width: 100%; border-collapse: collapse; }
.mtk-chat-msg-table th, .mtk-chat-msg-table td {
  text-align: left; padding: 6px 10px;
  border-bottom: 1px solid #e2e0da;
}
.mtk-chat-msg-table th { background: #faf9f7; font-weight: 600; font-size: 11px; color: #6b6862; }
.mtk-chat-msg-table tr:last-child td { border-bottom: none; }
.mtk-chat-msg-table a { color: #1d5c3a; text-decoration: none; }
.mtk-chat-msg-table a:hover { text-decoration: underline; }

/* ── Empty state ─────────────────────────────────────────── */
.mtk-chat-empty {
  text-align: center;
  padding: 28px 20px;
  color: #9e9b96;
  font-size: 13px;
  line-height: 1.6;
}
.mtk-chat-empty-title { font-size: 14px; font-weight: 600; color: #1a1917; margin-bottom: 4px; }
.mtk-chat-empty-examples { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; }
.mtk-chat-empty-example {
  font-size: 12px;
  text-align: left;
  background: #f7f6f3;
  border: 1px solid #e2e0da;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  color: #1a1917;
  transition: border-color 0.12s, background 0.12s;
}
.mtk-chat-empty-example:hover { background: #edf5f0; border-color: #1d5c3a; }

/* ── Input ───────────────────────────────────────────────── */
.mtk-chat-input-wrap {
  border-top: 1px solid #e2e0da;
  padding: 10px 12px;
  background: #faf9f7;
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.mtk-chat-textarea {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  max-height: 140px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
  border: 1px solid #d0cec8;
  border-radius: 8px;
  background: #fff;
  color: #1a1917;
  resize: none;
  outline: none;
  overflow-y: hidden;
}
.mtk-chat-textarea.mtk-chat-textarea-overflow { overflow-y: auto; }
.mtk-chat-textarea:focus { border-color: #1d5c3a; }
.mtk-chat-textarea::placeholder { color: #9e9b96; }
.mtk-chat-send {
  background: #1d5c3a;
  color: #fff;
  border: none;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s;
}
.mtk-chat-send:hover:not(:disabled) { background: #174a2e; }
.mtk-chat-send:disabled { background: #d0cec8; cursor: not-allowed; }
.mtk-chat-send svg { width: 16px; height: 16px; }

/* ── Settings overlay ────────────────────────────────────── */
.mtk-chat-settings {
  position: absolute;
  inset: 0;
  background: #fff;
  z-index: 5;
  padding: 16px;
  display: none;
  flex-direction: column;
  gap: 12px;
}
.mtk-chat-settings.mtk-chat-open { display: flex; }
.mtk-chat-settings label { font-size: 12px; color: #6b6862; }
.mtk-chat-settings input {
  width: 100%; padding: 8px 10px; font-size: 13px;
  border: 1px solid #d0cec8; border-radius: 8px;
  font-family: 'JetBrains Mono', monospace;
}
.mtk-chat-settings input:focus { outline: none; border-color: #1d5c3a; }
.mtk-chat-settings .mtk-chat-help {
  font-size: 11px; color: #9e9b96; line-height: 1.5;
}
.mtk-chat-settings .mtk-chat-help a { color: #1d5c3a; }

/* ── Loading dots ────────────────────────────────────────── */
.mtk-chat-loading {
  align-self: flex-start;
  background: #f7f6f3;
  padding: 9px 14px;
  border-radius: 12px;
  display: inline-flex;
  gap: 4px;
}
.mtk-chat-loading span {
  width: 6px; height: 6px;
  background: #9e9b96;
  border-radius: 50%;
  animation: mtk-chat-dot 1.4s infinite;
}
.mtk-chat-loading span:nth-child(2) { animation-delay: 0.2s; }
.mtk-chat-loading span:nth-child(3) { animation-delay: 0.4s; }
@keyframes mtk-chat-dot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 640px) {
  .mtk-chat-panel {
    bottom: 0; right: 0; left: 0;
    width: 100%; max-width: none;
    border-radius: 14px 14px 0 0;
    height: 80vh;
  }
  .mtk-chat-fab { bottom: 16px; right: 16px; width: 48px; height: 48px; }
}
