/* ═══════════════════════════════════════════════
   ai/css/ai.css  v1.6
   + marked.js markdown стили
   ═══════════════════════════════════════════════ */

/* ─── LANG TOGGLE ─── */
.lang-toggle-input { display: none; }

.lang-ru { display: none !important; }
.lang-kk { display: block; }
.ai-input.lang-ru { display: none !important; }
.ai-input.lang-kk { display: block; }

.lang-toggle-input:checked ~ .ai-page .lang-ru { display: block !important; }
.lang-toggle-input:checked ~ .ai-page .lang-kk { display: none !important; }
.lang-toggle-input:checked ~ .ai-page .ai-input.lang-kk { display: none !important; }
.lang-toggle-input:checked ~ .ai-page .ai-input.lang-ru { display: block !important; }

/* ─── LANG SWITCHER ─── */
.lang-switcher {
  position: absolute; top: 14px; right: 18px;
  display: flex; align-items: center; gap: 3px;
  cursor: pointer; user-select: none; z-index: 10;
}
.lang-btn {
  font-family: 'Montserrat', sans-serif;
  font-size: 11px; font-weight: 700;
  padding: 4px 11px; border-radius: 20px;
  letter-spacing: 0.5px; transition: background 0.2s, color 0.2s;
}
.lang-btn-kk { background: var(--green-dark); color: #fff; }
.lang-btn-ru { background: rgba(27,77,53,0.12); color: var(--green-dark); }
.lang-toggle-input:checked ~ .ai-page .lang-btn-kk { background: rgba(27,77,53,0.12); color: var(--green-dark); }
.lang-toggle-input:checked ~ .ai-page .lang-btn-ru { background: var(--green-dark); color: #fff; }

/* ─── BACK BUTTON ─── */
.ai-back-btn {
  position: absolute; top: 14px; left: 18px;
  display: flex; align-items: center; gap: 6px;
  font-family: 'Montserrat', sans-serif;
  font-size: 11px; font-weight: 700;
  color: var(--green-dark); background: rgba(27,77,53,0.10);
  border: none; border-radius: 20px; padding: 4px 13px 4px 10px;
  cursor: pointer; text-decoration: none;
  transition: background 0.2s, color 0.2s; z-index: 10;
}
.ai-back-btn:hover { background: var(--green-dark); color: #fff; }
.ai-back-btn i { font-size: 13px; }

/* ─── PAGE LAYOUT ─── */
html, body { height: 100%; overflow: hidden; }

.ai-page {
  height: 100vh; display: flex; flex-direction: column;
  font-family: 'Montserrat', sans-serif; overflow: hidden;
}

/* ─── HEADER ─── */
.ai-header {
  position: relative; flex-shrink: 0;
  background: linear-gradient(135deg, #e8f5ee 0%, #d4eedd 60%, #c2e4cc 100%);
  padding: 48px 24px 32px; text-align: center; overflow: hidden;
}
.ai-header::before {
  content: ''; position: absolute; top: -60px; left: -60px;
  width: 240px; height: 240px; border-radius: 50%;
  background: rgba(30,102,64,0.07);
}
.ai-header::after {
  content: ''; position: absolute; bottom: -40px; right: -40px;
  width: 180px; height: 180px; border-radius: 50%;
  background: rgba(30,102,64,0.06);
}
.ai-logo-name {
  font-size: 2.4rem; font-weight: 800; color: var(--green-dark);
  letter-spacing: -0.5px; margin-bottom: 10px; position: relative; z-index: 1;
}
.ai-subtitle {
  font-size: 14px; color: var(--green-mid); font-weight: 500;
  max-width: 520px; margin: 0 auto; line-height: 1.55; position: relative; z-index: 1;
}

/* ─── BODY ─── */
.ai-body {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  max-width: 860px; width: 100%; margin: 0 auto; padding: 0 16px;
}

/* ─── CHAT WINDOW ─── */
.ai-chat-window {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 24px 0 16px; display: flex; flex-direction: column; gap: 14px;
}

/* ─── CARDS ─── */
.ai-cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px; margin: 20px 0 28px;
}
.ai-card {
  background: var(--white); border-radius: 12px; padding: 24px 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.07); border: 1px solid #e8f0eb;
}
.ai-card-icon {
  width: 42px; height: 42px; background: #e8f5ee; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px; color: var(--green-mid); font-size: 20px;
}
.ai-card-title { font-size: 14px; font-weight: 700; color: var(--green-mid); margin-bottom: 8px; line-height: 1.3; }
.ai-card-desc  { font-size: 12px; color: var(--text-gray); line-height: 1.55; }

/* ─── MESSAGES ─── */
.msg { display: flex; gap: 10px; max-width: 82%; animation: msgIn 0.22s ease; }
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg.msg-user { align-self: flex-end; flex-direction: row-reverse; }

.msg-bubble {
  padding: 11px 16px; border-radius: 16px;
  font-size: 13px; line-height: 1.6; word-break: break-word;
}
/* пользователь — plain text */
.msg-user .msg-bubble {
  background: var(--green-mid); color: var(--white);
  border-bottom-right-radius: 4px; white-space: pre-wrap;
}
/* бот — markdown рендер */
.msg-bot .msg-bubble {
  background: var(--white); color: var(--text-dark);
  border: 1px solid #e0ebe5; border-bottom-left-radius: 4px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}

/* ─── MARKDOWN СТИЛИ внутри бабла бота ─── */
.msg-bot .msg-bubble p       { margin: 0 0 8px; }
.msg-bot .msg-bubble p:last-child { margin-bottom: 0; }
.msg-bot .msg-bubble strong  { font-weight: 700; color: var(--green-dark); }
.msg-bot .msg-bubble em      { font-style: italic; }
.msg-bot .msg-bubble ul,
.msg-bot .msg-bubble ol      { margin: 6px 0 8px 18px; padding: 0; }
.msg-bot .msg-bubble li      { margin-bottom: 3px; }
.msg-bot .msg-bubble h1,
.msg-bot .msg-bubble h2,
.msg-bot .msg-bubble h3      { font-size: 14px; font-weight: 700; margin: 8px 0 4px; color: var(--green-dark); }
.msg-bot .msg-bubble code    { background: #f0f5f2; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.msg-bot .msg-bubble a       { color: var(--green-mid); text-decoration: underline; }
.msg-bot .msg-bubble hr      { border: none; border-top: 1px solid #e0ebe5; margin: 8px 0; }

.msg-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--green-dark);
  display: flex; align-items: center; justify-content: center;
  color: var(--white); font-size: 14px; flex-shrink: 0; margin-top: 2px;
}
.msg-user .msg-avatar { background: var(--gold); }

/* ─── TYPING ─── */
.msg-typing {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px !important;
}
.typing-dots { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
.typing-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green-mid); opacity: 0.4; animation: dot 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot {
  0%, 60%, 100% { opacity: 0.4; transform: translateY(0); }
  30%           { opacity: 1;   transform: translateY(-4px); }
}
.typing-text {
  font-size: 12px; color: var(--text-gray); font-style: italic;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ─── ERROR ─── */
.msg-error .msg-bubble { background: #fdecea; border-color: #f5c6c3; color: #c0392b; }

/* ─── INPUT BAR ─── */
.ai-input-bar {
  flex-shrink: 0; background: #f7faf8;
  padding: 12px 0 20px; border-top: 1px solid #e4ede8;
}
.ai-input-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.ai-input-wrap {
  flex: 1; display: flex; align-items: center; gap: 10px;
  background: var(--white); border: 1.5px solid #d0e4d9; border-radius: 50px;
  padding: 8px 8px 8px 20px; box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.ai-input-wrap:focus-within { border-color: var(--green-mid); box-shadow: 0 2px 16px rgba(30,102,64,0.12); }

.ai-input {
  flex: 1; border: none; outline: none;
  font-family: 'Montserrat', sans-serif; font-size: 13px; color: var(--text-dark);
  background: transparent; resize: none; line-height: 1.5; max-height: 120px; overflow-y: auto;
}
.ai-input::placeholder { color: #aac1b0; }

.ai-send-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--green-mid); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--white); font-size: 15px; flex-shrink: 0;
  transition: background 0.2s, transform 0.2s;
}
.ai-send-btn:hover    { background: var(--green-dark); transform: scale(1.06); }
.ai-send-btn:disabled { background: #b0c8b8; cursor: not-allowed; transform: none; }

/* ─── CLEAR BUTTON ─── */
.ai-clear-btn {
  flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%;
  background: rgba(27,77,53,0.08); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--green-dark); font-size: 15px;
  transition: background 0.2s, color 0.2s;
}
.ai-clear-btn:hover { background: #fdecea; color: #c0392b; }

/* ─── DISCLAIMER ─── */
.ai-disclaimer { text-align: center; font-size: 11px; color: #a0b8a8; padding: 0; margin: 0; }

/* ─── RESPONSIVE ─── */
@media (max-width: 600px) {
  .ai-logo-name { font-size: 2rem; }
  .ai-cards { grid-template-columns: 1fr; }
  .msg { max-width: 94%; }
  .lang-switcher { top: 10px; right: 12px; }
  .ai-back-btn { top: 10px; left: 12px; font-size: 10px; padding: 4px 10px 4px 8px; }
  .typing-text { display: none; }
}
