/* ═══════════════════════════════════════════════════════════
   DecodeIIT — Science-Based Learning Features
   Gamma music, Pomodoro, Immersive mode, Study planner,
   Teach-back, AI assistant, Flashcards, Quotes
   ═══════════════════════════════════════════════════════════ */

/* ─── Gamma 40Hz Music Player Bar ─── */
.gamma-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 48px;
  background: linear-gradient(90deg, #1a1a2e 0%, #16213e 100%);
  border-top: 1px solid var(--yellow);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 900;
  padding: 0 1.5rem;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: var(--sans);
}
.gamma-bar.visible { transform: translateY(0); }
.gamma-bar .gamma-wave {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 24px;
}
.gamma-bar .gamma-wave span {
  width: 3px;
  background: var(--yellow);
  border-radius: 2px;
  animation: gammaWave 0.6s ease-in-out infinite alternate;
}
.gamma-bar .gamma-wave span:nth-child(1) { height: 8px; animation-delay: 0s; }
.gamma-bar .gamma-wave span:nth-child(2) { height: 16px; animation-delay: 0.1s; }
.gamma-bar .gamma-wave span:nth-child(3) { height: 24px; animation-delay: 0.2s; }
.gamma-bar .gamma-wave span:nth-child(4) { height: 16px; animation-delay: 0.3s; }
.gamma-bar .gamma-wave span:nth-child(5) { height: 8px; animation-delay: 0.4s; }
.gamma-bar.muted .gamma-wave span { animation-play-state: paused; opacity: 0.3; }
.gamma-bar .gamma-label {
  font-size: 0.75rem;
  color: var(--yellow);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 600;
}
.gamma-bar .gamma-info {
  font-size: 0.65rem;
  color: var(--gray);
  max-width: 300px;
  text-align: center;
  line-height: 1.3;
}
.gamma-bar .gamma-info a { color: var(--yellow); text-decoration: underline; cursor: pointer; font-size: 0.6rem; }
.gamma-bar .gamma-mute {
  background: none;
  border: 1px solid var(--gray-border);
  color: var(--white);
  padding: 0.3rem 0.8rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.2s;
}
.gamma-bar .gamma-mute:hover { border-color: var(--yellow); color: var(--yellow); }
@keyframes gammaWave {
  0% { transform: scaleY(0.3); }
  100% { transform: scaleY(1); }
}

/* ─── Pomodoro Timer ─── */
.pomodoro-widget {
  position: fixed;
  bottom: 60px;
  right: 20px;
  width: 220px;
  background: var(--card-bg);
  border: 1px solid var(--gray-border);
  border-radius: 12px;
  padding: 1rem;
  z-index: 800;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  transform: translateY(120%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.pomodoro-widget.visible { transform: translateY(0); }
.pomodoro-widget .pomo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.8rem;
}
.pomodoro-widget .pomo-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--yellow);
  font-weight: 600;
}
/* Pomodoro info icon with hover tooltip */
.pomodoro-widget .pomo-info-icon {
  position: relative;
  font-size: 0.85rem;
  color: var(--gray);
  cursor: help;
  margin-left: 0.3rem;
  line-height: 1;
}
.pomodoro-widget .pomo-info-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  right: -60px;
  width: 240px;
  background: var(--black);
  border: 1px solid var(--yellow);
  border-radius: 6px;
  padding: 0.7rem 0.8rem;
  font-size: 0.7rem;
  line-height: 1.5;
  color: var(--white);
  z-index: 1000;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
  pointer-events: none;
}
.pomodoro-widget .pomo-info-icon:hover .pomo-info-tooltip { display: block; }
.pomodoro-widget .pomo-close {
  background: none;
  border: none;
  color: var(--gray);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}
.pomodoro-widget .pomo-time {
  text-align: center;
  font-family: var(--serif);
  font-size: 2.5rem;
  color: var(--white);
  margin: 0.5rem 0;
  font-variant-numeric: tabular-nums;
}
.pomodoro-widget .pomo-time.break-mode { color: var(--success); }
.pomodoro-widget .pomo-status {
  text-align: center;
  font-size: 0.7rem;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.8rem;
}
.pomodoro-widget .pomo-progress {
  height: 3px;
  background: var(--gray-border);
  border-radius: 2px;
  margin-bottom: 0.8rem;
  overflow: hidden;
}
.pomodoro-widget .pomo-progress-fill {
  height: 100%;
  background: var(--yellow);
  border-radius: 2px;
  transition: width 1s linear;
}
.pomodoro-widget .pomo-controls {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}
.pomodoro-widget .pomo-btn {
  padding: 0.4rem 1rem;
  border: 1px solid var(--gray-border);
  background: none;
  color: var(--white);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.2s;
}
.pomodoro-widget .pomo-btn:hover { border-color: var(--yellow); color: var(--yellow); }
.pomodoro-widget .pomo-btn.primary { background: var(--yellow); color: var(--black); border-color: var(--yellow); }
.pomodoro-widget .pomo-sessions {
  text-align: center;
  font-size: 0.65rem;
  color: var(--gray);
  margin-top: 0.6rem;
}

/* ─── Immersive Mode Overlay ─── */
.immersive-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  padding: 2rem;
}
.immersive-overlay.active { display: flex; }
.immersive-overlay .immersive-icon { font-size: 3rem; margin-bottom: 1rem; }
.immersive-overlay .immersive-title {
  font-family: var(--serif);
  font-size: 1.8rem;
  color: var(--yellow);
  margin-bottom: 0.5rem;
}
.immersive-overlay .immersive-msg {
  color: var(--gray);
  font-size: 0.9rem;
  max-width: 400px;
  line-height: 1.5;
  margin-bottom: 1.5rem;
}
.immersive-overlay .immersive-btn {
  background: var(--yellow);
  color: var(--black);
  border: none;
  padding: 0.8rem 2rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.immersive-enter-bar {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.6rem 1rem;
  background: rgba(245, 197, 24, 0.08);
  border: 1px solid var(--yellow);
  border-radius: 6px;
  margin-bottom: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}
.immersive-enter-bar:hover { background: rgba(245, 197, 24, 0.15); }
.immersive-enter-bar .immersive-enter-icon { font-size: 1.2rem; }
.immersive-enter-bar .immersive-enter-text { font-size: 0.8rem; color: var(--yellow); }
.immersive-enter-bar .immersive-enter-cite { font-size: 0.6rem; color: var(--gray); }

/* ─── Science Tips Panel ─── */
.science-tip {
  background: linear-gradient(135deg, rgba(245,197,24,0.05), rgba(99,102,241,0.05));
  border: 1px solid var(--gray-border);
  border-left: 3px solid var(--yellow);
  border-radius: 8px;
  padding: 1.2rem 1.5rem;
  margin: 1.5rem 0;
  position: relative;
}
.science-tip .tip-icon { font-size: 1.3rem; margin-bottom: 0.5rem; display: block; }
.science-tip .tip-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--yellow);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}
.science-tip .tip-text { font-size: 0.85rem; color: var(--white); line-height: 1.5; }
.science-tip .tip-citation {
  font-size: 0.65rem;
  color: var(--gray);
  margin-top: 0.5rem;
  font-style: italic;
}
.science-tip .tip-citation a { color: var(--accent-cyan); text-decoration: none; }
/* Citation hover — shows layman explanation */
.science-tip .citation-hover {
  cursor: help;
  border-bottom: 1px dotted var(--gray);
  position: relative;
}
.science-tip .citation-hover:hover { color: var(--yellow); }
.science-tip .citation-hover::after {
  content: attr(title);
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  width: 280px;
  padding: 0.5rem 0.7rem;
  background: var(--black);
  border: 1px solid var(--yellow);
  border-radius: 6px;
  color: var(--white);
  font-size: 0.72rem;
  font-style: normal;
  line-height: 1.4;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  pointer-events: none;
}
.science-tip .citation-hover:hover::after { display: block; }

/* ─── Subtle Quotes (shown during delays / loading) ─── */
.subtle-quote {
  padding: 0.5rem 0;
  font-style: italic;
  font-size: 0.75rem;
  color: var(--gray);
  line-height: 1.5;
  opacity: 0;
  animation: fadeInQuote 1s ease 0.5s forwards;
}
.subtle-quote .sq-text { color: var(--gray); }
.subtle-quote .sq-author { color: var(--yellow); opacity: 0.6; font-size: 0.65rem; }
@keyframes fadeInQuote { 0% { opacity: 0; } 100% { opacity: 1; } }

/* ─── Study Planner ─── */
.planner-container {
  max-width: 1000px;
  margin: 0 auto;
}
.planner-form {
  background: var(--card-bg);
  border: 1px solid var(--gray-border);
  border-radius: 8px;
  padding: 2rem;
  margin-bottom: 2rem;
}
.planner-form .form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.planner-week-nav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.planner-week-btn {
  padding: 0.4rem 1rem;
  border: 1px solid var(--gray-border);
  background: none;
  color: var(--white);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
}
.planner-week-btn.active { background: var(--yellow); color: var(--black); border-color: var(--yellow); }
.planner-schedule {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.5rem;
}
.planner-day {
  background: var(--card-bg);
  border: 1px solid var(--gray-border);
  border-radius: 6px;
  padding: 0.8rem;
}
.planner-day-name {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--yellow);
  font-weight: 600;
  margin-bottom: 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--gray-border);
}
.planner-slot {
  padding: 0.3rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  font-size: 0.65rem;
}
.planner-slot .slot-time { color: var(--gray); }
.planner-slot .slot-module { color: var(--white); font-weight: 500; margin-top: 0.1rem; }
.planner-slot .slot-type {
  display: inline-block;
  padding: 0.1rem 0.3rem;
  border-radius: 2px;
  font-size: 0.55rem;
  text-transform: uppercase;
  margin-top: 0.2rem;
}
.planner-slot .slot-type.study { background: rgba(59,130,246,0.2); color: #3b82f6; }
.planner-slot .slot-type.practice { background: rgba(168,85,247,0.2); color: #a855f7; }
.planner-slot .slot-type.revision { background: rgba(245,197,24,0.2); color: var(--yellow); }
.planner-slot .slot-type.wellness { background: rgba(34,197,94,0.2); color: #22c55e; }

/* ─── Teach-Back Chat ─── */
.teachback-container {
  max-width: 700px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
  min-height: 400px;
}
.teachback-header {
  background: var(--card-bg);
  border: 1px solid var(--gray-border);
  border-radius: 8px 8px 0 0;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.teachback-header .tb-avatar { font-size: 2rem; }
.teachback-header .tb-name { font-weight: 600; color: var(--white); }
.teachback-header .tb-tag {
  font-size: 0.65rem;
  background: rgba(245,197,24,0.15);
  color: var(--yellow);
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  text-transform: uppercase;
}
.teachback-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: var(--black);
  border-left: 1px solid var(--gray-border);
  border-right: 1px solid var(--gray-border);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.teachback-msg {
  max-width: 80%;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
}
.teachback-msg.junior {
  align-self: flex-start;
  background: var(--card-bg);
  border: 1px solid var(--gray-border);
  color: var(--white);
  border-bottom-left-radius: 2px;
}
.teachback-msg.teacher {
  align-self: flex-end;
  background: var(--yellow);
  color: var(--black);
  border-bottom-right-radius: 2px;
}
.teachback-input {
  display: flex;
  gap: 0.5rem;
  padding: 1rem;
  background: var(--card-bg);
  border: 1px solid var(--gray-border);
  border-radius: 0 0 8px 8px;
}
.teachback-input input {
  flex: 1;
  background: var(--black);
  border: 1px solid var(--gray-border);
  color: var(--white);
  padding: 0.7rem 1rem;
  border-radius: 4px;
  font-size: 0.9rem;
}
.teachback-input input:focus { border-color: var(--yellow); outline: none; }
.teachback-input button {
  background: var(--yellow);
  color: var(--black);
  border: none;
  padding: 0.7rem 1.5rem;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
}

/* ─── AI Study Assistant Widget ─── */
.assistant-fab {
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--yellow);
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 850;
  box-shadow: 0 4px 16px rgba(245,197,24,0.3);
  transition: transform 0.2s;
  display: none;
}
.assistant-fab:hover { transform: scale(1.1); }
.assistant-fab.has-notifications::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 14px;
  height: 14px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--black);
}
.assistant-panel {
  position: fixed;
  bottom: 86px;
  left: 20px;
  width: 340px;
  height: 520px;
  background: var(--card-bg);
  border: 1px solid var(--gray-border);
  border-radius: 12px;
  z-index: 850;
  overflow: hidden;
  display: none;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.assistant-panel.open { display: flex; }

/* Chat view inside panel */
.ap-chat-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ap-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.ap-msg {
  padding: 0.55rem 0.8rem;
  border-radius: 10px;
  font-size: 0.8rem;
  line-height: 1.5;
  max-width: 88%;
  word-break: break-word;
}
.ap-msg-buddy {
  background: rgba(245,197,24,0.08);
  border: 1px solid rgba(245,197,24,0.15);
  color: var(--white);
  align-self: flex-start;
  border-bottom-left-radius: 3px;
}
.ap-msg-user {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--gray-border);
  color: var(--white);
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}
.ap-chat-input {
  display: flex;
  gap: 0.4rem;
  padding: 0.6rem;
  border-top: 1px solid var(--gray-border);
}
.ap-chat-input input {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--gray-border);
  color: var(--white);
  padding: 0.45rem 0.7rem;
  border-radius: 6px;
  font-size: 0.78rem;
  outline: none;
}
.ap-chat-input input:focus { border-color: var(--yellow); }
.ap-chat-input button {
  background: var(--yellow);
  color: var(--black);
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.assistant-panel .ap-header {
  padding: 1rem;
  border-bottom: 1px solid var(--gray-border);
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
.assistant-panel .ap-avatar { font-size: 1.8rem; }
.assistant-panel .ap-name {
  font-weight: 600;
  color: var(--white);
  font-size: 0.95rem;
}
.assistant-panel .ap-status {
  font-size: 0.65rem;
  color: var(--success);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.assistant-panel .ap-status::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
}
.assistant-panel .ap-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}
.assistant-panel .ap-section {
  margin-bottom: 1rem;
}
.assistant-panel .ap-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--yellow);
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.assistant-panel .ap-card {
  background: var(--black);
  border: 1px solid var(--gray-border);
  border-radius: 6px;
  padding: 0.7rem;
  margin-bottom: 0.4rem;
  font-size: 0.8rem;
  color: var(--white);
  cursor: pointer;
  transition: border-color 0.2s;
}
.assistant-panel .ap-card:hover { border-color: var(--yellow); }
.assistant-panel .ap-card .ap-card-label {
  font-size: 0.65rem;
  color: var(--gray);
  margin-top: 0.2rem;
}
.assistant-panel .ap-rename {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.5rem;
}
.assistant-panel .ap-rename input {
  flex: 1;
  background: var(--black);
  border: 1px solid var(--gray-border);
  color: var(--white);
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
}
.assistant-panel .ap-rename button {
  background: var(--yellow);
  color: var(--black);
  border: none;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  font-size: 0.7rem;
  cursor: pointer;
}

/* ─── Flashcard Review ─── */
.flashcard {
  width: 100%;
  max-width: 500px;
  min-height: 250px;
  margin: 0 auto;
  perspective: 1000px;
  cursor: pointer;
}
.flashcard-inner {
  width: 100%;
  min-height: 250px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s;
}
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-front, .flashcard-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  border-radius: 12px;
  text-align: center;
  font-size: 1.1rem;
  line-height: 1.6;
}
.flashcard-front {
  background: var(--card-bg);
  border: 2px solid var(--yellow);
  color: var(--white);
}
.flashcard-back {
  background: var(--yellow);
  color: var(--black);
  transform: rotateY(180deg);
  font-weight: 500;
}
.flashcard-controls {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
}
.flashcard-controls button {
  padding: 0.5rem 1.2rem;
  border: 1px solid var(--gray-border);
  background: none;
  color: var(--white);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
}
.flashcard-controls button:hover { border-color: var(--yellow); }
.flashcard-controls button.easy { border-color: var(--success); color: var(--success); }
.flashcard-controls button.hard { border-color: var(--danger); color: var(--danger); }

/* ─── Responsive adjustments ─── */
@media (max-width: 768px) {
  .gamma-bar .gamma-info { display: none; }
  .pomodoro-widget { right: 10px; width: 190px; }
  .assistant-panel { width: 300px; left: 10px; }
  .planner-schedule { grid-template-columns: 1fr; }
  .teachback-msg { max-width: 90%; }
}
