/*
 * ai_voice_tutor.css
 * ────────────────────
 * Aryzor Voice-First AI Teacher — Pass 1 widget styles.
 *
 * The widget is only ever mounted into the DOM (see ai_voice_tutor.js's
 * _buildDom()) when the server confirms AI_VOICE_TUTOR_ENABLED is on, so
 * these rules never affect any page for a student on a build with the
 * flag off.
 */

.avt-fab {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: #6366f1;
  color: #fff;
  font-size: 24px;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.45);
  cursor: pointer;
  z-index: 9990;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.avt-fab:hover  { transform: scale(1.06); }
.avt-fab:active { transform: scale(0.96); }
.avt-fab[data-state="listening"]  { box-shadow: 0 0 0 6px rgba(99, 102, 241, 0.25), 0 4px 14px rgba(99,102,241,0.45); }
.avt-fab[data-state="speaking"]   { background: #10b981; }
.avt-fab[data-state="error"]      { background: #ef4444; }
.avt-fab[data-state="connecting"],
.avt-fab[data-state="requesting_microphone"] { opacity: 0.75; }

.avt-panel {
  position: fixed;
  right: 16px;
  bottom: 84px;
  width: 340px;
  max-width: calc(100vw - 32px);
  max-height: 70vh;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.22);
  z-index: 9991;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
}

/* Collapsed while the whiteboard is the focus of the lesson (set by
   ai_teacher_whiteboard.js's show()/hide()). The session stays fully
   connected and every control stays reachable — the panel just shrinks to
   a compact strip in the corner instead of competing with the board for
   attention, the way a teacher stands beside the board rather than in
   front of it. The transcript log is the one thing hidden outright (the
   board's own narration line replaces it while teaching). */
.avt-panel[data-board-open="true"] {
  /* A single compact strip, pinned into the gutter the board reserves at
     the bottom of the screen (see .atw-board's max-height calc). It must
     stay SHORT — an earlier version kept the full stacked button grid
     here and grew tall enough to cover the board's own "Close board"
     button, stranding the student. */
  width: auto;
  max-width: calc(100vw - 32px);
  max-height: none;
  bottom: 8px;
  flex-direction: row;
  align-items: center;
}
.avt-panel[data-board-open="true"] .avt-mic-indicator,
.avt-panel[data-board-open="true"] .avt-transcript,
.avt-panel[data-board-open="true"] .avt-error {
  display: none !important;
}
.avt-panel[data-board-open="true"] .avt-panel-header {
  border-bottom: none;
  border-right: 1px solid #e5e7eb;
  padding: 8px 10px;
  background: transparent;
}
.avt-panel[data-board-open="true"] .avt-controls {
  padding: 6px 8px;
  gap: 4px;
  border-top: none;
  flex-wrap: nowrap;
  background: transparent;
}
.avt-panel[data-board-open="true"] .avt-ctrl-btn {
  flex: 0 0 auto;
  font-size: 11px;
  min-height: 30px;
  padding: 5px 8px;
}

.avt-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
}
.avt-title { font-weight: 700; color: #1e293b; font-size: 14px; }
.avt-ai-badge {
  font-size: 10px;
  font-weight: 700;
  background: #6366f1;
  color: #fff;
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 4px;
}
.avt-status-pill {
  margin-left: auto;
  font-size: 11px;
  color: #475569;
  background: #eef2ff;
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}
.avt-close-btn {
  border: none;
  background: transparent;
  font-size: 16px;
  cursor: pointer;
  color: #64748b;
  line-height: 1;
  padding: 4px 6px;
}
.avt-close-btn:hover { color: #1e293b; }

.avt-mic-indicator {
  height: 3px;
  width: 100%;
  background: #e5e7eb;
}
.avt-mic-indicator[data-active="true"] {
  background: linear-gradient(90deg, #6366f1, #10b981);
}

.avt-transcript {
  flex: 1;
  min-height: 80px;
  max-height: 240px;
  overflow-y: auto;
  padding: 10px 14px;
  font-size: 13px;
  color: #334155;
  line-height: 1.5;
}
.avt-transcript-line { margin-bottom: 8px; }
.avt-transcript-student { color: #1e293b; font-weight: 600; }
.avt-transcript-assistant { color: #4338ca; }

.avt-error {
  margin: 0 14px 8px;
  padding: 8px 10px;
  background: #fef2f2;
  color: #b91c1c;
  border-radius: 8px;
  font-size: 12px;
}

.avt-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid #e5e7eb;
  background: #fafafa;
}
.avt-ctrl-btn {
  flex: 1 1 45%;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #334155;
  border-radius: 10px;
  padding: 8px 6px;
  font-size: 12px;
  cursor: pointer;
  min-height: 40px;
}
/* Spoken-language picker — sits in the control row alongside the buttons. */
.avt-lang-wrap {
  flex: 1 1 45%;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 10px;
  padding: 4px 8px;
  min-height: 40px;
  box-sizing: border-box;
}
.avt-lang-label { font-size: 11px; color: #64748b; white-space: nowrap; }
.avt-lang-select {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 12px;
  color: #334155;
  cursor: pointer;
}
.avt-lang-select:focus-visible { outline: 2px solid #6366f1; outline-offset: 1px; }
/* Hidden while the whiteboard is teaching — the collapsed strip is for
   in-lesson controls only, and language cannot change mid-session anyway. */
.avt-panel[data-board-open="true"] .avt-lang-wrap { display: none; }

.avt-ctrl-btn:hover { background: #f1f5f9; }
.avt-ctrl-btn:active { transform: scale(0.97); }
.avt-ctrl-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  background: #fff;
}
.avt-ctrl-btn:disabled:hover { background: #fff; }

/* "End tutor" is the destructive/final action — distinct from the other
   three (mute, stop speaking, repeat), which all leave the session live. */
.avt-ctrl-btn-end {
  border-color: #fecaca;
  color: #b91c1c;
  background: #fff5f5;
}
.avt-ctrl-btn-end:hover { background: #fee2e2; }

/* ── Mobile (~375px and below) ──────────────────────────────────────────
   Widget must never cover the answer input/submit controls, stay usable,
   and never trigger horizontal scroll or the on-screen keyboard (there is
   no text input in this widget). */
@media (max-width: 480px) {
  .avt-fab {
    right: 12px;
    bottom: 12px;
    width: 50px;
    height: 50px;
    font-size: 20px;
  }
  .avt-panel {
    left: 8px;
    right: 8px;
    bottom: 72px;
    width: auto;
    max-width: calc(100vw - 16px);
    max-height: 60vh;
  }
  /* The board goes genuinely fullscreen on phones (see
     ai_teacher_whiteboard.css), so there is no gutter left to dock the
     collapsed panel into — it hides outright while teaching rather than
     floating on top of the board and stealing its controls' clicks. The
     session stays fully connected the whole time; closing the board
     (Close board / Esc / backdrop) brings the panel straight back. */
  .avt-panel[data-board-open="true"] {
    /* !important is load-bearing here, not decoration: _onFabClick sets
       panel.style.display = 'block' as an INLINE style, which would
       otherwise always beat this rule and leave the panel floating over
       the fullscreen board — swallowing the clicks on the board's own
       "Close board" button and stranding the student. */
    display: none !important;
  }
}