/* ── EduBot AI – Public Styles ─────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&family=Poppins:wght@400;500;600&display=swap');

#edubot-wrapper {
  --eb-primary:    #4f46e5;
  --eb-primary-d:  #3730a3;
  --eb-primary-l:  #eef2ff;
  --eb-green:      #22c55e;
  --eb-red:        #ef4444;
  --eb-orange:     #f97316;
  --eb-bg:         #f8faff;
  --eb-card:       #ffffff;
  --eb-border:     #e2e8f0;
  --eb-text:       #1e293b;
  --eb-muted:      #64748b;
  --eb-radius:     14px;
  --eb-shadow:     0 4px 24px rgba(79,70,229,.10);

  font-family: 'Nunito', sans-serif;
  font-size: 15px;
  color: var(--eb-text);
  background: var(--eb-bg);
  border: 1px solid var(--eb-border);
  border-radius: var(--eb-radius);
  box-shadow: var(--eb-shadow);
  overflow: hidden;
  max-width: 100%;
}

/* ── Header ──────────────────────────────────────────────────── */
.eb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, var(--eb-primary) 0%, var(--eb-primary-d) 100%);
  padding: 14px 18px;
  color: #fff;
}
.eb-header-left { display: flex; align-items: center; gap: 12px; }
.eb-avatar-wrap { position: relative; }
.eb-avatar-wrap img { width: 44px; height: 44px; border-radius: 50%; border: 2px solid rgba(255,255,255,.5); background:#fff; object-fit:cover; }
.eb-online-dot { position:absolute; bottom:1px; right:1px; width:11px; height:11px; background:var(--eb-green); border-radius:50%; border:2px solid #fff; }
.eb-bot-name  { font-size:1.05rem; font-weight:800; letter-spacing:.3px; }
.eb-bot-sub   { font-size:.78rem; opacity:.8; }
.eb-stats-btn { background:rgba(255,255,255,.15); border:none; border-radius:8px; color:#fff; font-size:1.1rem; padding:7px 10px; cursor:pointer; transition:.2s; }
.eb-stats-btn:hover { background:rgba(255,255,255,.3); }

/* ── Chapter Bar ─────────────────────────────────────────────── */
.eb-chapter-bar {
  background: var(--eb-primary-l);
  border-bottom: 1px solid var(--eb-border);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: .88rem;
  font-weight: 700;
  color: var(--eb-primary-d);
}
.eb-selectors { display:flex; gap:8px; flex-wrap:wrap; }
.eb-chapter-bar select {
  border: 1.5px solid var(--eb-primary);
  border-radius: 8px;
  padding: 5px 10px;
  font-family: inherit;
  font-size: .85rem;
  background: #fff;
  color: var(--eb-text);
  cursor: pointer;
}
.eb-chapter-info { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }

/* ── Mode Bar ────────────────────────────────────────────────── */
.eb-mode-bar {
  padding: 16px 18px;
  background: var(--eb-card);
  border-bottom: 1px solid var(--eb-border);
}
.eb-mode-label { font-size:.82rem; font-weight:700; text-transform:uppercase; letter-spacing:.06em; color:var(--eb-muted); display:block; margin-bottom:10px; }
.eb-modes { display:flex; flex-wrap:wrap; gap:8px; }
.eb-mode-btn {
  background: var(--eb-primary-l);
  color: var(--eb-primary-d);
  border: 1.5px solid transparent;
  border-radius: 50px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
}
.eb-mode-btn:hover, .eb-mode-btn.active {
  background: var(--eb-primary);
  color: #fff;
  border-color: var(--eb-primary);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(79,70,229,.3);
}

/* ── Main ────────────────────────────────────────────────────── */
.eb-main { padding: 18px; min-height: 300px; }

/* ── Chips ───────────────────────────────────────────────────── */
.eb-chip {
  background: var(--eb-primary);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 5px 14px;
  font-family: inherit;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  transition: .2s;
}
.eb-chip:hover { background: var(--eb-primary-d); }
.eb-chip-change { background: rgba(79,70,229,.12); color: var(--eb-primary); }
.eb-btn-outline { background: transparent; color: var(--eb-primary); border: 2px solid var(--eb-primary); }
.eb-btn-outline:hover { background: var(--eb-primary-l); }

/* ── Start Btn ───────────────────────────────────────────────── */
.eb-start-btn {
  display: inline-block;
  background: var(--eb-primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 11px 26px;
  font-family: inherit;
  font-size: .95rem;
  font-weight: 800;
  cursor: pointer;
  margin-top: 16px;
  transition: all .2s;
}
.eb-start-btn:hover { background: var(--eb-primary-d); transform: translateY(-2px); box-shadow: 0 4px 14px rgba(79,70,229,.35); }

/* ── Form Row ────────────────────────────────────────────────── */
.eb-form-row { display:flex; align-items:center; gap:14px; margin-bottom:10px; }
.eb-form-row label { font-weight:700; min-width:160px; }
.eb-form-row select { border:1.5px solid var(--eb-border); border-radius:8px; padding:7px 12px; font-family:inherit; background:#fff; }

/* ── Loading ─────────────────────────────────────────────────── */
.eb-loading { text-align:center; padding:50px 20px; }
.eb-spinner { width:46px; height:46px; border:4px solid var(--eb-primary-l); border-top-color:var(--eb-primary); border-radius:50%; animation:eb-spin .8s linear infinite; margin:0 auto 14px; }
@keyframes eb-spin { to { transform: rotate(360deg); } }

/* ── Chat Panel ──────────────────────────────────────────────── */
.eb-chat-messages {
  min-height: 280px;
  max-height: 420px;
  overflow-y: auto;
  padding: 4px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.eb-msg { display:flex; gap:10px; align-items: flex-end; }
.eb-msg-bot .eb-msg-bubble {
  background: var(--eb-primary-l);
  color: var(--eb-text);
  border-radius: 18px 18px 18px 4px;
  padding: 11px 15px;
  max-width: 82%;
  line-height: 1.55;
  font-size: .9rem;
}
.eb-msg-user { justify-content: flex-end; }
.eb-msg-user .eb-msg-bubble {
  background: var(--eb-primary);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
  padding: 11px 15px;
  max-width: 82%;
  line-height: 1.55;
  font-size: .9rem;
}
.eb-msg-bubble p { margin: 0 0 6px; }
.eb-msg-bubble p:last-child { margin-bottom:0; }
.eb-msg-bubble ul { margin:4px 0; padding-left:18px; }
.eb-chat-input-wrap {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  border-top: 1px solid var(--eb-border);
  padding-top: 14px;
}
.eb-chat-input-wrap textarea {
  flex: 1;
  border: 1.5px solid var(--eb-border);
  border-radius: 10px;
  padding: 10px 13px;
  font-family: inherit;
  font-size: .9rem;
  resize: none;
  transition: border-color .2s;
}
.eb-chat-input-wrap textarea:focus { border-color: var(--eb-primary); outline: none; }
#eb-chat-send {
  background: var(--eb-primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  font-size: .88rem;
  transition: .2s;
  align-self: flex-end;
}
#eb-chat-send:hover { background: var(--eb-primary-d); }

/* ── MCQ Quiz ─────────────────────────────────────────────────  */
.eb-quiz-header { display:flex; align-items:center; gap:14px; margin-bottom:18px; }
.eb-progress-bar { flex:1; height:9px; background:var(--eb-primary-l); border-radius:99px; overflow:hidden; }
.eb-progress-fill { height:100%; background: linear-gradient(90deg, var(--eb-primary), #818cf8); border-radius:99px; transition: width .4s ease; }
.eb-quiz-counter { font-size:.85rem; font-weight:800; color:var(--eb-muted); white-space:nowrap; }

.eb-question-card {
  background: var(--eb-card);
  border: 1.5px solid var(--eb-border);
  border-radius: var(--eb-radius);
  padding: 22px;
  box-shadow: 0 2px 12px rgba(0,0,0,.04);
}
.eb-question-text { font-size: 1rem; font-weight: 700; line-height: 1.5; margin-bottom: 18px; }
.eb-options { display:flex; flex-direction:column; gap:10px; }
.eb-option {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--eb-bg);
  border: 2px solid var(--eb-border);
  border-radius: 10px;
  padding: 12px 16px;
  cursor: pointer;
  font-size: .92rem;
  font-weight: 600;
  transition: all .18s;
}
.eb-option:hover { border-color: var(--eb-primary); background: var(--eb-primary-l); }
.eb-option.correct { border-color: var(--eb-green); background: #f0fdf4; color: #166534; }
.eb-option.wrong   { border-color: var(--eb-red);   background: #fef2f2; color: #991b1b; }
.eb-option-key {
  width: 30px; height: 30px;
  background: var(--eb-primary-l);
  color: var(--eb-primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: .85rem;
  flex-shrink: 0;
}
.eb-option.correct .eb-option-key { background: var(--eb-green); color:#fff; }
.eb-option.wrong   .eb-option-key { background: var(--eb-red);   color:#fff; }

.eb-explanation {
  margin-top: 14px;
  background: #fffbeb;
  border: 1.5px solid #fde68a;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: .88rem;
  line-height: 1.5;
  color: #92400e;
}
.eb-next-btn {
  margin-top: 16px;
  background: var(--eb-primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 22px;
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
  font-size: .9rem;
  transition: .2s;
}
.eb-next-btn:hover { background: var(--eb-primary-d); }

/* Result */
.eb-result-panel { text-align: center; padding: 30px 20px; }
.eb-result-inner { max-width: 400px; margin: 0 auto; }
.eb-result-emoji { font-size: 3.5rem; margin-bottom: 10px; }
.eb-result-score { font-size: 2.2rem; font-weight: 800; color: var(--eb-primary); }
.eb-result-msg   { font-size: 1.05rem; color: var(--eb-muted); margin: 8px 0 18px; }
.eb-result-breakdown { text-align: left; background: var(--eb-bg); border: 1px solid var(--eb-border); border-radius: 10px; padding: 14px; margin-bottom: 14px; font-size: .88rem; }
.eb-result-breakdown .eb-rb-row { display:flex; justify-content:space-between; padding: 3px 0; }

/* ── Flashcards ──────────────────────────────────────────────── */
.eb-fc-nav { display:flex; align-items:center; justify-content:center; gap:18px; margin-bottom:16px; font-weight:700; }
.eb-fc-nav button {
  background: var(--eb-primary-l);
  color: var(--eb-primary);
  border: none;
  border-radius: 8px;
  width: 36px; height: 36px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: .2s;
}
.eb-fc-nav button:hover { background: var(--eb-primary); color:#fff; }

.eb-fc-card {
  perspective: 1000px;
  height: 200px;
  cursor: pointer;
  user-select: none;
}
.eb-fc-inner {
  position: relative;
  width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform .5s ease;
}
.eb-fc-inner.flipped { transform: rotateY(180deg); }
.eb-fc-front, .eb-fc-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--eb-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
}
.eb-fc-front { background: linear-gradient(135deg, var(--eb-primary), #818cf8); color: #fff; }
.eb-fc-back  { background: linear-gradient(135deg, #0ea5e9, #06b6d4); color: #fff; transform: rotateY(180deg); }
.eb-fc-hint  { text-align:center; font-size:.8rem; color:var(--eb-muted); margin: 10px 0; }
.eb-fc-actions { display:flex; gap:8px; justify-content:center; }

/* ── Fill Blanks ─────────────────────────────────────────────── */
.eb-fb-item {
  background: var(--eb-card);
  border: 1.5px solid var(--eb-border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
  font-size: .95rem;
}
.eb-fb-item .eb-fb-q { font-weight: 700; margin-bottom: 10px; }
.eb-fb-item input {
  border: 2px solid var(--eb-border);
  border-radius: 7px;
  padding: 6px 12px;
  font-family: inherit;
  font-size: .9rem;
  transition: .2s;
  width: 200px;
}
.eb-fb-item input:focus { border-color: var(--eb-primary); outline: none; }
.eb-fb-item.correct { border-color: var(--eb-green); }
.eb-fb-item.wrong   { border-color: var(--eb-red); }
.eb-fb-score { font-size:1.1rem; font-weight:800; padding:16px; background:var(--eb-primary-l); border-radius:10px; text-align:center; margin-top:14px; color:var(--eb-primary-d); }
.eb-fb-answer-reveal { margin-top:6px; font-size:.85rem; color: var(--eb-green); font-weight:700; }

/* ── Summary ─────────────────────────────────────────────────── */
.eb-sum-toolbar { display:flex; gap:8px; margin-bottom:14px; }
.eb-sum-content {
  background: var(--eb-card);
  border: 1.5px solid var(--eb-border);
  border-radius: var(--eb-radius);
  padding: 20px;
  font-size: .93rem;
  line-height: 1.7;
  white-space: pre-wrap;
}

/* ── Q&A ─────────────────────────────────────────────────────── */
.eb-qa-item {
  background: var(--eb-card);
  border: 1.5px solid var(--eb-border);
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
}
.eb-qa-question {
  padding: 14px 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.eb-qa-question:hover { background: var(--eb-primary-l); }
.eb-qa-answer {
  padding: 0 16px;
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s ease, padding .3s;
  font-size: .9rem;
  line-height: 1.6;
  color: var(--eb-muted);
  background: #fafafa;
}
.eb-qa-answer.open { max-height: 500px; padding: 14px 16px; }
.eb-qa-chevron { transition: transform .3s; }
.eb-qa-question.open .eb-qa-chevron { transform: rotate(180deg); }

/* ── Stats Modal ─────────────────────────────────────────────── */
.eb-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.eb-modal {
  background: #fff;
  border-radius: var(--eb-radius);
  max-width: 580px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.eb-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--eb-border);
}
.eb-modal-header h2 { margin:0; font-size: 1.1rem; }
.eb-modal-header button { background:none; border:none; font-size:1.2rem; cursor:pointer; color:var(--eb-muted); }
#eb-stats-content { padding: 18px 22px; }
.eb-stats-table { width:100%; border-collapse:collapse; font-size:.88rem; }
.eb-stats-table th { text-align:left; padding:8px 10px; background:var(--eb-bg); }
.eb-stats-table td { padding:8px 10px; border-top:1px solid var(--eb-border); }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 540px) {
  .eb-modes { gap: 6px; }
  .eb-mode-btn { padding: 7px 12px; font-size: .82rem; }
  .eb-question-card { padding: 16px; }
  .eb-form-row { flex-direction:column; align-items:flex-start; gap:6px; }
}
