/* ============================================================
   Talk Show AI Tutor — Chat widget UI
   Matches the dark glass theme from slides.css
   ============================================================ */

:root {
  --tsc-bg: rgba(10, 10, 26, 0.88);
  --tsc-card: rgba(255, 255, 255, 0.06);
  --tsc-border: rgba(255, 255, 255, 0.12);
  --tsc-border-bright: rgba(255, 255, 255, 0.22);
  --tsc-text: #f1f5f9;
  --tsc-text2: #cbd5e1;
  --tsc-text3: #94a3b8;
  --tsc-text4: #64748b;
  --tsc-indigo: #6366f1;
  --tsc-cyan: #06b6d4;
  --tsc-grad: linear-gradient(135deg, #6366f1, #06b6d4);
  --tsc-grad2: linear-gradient(135deg, #8b5cf6, #ec4899);
  --tsc-glow: rgba(99, 102, 241, 0.35);
}

/* ============================
   FLOATING BUTTON
   ============================ */
.ts-chat-btn {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 2000;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1px solid rgba(99, 102, 241, 0.4);
  background: var(--tsc-grad);
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 32px var(--tsc-glow), 0 0 0 1px rgba(255,255,255,0.06) inset;
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.25s;
}

.ts-chat-btn:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 14px 40px rgba(99,102,241,0.5), 0 0 0 1px rgba(255,255,255,0.1) inset;
}

.ts-chat-btn::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: var(--tsc-grad);
  opacity: 0.5;
  filter: blur(14px);
  z-index: -1;
  animation: tscPulse 2.5s ease-in-out infinite;
}

@keyframes tscPulse {
  0%, 100% { opacity: 0.35; transform: scale(1); }
  50%      { opacity: 0.6;  transform: scale(1.08); }
}

.ts-chat-btn[data-open="true"] { display: none; }

/* ============================
   PANEL
   ============================ */
.ts-panel {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2001;
  width: min(420px, calc(100vw - 40px));
  height: min(640px, calc(100vh - 40px));
  background: var(--tsc-bg);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid var(--tsc-border-bright);
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255,255,255,0.04) inset;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Inter', -apple-system, sans-serif;
  color: var(--tsc-text);
}

.ts-panel[data-open="true"] { display: flex; animation: tscSlideUp 0.32s cubic-bezier(0.22, 1, 0.36, 1); }

@keyframes tscSlideUp {
  from { transform: translateY(20px) scale(0.96); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

/* ============================
   HEADER
   ============================ */
.ts-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--tsc-border);
  background: linear-gradient(180deg, rgba(99,102,241,0.08), transparent);
  flex-shrink: 0;
}

.ts-head .avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--tsc-grad);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  color: #fff;
  box-shadow: 0 4px 12px var(--tsc-glow);
  flex-shrink: 0;
}

.ts-head .meta { flex: 1; min-width: 0; }
.ts-head .title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--tsc-text);
  line-height: 1.1;
}
.ts-head .sub {
  font-size: 0.72rem;
  color: var(--tsc-text3);
  margin-top: 2px;
  display: flex; align-items: center; gap: 6px;
}
.ts-head .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px rgba(16,185,129,0.6);
  animation: tscPulse 2s ease-in-out infinite;
}

.ts-head .close {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--tsc-border);
  color: var(--tsc-text3);
  cursor: pointer;
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, color 0.2s;
}
.ts-head .close:hover { background: rgba(255,255,255,0.12); color: var(--tsc-text); }

/* ============================
   MESSAGES AREA
   ============================ */
.ts-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.ts-messages::-webkit-scrollbar { width: 6px; }
.ts-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 6px; }

.ts-msg {
  max-width: 92%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.55;
  word-wrap: break-word;
}

.ts-msg.bot {
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.22);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  color: var(--tsc-text);
}

.ts-msg.user {
  background: rgba(6, 182, 212, 0.15);
  border: 1px solid rgba(6, 182, 212, 0.3);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  color: var(--tsc-text);
}

.ts-msg.error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  align-self: stretch;
  color: #fca5a5;
  font-size: 0.82rem;
}

.ts-msg p { margin: 0 0 0.6em; }
.ts-msg p:last-child { margin-bottom: 0; }
.ts-msg strong { color: var(--tsc-text); font-weight: 700; }
.ts-msg em { color: var(--tsc-text2); font-style: italic; }
.ts-msg code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.84em;
  background: rgba(255,255,255,0.08);
  padding: 1px 6px;
  border-radius: 4px;
  color: #c4b5fd;
}
.ts-msg pre {
  background: #0d1117;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 8px 0;
  overflow-x: auto;
  font-size: 0.82em;
  line-height: 1.55;
}
.ts-msg pre code {
  background: transparent;
  padding: 0;
  color: #e2e8f0;
}
.ts-msg blockquote {
  border-left: 3px solid var(--tsc-cyan);
  padding-left: 10px;
  margin: 6px 0;
  color: var(--tsc-text2);
  font-style: italic;
}
.ts-msg ul, .ts-msg ol { margin: 4px 0 4px 18px; padding: 0; }
.ts-msg li { margin-bottom: 3px; }
.ts-msg a { color: #a5b4fc; text-decoration: underline; text-decoration-color: rgba(165,180,252,0.4); }

/* Typing indicator */
.ts-typing {
  display: inline-flex; gap: 4px; align-items: center; padding: 4px 6px;
}
.ts-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--tsc-indigo);
  animation: tscBlink 1.4s ease-in-out infinite;
}
.ts-typing span:nth-child(2) { animation-delay: 0.2s; }
.ts-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes tscBlink {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40%           { opacity: 1;   transform: scale(1.1); }
}

/* ============================
   QUICK PROMPTS
   ============================ */
.ts-quicks {
  padding: 0 16px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
}
.ts-quicks .label {
  width: 100%;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--tsc-text4);
  text-transform: uppercase;
  margin-bottom: 2px;
}
.ts-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--tsc-border);
  color: var(--tsc-text2);
  font-size: 0.74rem;
  font-family: inherit;
  padding: 6px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1.3;
}
.ts-chip:hover {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.35);
  color: var(--tsc-text);
}

/* ============================
   INPUT AREA
   ============================ */
.ts-input-wrap {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--tsc-border);
  background: rgba(0,0,0,0.18);
  flex-shrink: 0;
}

.ts-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--tsc-border);
  border-radius: 12px;
  padding: 6px 6px 6px 12px;
  transition: border-color 0.2s;
}
.ts-input-row:focus-within {
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

.ts-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--tsc-text);
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.45;
  resize: none;
  outline: none;
  max-height: 120px;
  min-height: 22px;
  padding: 6px 0;
}
.ts-input::placeholder { color: var(--tsc-text4); }

.ts-send {
  width: 34px; height: 34px;
  border-radius: 9px;
  border: none;
  background: var(--tsc-grad);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.2s, transform 0.2s;
  flex-shrink: 0;
}
.ts-send:hover { transform: translateY(-1px); }
.ts-send:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.ts-hint {
  font-size: 0.68rem;
  color: var(--tsc-text4);
  margin-top: 6px;
  display: flex; justify-content: space-between; align-items: center;
}
.ts-hint kbd {
  font-family: 'JetBrains Mono', monospace;
  background: rgba(255,255,255,0.08);
  padding: 0 5px;
  border-radius: 3px;
  font-size: 0.7em;
}
.ts-hint .reset {
  background: none;
  border: none;
  color: var(--tsc-text4);
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(148,163,184,0.3);
}
.ts-hint .reset:hover { color: var(--tsc-text2); }

/* ============================
   MOBILE
   ============================ */
@media (max-width: 600px) {
  .ts-chat-btn { width: 52px; height: 52px; bottom: 16px; right: 16px; }
  .ts-panel { width: calc(100vw - 16px); right: 8px; bottom: 8px; height: calc(100vh - 16px); }
}
