/* ============================================================
   Edutec AI — floating chat widget
   Sits on top of the simulation canvas.
   Visual language matched to the Edutec AI reference UI:
   breathing FAB, pulsing online dot, bordered message bubbles,
   deep-green gradient header, pill quick-action chips.
   All original selectors/IDs preserved — edutec-chat.js relies on them.
   ============================================================ */

:root {
  --edu-green-dark: #2e6347;
  --edu-green-mid: #4d8f66;
  --edu-green-light: #5be89a;
  --edu-bubble-user: #4d8f66;
  --edu-bubble-ai: #e8f2ec;
  --edu-text: #1a3d2e;
  --edu-muted: #6a8a78;
  --edu-border: #e2ece6;
}

#edutecWidgetRoot {
  position: fixed;
  z-index: 10000;
  right: 30px;
  bottom: 30px;
  font-family: 'Segoe UI', Arial, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

/* ── Toggle / launcher button ─────────────────────────────── */
.edu-toggle-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.9);
  cursor: pointer;
  background: linear-gradient(135deg, var(--edu-green-mid) 0%, var(--edu-green-dark) 100%);
  box-shadow: 0 8px 32px rgba(46, 99, 71, 0.35);
  color: #fff;
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  position: relative;
  animation: edu-breathe 3s ease-in-out infinite;
}
.edu-toggle-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 40px rgba(46, 99, 71, 0.5);
  animation-play-state: paused;
}
.edu-toggle-btn:active { transform: scale(1.02); }

@keyframes edu-breathe {
  0%, 100% { transform: scale(1); box-shadow: 0 8px 32px rgba(46, 99, 71, 0.3); }
  50%      { transform: scale(1.05); box-shadow: 0 8px 48px rgba(46, 99, 71, 0.55); }
}

/* Pulsing ring around the FAB */
.edu-toggle-btn::before {
  content: '';
  position: absolute;
  top: -6px; left: -6px; right: -6px; bottom: -6px;
  border-radius: 50%;
  border: 2px solid rgba(77, 143, 102, 0.35);
  animation: edu-ring-pulse 2s ease-out infinite;
  pointer-events: none;
}
@keyframes edu-ring-pulse {
  0%   { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.25); opacity: 0; }
}

/* Online status dot on the FAB */
.edu-toggle-btn::after {
  content: '';
  position: absolute;
  bottom: 3px; left: 3px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--edu-green-light);
  border: 2px solid #fff;
  animation: edu-status-pulse 2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes edu-status-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(91, 232, 154, 0.45); }
  50%      { transform: scale(1.12); box-shadow: 0 0 0 7px rgba(91, 232, 154, 0); }
}

.edu-toggle-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 19px;
  height: 19px;
  padding: 0 4px;
  border-radius: 10px;
  background: #e8425a;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  z-index: 1;
}
.edu-toggle-badge.hidden { display: none; }

/* ── Low-friction "stuck?" nudge bubble ───────────────────── */
.edu-nudge {
  max-width: 260px;
  background: #ffffff;
  border-left: 4px solid var(--edu-green-mid);
  border-radius: 16px;
  padding: 12px 16px;
  font-size: 12.5px;
  color: var(--edu-text);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  animation: edu-pop-in 0.4s ease;
}
.edu-nudge.hidden { display: none; }
.edu-nudge strong { color: var(--edu-green-dark); }
.edu-nudge .edu-nudge-dismiss {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--edu-muted);
  text-decoration: underline;
}

@keyframes edu-pop-in {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Chat panel ────────────────────────────────────────────── */
.edu-panel {
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 500px;
  max-height: calc(100vh - 110px);
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(77, 143, 102, 0.15);
  animation: edu-pop-in 0.35s ease;
}
.edu-panel.hidden { display: none; }

.edu-panel-header {
  background: linear-gradient(135deg, var(--edu-green-mid), var(--edu-green-dark));
  color: #fff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.edu-panel-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.35);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.edu-panel-titles { flex: 1; min-width: 0; }
.edu-panel-name { font-size: 14.5px; font-weight: 700; line-height: 1.3; }
.edu-panel-sub {
  font-size: 10.5px; opacity: 0.9; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 5px;
}
.edu-panel-sub::before {
  content: '';
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--edu-green-light);
  display: inline-block;
  animation: edu-status-pulse 2s ease-in-out infinite;
}
.edu-panel-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.edu-panel-download,
.edu-panel-close {
  background: rgba(255, 255, 255, 0.15);
  border: none; color: #fff; font-size: 15px;
  cursor: pointer; width: 30px; height: 30px; border-radius: 50%;
  transition: all 0.25s ease;
  display: flex; align-items: center; justify-content: center;
}
.edu-panel-download:hover { background: rgba(255, 255, 255, 0.32); transform: translateY(-1px); }
.edu-panel-close:hover { background: rgba(232, 66, 90, 0.5); transform: rotate(90deg); }

/* ── Message log ───────────────────────────────────────────── */
.edu-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8faf9;
}
.edu-log::-webkit-scrollbar { width: 5px; }
.edu-log::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 10px; }
.edu-log::-webkit-scrollbar-thumb { background: var(--edu-green-mid); border-radius: 10px; }

.edu-msg {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.edu-msg.ai {
  align-self: flex-start;
  background: var(--edu-bubble-ai);
  color: var(--edu-text);
  border-bottom-left-radius: 4px;
  border-left: 4px solid var(--edu-green-mid);
}
.edu-msg.user {
  align-self: flex-end;
  background: var(--edu-bubble-user);
  color: #fff;
  border-bottom-right-radius: 4px;
  border-right: 4px solid var(--edu-green-dark);
}
.edu-msg.system {
  align-self: center;
  background: transparent;
  color: var(--edu-muted);
  font-size: 11px;
  font-style: italic;
}
.edu-msg.error {
  align-self: flex-start;
  background: #fdeceb;
  color: #a03a2a;
  border-bottom-left-radius: 4px;
  border-left: 4px solid #e8425a;
}

/* ── Typing / loading indicator ───────────────────────────── */
.edu-typing {
  align-self: flex-start;
  display: flex;
  gap: 5px;
  padding: 12px 14px;
  background: var(--edu-bubble-ai);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  border-left: 4px solid var(--edu-green-mid);
}
.edu-typing span {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--edu-green-mid);
  animation: edu-typing-dot 1.4s ease-in-out infinite;
}
.edu-typing span:nth-child(2) { animation-delay: 0.2s; }
.edu-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes edu-typing-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-8px); opacity: 1; }
}

/* ── Input row ─────────────────────────────────────────────── */
.edu-input-row {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--edu-border);
  background: #fff;
}
.edu-input {
  flex: 1;
  border: 2px solid var(--edu-border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  min-width: 0;
  transition: border-color 0.25s ease;
}
.edu-input:focus { border-color: var(--edu-green-mid); }
.edu-input::placeholder { color: #aab9b2; }

.edu-send-btn {
  width: 42px; height: 42px; border-radius: 12px;
  border: none; background: var(--edu-green-mid); color: #fff;
  font-size: 15px; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.25s ease, transform 0.15s ease;
}
.edu-send-btn:hover { background: var(--edu-green-dark); }
.edu-send-btn:active { transform: scale(0.94); }
.edu-send-btn:disabled { background: #aab9b2; opacity: 0.7; cursor: not-allowed; }

.edu-hint-row {
  padding: 8px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: #f8faf9;
  border-top: 1px solid rgba(0, 0, 0, 0.03);
}
.edu-hint-chip {
  border: 1px solid rgba(77, 143, 102, 0.3);
  background: #ffffff;
  color: var(--edu-green-dark);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 13px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.edu-hint-chip:hover {
  background: var(--edu-green-mid);
  color: #fff;
  border-color: var(--edu-green-mid);
  transform: scale(1.04);
}

.ai-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

@media (max-width: 480px) {
  #edutecWidgetRoot { right: 14px; bottom: 14px; }
  .edu-toggle-btn { width: 56px; height: 56px; }
  .edu-panel { width: calc(100vw - 24px); height: calc(100vh - 100px); }
}
