/* ════ AI TEACHER ════ */
.ai-teacher-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: linear-gradient(135deg, rgba(124,91,248,.18), rgba(73,54,232,.12));
  border: 1.5px solid rgba(124,91,248,.35);
  border-radius: 20px;
  padding: 14px 16px;
  cursor: pointer;
  margin: 4px 0 8px;
  text-align: right;
  font-family: inherit;
  transition: transform .18s var(--spring), box-shadow .18s;
  box-shadow: 0 4px 20px rgba(124,91,248,.15);
}
.ai-teacher-btn:active { transform: scale(0.97); }
.ai-teacher-fox {
  width: 54px;
  height: 54px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 8px rgba(108,79,246,0.25));
}
.ai-teacher-btn-body { flex: 1; text-align: right; }
.ai-teacher-btn-title {
  font-size: 15px; font-weight: 800;
  color: var(--text); direction: rtl;
  background: linear-gradient(135deg, #a78bfa, #818cf8);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.ai-teacher-btn-sub {
  font-size: 12px; color: var(--text-soft);
  direction: rtl; margin-top: 2px;
}

/* Chat Modal Sheet */
.ai-chat-sheet {
  background: var(--surface);
  border-radius: 28px 28px 0 0;
  padding: 0 0 env(safe-area-inset-bottom);
  display: flex;
  flex-direction: column;
  max-height: 78vh;
  width: 100%;
  box-shadow: 0 -8px 40px rgba(0,0,0,.35);
  border-top: 1px solid rgba(124,91,248,.25);
}
.ai-chat-fox-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1.5px solid rgba(124,91,248,.4);
  box-shadow: 0 2px 6px rgba(108,79,246,0.22);
  background: linear-gradient(135deg, #7c5bf8, #4936e8);
}

/* Header: title pill on the right (RTL), action buttons on the left.
   direction:rtl on the header places the first child (title) at the
   visual right and the second child (actions) at the visual left,
   matching natural Hebrew reading order. */
.ai-chat-header {
  display: flex;
  direction: rtl;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid rgba(124,91,248,0.12);
  margin: 0;
}
.ai-chat-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;                      /* allow text to truncate cleanly */
  flex: 1;
}
.ai-chat-title-text {
  font-size: 16px;
  font-weight: 900;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: linear-gradient(135deg, #6c4ef6, #b966ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  min-width: 0;
}

/* Messages area */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  min-height: 200px;
  max-height: 48vh;
}
.ai-bubble {
  max-width: 82%;
  border-radius: 18px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  direction: rtl;
  animation: bubble-in .22s var(--spring) both;
}
@keyframes bubble-in {
  from { opacity: 0; transform: translateY(8px) scale(.95); }
  to   { opacity: 1; transform: none; }
}
.ai-bubble-foxy {
  background: linear-gradient(135deg, rgba(124,91,248,.22), rgba(73,54,232,.15));
  border: 1px solid rgba(124,91,248,.3);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  color: var(--text);
}
.ai-bubble-user {
  background: linear-gradient(135deg, #7c5bf8, #4936e8);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  color: #fff;
}
.ai-bubble-text { font-weight: 600; }

.ai-speak-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: rgba(124,91,248,.15);
  border: 1px solid rgba(124,91,248,.3);
  color: #a78bfa;
  cursor: pointer;
  padding: 0;
  margin-top: 6px;
  transition: background .15s, transform .15s;
  flex-shrink: 0;
}
.ai-speak-btn:active { transform: scale(0.88); background: rgba(124,91,248,.35); }
.ai-speak-btn svg { width: 13px; height: 13px; }

/* Thinking animation */
.ai-thinking {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 2px;
}
.ai-thinking span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #7c5bf8;
  animation: dot-bounce .9s ease-in-out infinite;
}
.ai-thinking span:nth-child(2) { animation-delay: .15s; }
.ai-thinking span:nth-child(3) { animation-delay: .30s; }
@keyframes dot-bounce {
  0%, 80%, 100% { transform: scale(.7); opacity: .5; }
  40%           { transform: scale(1);  opacity: 1; }
}

/* History controls */
.ai-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ai-chat-clear-btn {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.25);
  color: #f87171;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background .15s, transform .15s var(--spring);
}
.ai-chat-clear-btn:active { transform: scale(0.88); background: rgba(239,68,68,.28); }
.ai-chat-clear-btn svg { width: 15px; height: 15px; }
.ai-bubble.no-anim { animation: none; }

/* Rate counter */
.ai-rate-counter {
  text-align: center;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-soft);
  padding: 5px 16px 2px;
  direction: rtl;
  min-height: 18px;
  transition: color .2s;
}
.ai-rate-counter--low   { color: #f59e0b; }
.ai-rate-counter--empty { color: #f87171; font-size: 13px; padding: 8px 16px; }

/* Input row */
.ai-chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px 14px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.ai-chat-input {
  flex: 1;
  background: rgba(255,255,255,.07);
  border: 1.5px solid rgba(124,91,248,.3);
  border-radius: 14px;
  padding: 11px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  font-weight: 600;
  outline: none;
  direction: rtl;
  transition: border-color .18s;
  min-height: 44px;
}
.ai-chat-input:focus { border-color: #7c5bf8; }
.ai-chat-input::placeholder { color: var(--text-soft); font-weight: 400; }
.ai-chat-send-btn {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #7c5bf8, #4936e8);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform .15s var(--spring), opacity .15s;
  box-shadow: 0 4px 14px rgba(124,91,248,.4);
}
.ai-chat-send-btn:active  { transform: scale(0.92); }
.ai-chat-send-btn:disabled { opacity: .45; pointer-events: none; }

