/* ════════════════════════════════════════════════════════════════════
   AI Tutor — schoolclaude (brand: dark + gold, RTL)
   Replaces inline styles previously injected by js/ai-tutor-ui.js.
   ════════════════════════════════════════════════════════════════════ */

/* ── Floating Action Button ─────────────────────────────────────── */
.ai-tutor-fab {
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #E8A020 0%, #F5C040 100%);
  color: #050508;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(232, 160, 32, 0.45);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 200ms ease, box-shadow 200ms ease;
  -webkit-tap-highlight-color: transparent;
}
.ai-tutor-fab:hover {
  transform: scale(1.06);
  box-shadow: 0 8px 28px rgba(232, 160, 32, 0.6);
}
.ai-tutor-fab:active { transform: scale(0.94); }
.ai-tutor-fab.is-open { transform: rotate(180deg); }

/* ── Panel ──────────────────────────────────────────────────────── */
.ai-tutor-panel {
  position: fixed;
  bottom: 90px;
  left: 20px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 540px;
  max-height: 75vh;
  background: linear-gradient(180deg, #0A0515 0%, #050508 100%);
  color: #F0F0FF;
  border: 1px solid rgba(232, 160, 32, 0.25);
  border-radius: 18px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  font-family: 'Heebo', sans-serif;
}
.ai-tutor-panel.open { display: flex; animation: aiTutorSlideUp 280ms ease-out; }
@keyframes aiTutorSlideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Mobile + app-mode: full-screen panel ──────────────────────── */
@media (max-width: 600px) {
  .ai-tutor-panel.open {
    inset: 0;
    width: 100vw; height: 100vh; max-height: none;
    border-radius: 0;
    border: none;
  }
}
html[data-app-mode="true"] .ai-tutor-panel.open {
  inset: 0;
  width: 100vw; height: 100vh; max-height: none;
  border-radius: 0;
  border: none;
  padding-top: env(safe-area-inset-top, 0);
}

/* ── Header ─────────────────────────────────────────────────────── */
.ai-tutor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.1rem;
  background: linear-gradient(135deg, rgba(232, 160, 32, 0.18), rgba(232, 160, 32, 0.06));
  border-bottom: 1px solid rgba(232, 160, 32, 0.25);
  font-weight: 700;
  font-size: 0.95rem;
}
.ai-tutor-header__title {
  display: flex; align-items: center; gap: 0.5rem;
  background: linear-gradient(135deg, #F5C040, #E8A020);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.ai-tutor-header__icon {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #E8A020, #F5C040);
  font-size: 0.85rem;
  -webkit-text-fill-color: initial;
}
.ai-tutor-close {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #F0F0FF;
  font-size: 1.1rem;
  cursor: pointer;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: background 150ms ease;
}
.ai-tutor-close:hover { background: rgba(255, 255, 255, 0.12); }
.ai-tutor-close:active { transform: scale(0.92); }

/* ── Log (messages area) ───────────────────────────────────────── */
.ai-tutor-log {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background: transparent;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}
.ai-tutor-log::-webkit-scrollbar { width: 6px; }
.ai-tutor-log::-webkit-scrollbar-thumb {
  background: rgba(232, 160, 32, 0.25);
  border-radius: 3px;
}

.ai-tutor-msg {
  padding: 0.7rem 0.95rem;
  border-radius: 14px;
  max-width: 88%;
  font-size: 0.92rem;
  line-height: 1.55;
  word-break: break-word;
  hyphens: auto;
}
.ai-tutor-user {
  background: linear-gradient(135deg, #E8A020, #F5C040);
  color: #050508;
  align-self: flex-start;
  font-weight: 500;
  border-bottom-right-radius: 4px;
}
.ai-tutor-assistant {
  background: rgba(255, 255, 255, 0.06);
  color: #F0F0FF;
  border: 1px solid rgba(255, 255, 255, 0.1);
  align-self: flex-end;
  border-bottom-left-radius: 4px;
}
.ai-tutor-assistant.streaming::after {
  content: '▍';
  color: #F5C040;
  animation: aiTutorBlink 1s infinite;
  margin-inline-start: 2px;
}
.ai-tutor-assistant.error {
  color: #FCA5A5;
  background: rgba(220, 38, 38, 0.1);
  border-color: rgba(220, 38, 38, 0.3);
}
@keyframes aiTutorBlink { 0%, 100% { opacity: 1 } 50% { opacity: 0 } }

/* ── Markdown styling inside assistant messages ────────────────── */
.ai-tutor-assistant p { margin: 0 0 0.5rem; }
.ai-tutor-assistant p:last-child { margin: 0; }
.ai-tutor-assistant h1,
.ai-tutor-assistant h2,
.ai-tutor-assistant h3 {
  font-size: 1rem; font-weight: 700; margin: 0.65rem 0 0.4rem;
  color: #F5C040;
}
.ai-tutor-assistant ul,
.ai-tutor-assistant ol {
  margin: 0.35rem 0;
  padding-inline-start: 1.4rem;
}
.ai-tutor-assistant li { margin-bottom: 0.2rem; }
.ai-tutor-assistant code {
  background: rgba(0, 0, 0, 0.4);
  color: #F5C040;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 0.85em;
}
.ai-tutor-assistant pre {
  position: relative;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(232, 160, 32, 0.18);
  border-radius: 10px;
  padding: 2.2rem 0.85rem 0.75rem;
  margin: 0.5rem 0;
  overflow-x: auto;
  font-size: 0.85em;
  direction: ltr;
  text-align: left;
}
.ai-tutor-assistant pre code {
  background: transparent;
  color: #F0F0FF;
  padding: 0;
  font-size: 1em;
}
.ai-tutor-copy-btn {
  position: absolute;
  top: 6px; left: 6px;
  background: rgba(232, 160, 32, 0.15);
  color: #F5C040;
  border: 1px solid rgba(232, 160, 32, 0.3);
  border-radius: 6px;
  padding: 0.2rem 0.55rem;
  font-size: 0.7rem;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: background 150ms ease;
}
.ai-tutor-copy-btn:hover { background: rgba(232, 160, 32, 0.25); }
.ai-tutor-copy-btn.copied { background: rgba(34, 197, 94, 0.2); color: #4ADE80; border-color: rgba(34, 197, 94, 0.4); }

/* ── Welcome screen + prompt chips ─────────────────────────────── */
.ai-tutor-welcome {
  padding: 0.5rem 0.25rem;
  text-align: start;
  font-size: 0.93rem;
  line-height: 1.6;
  color: rgba(240, 240, 255, 0.85);
}
.ai-tutor-welcome strong { color: #F5C040; }
.ai-tutor-welcome ul {
  margin: 0.5rem 0 0.75rem;
  padding-inline-start: 1.4rem;
}
.ai-tutor-welcome li { margin-bottom: 0.25rem; }

.ai-tutor-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.5rem 0.25rem 0.25rem;
}
.ai-tutor-chip {
  background: rgba(232, 160, 32, 0.12);
  color: #F5C040;
  border: 1px solid rgba(232, 160, 32, 0.3);
  border-radius: 999px;
  padding: 0.5rem 0.85rem;
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: background 150ms ease, transform 100ms ease;
}
.ai-tutor-chip:hover { background: rgba(232, 160, 32, 0.2); }
.ai-tutor-chip:active { transform: scale(0.96); }

/* ── Form (input + send) ───────────────────────────────────────── */
.ai-tutor-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 0.85rem;
  border-top: 1px solid rgba(232, 160, 32, 0.18);
  background: rgba(0, 0, 0, 0.4);
  /* iPhone notch / Android nav */
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0));
}
.ai-tutor-input {
  flex: 1;
  resize: none;
  padding: 0.6rem 0.85rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  color: #F0F0FF;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.4;
  max-height: 96px;
  overflow-y: auto;
  transition: border-color 150ms ease;
}
.ai-tutor-input:focus {
  outline: none;
  border-color: rgba(232, 160, 32, 0.6);
}
.ai-tutor-input::placeholder { color: rgba(240, 240, 255, 0.4); }
.ai-tutor-send {
  background: linear-gradient(135deg, #E8A020, #F5C040);
  color: #050508;
  border: none;
  border-radius: 12px;
  padding: 0 1.05rem;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: transform 100ms ease, opacity 150ms ease;
  min-width: 52px;
}
.ai-tutor-send:active { transform: scale(0.94); }
.ai-tutor-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Reduced motion ────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .ai-tutor-panel.open { animation: none; }
  .ai-tutor-fab,
  .ai-tutor-chip,
  .ai-tutor-send,
  .ai-tutor-close { transition: none; }
  .ai-tutor-fab:active,
  .ai-tutor-chip:active,
  .ai-tutor-send:active,
  .ai-tutor-close:active { transform: none; }
}
