/* =============================================================
   styles.css — Iksula Induction Player
   ============================================================= */

/* ── Custom Properties ──────────────────────────────────────── */

:root {
  --color-brand:        #D62B2B;
  --color-brand-dark:   #a81f1f;
  --color-brand-light:  #fceaea;
  --color-bg:           #f4f5f7;
  --color-surface:      #ffffff;
  --color-sidebar:      #1e2330;
  --color-sidebar-text: #c8cdd8;
  --color-sidebar-hover:#2d3448;
  --color-active-bg:    #2d3448;
  --color-text:         #1a1d26;
  --color-muted:        #6b7280;
  --color-border:       #e5e7eb;
  --color-success:      #16a34a;
  --color-done-bg:      #dcfce7;

  --sidebar-width:      280px;
  --header-height:      56px;
  --radius:             10px;
  --shadow:             0 2px 12px rgba(0,0,0,0.08);
  --transition:         0.2s ease;

  --font-ui:    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ── Reset ──────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font-ui);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 15px;
  line-height: 1.5;
}

button { cursor: pointer; font-family: inherit; }
ul { list-style: none; }
a { color: inherit; text-decoration: none; }

/* ── Layout Shell ───────────────────────────────────────────── */

#app {
  display: grid;
  grid-template-rows: var(--header-height) 1fr;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-areas:
    "header header"
    "sidebar main";
  height: 100vh;
  overflow: hidden;
}

/* ── Header ─────────────────────────────────────────────────── */

#header {
  grid-area: header;
  background: var(--color-brand);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  z-index: 10;
}

#header .logo {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

#header .logo span {
  opacity: 0.75;
  font-weight: 400;
}

#header .spacer { flex: 1; }

/* Progress bar in header */
.progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

#progress-label {
  font-size: 0.78rem;
  opacity: 0.9;
  white-space: nowrap;
}

#progress-track {
  width: 140px;
  height: 6px;
  background: rgba(255,255,255,0.25);
  border-radius: 99px;
  overflow: hidden;
}

#progress-fill {
  height: 100%;
  width: 0%;
  background: #fff;
  border-radius: 99px;
  transition: width 0.4s ease;
}

/* ── Sidebar ─────────────────────────────────────────────────── */

#sidebar {
  grid-area: sidebar;
  background: var(--color-sidebar);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255,255,255,0.04);
}

#sidebar-header {
  padding: 18px 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

#sidebar-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-sidebar-text);
  opacity: 0.6;
}

/* Module list */
#module-list {
  flex: 1;
  padding: 8px 0;
}

.module-item {
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.module-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  cursor: pointer;
  transition: background var(--transition);
  color: var(--color-sidebar-text);
}

.module-header:hover {
  background: var(--color-sidebar-hover);
}

.module-item.active > .module-header {
  background: var(--color-active-bg);
  color: #fff;
}

.module-item.complete > .module-header {
  color: #86efac;
}

.module-icon {
  font-size: 1.05rem;
  flex-shrink: 0;
}

.module-title {
  flex: 1;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.3;
}

.module-badge {
  font-size: 0.65rem;
  background: rgba(255,255,255,0.1);
  border-radius: 99px;
  padding: 2px 7px;
  color: var(--color-sidebar-text);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Slide sub-list */
.slide-list {
  padding: 4px 0 6px 0;
  background: rgba(0,0,0,0.15);
}

.slide-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 16px 7px 36px;
  cursor: pointer;
  color: var(--color-sidebar-text);
  font-size: 0.78rem;
  transition: background var(--transition);
  opacity: 0.8;
}

.slide-item:hover {
  background: rgba(255,255,255,0.06);
  opacity: 1;
}

.slide-item.current {
  color: #fff;
  opacity: 1;
  background: rgba(214, 43, 43, 0.2);
}

.slide-item.done {
  opacity: 1;
  color: #86efac;
}

.slide-dot {
  font-size: 0.65rem;
  margin-top: 2px;
  flex-shrink: 0;
  width: 12px;
  text-align: center;
}

.slide-name {
  line-height: 1.35;
}

/* Sidebar reset button at bottom */
#sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

#btn-restart {
  width: 100%;
  padding: 7px 12px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius);
  color: var(--color-sidebar-text);
  font-size: 0.75rem;
  transition: background var(--transition);
}

#btn-restart:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

/* ── Main Content Area ───────────────────────────────────────── */

#main {
  grid-area: main;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-bg);
}

/* Breadcrumb */
#breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 32px;
  font-size: 0.78rem;
  color: var(--color-muted);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}

#breadcrumb-module {
  font-weight: 500;
  color: var(--color-brand);
}

#slide-counter {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--color-muted);
}

/* TTS warning */
#tts-warning {
  margin: 12px 32px 0;
  padding: 8px 14px;
  background: #fef9c3;
  border: 1px solid #fde047;
  border-radius: var(--radius);
  font-size: 0.8rem;
  color: #713f12;
}

/* Slide stage */
#slide-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  overflow-y: auto;
}

#slide-area {
  width: 100%;
  max-width: 760px;
}

/* ── Slide Card ──────────────────────────────────────────────── */

.slide {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 48px;
  border-top: 4px solid var(--color-brand);
}

.slide-completion {
  border-top-color: var(--color-success);
  background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 60%);
}

.completion-banner {
  font-size: 1.4rem;
  text-align: center;
  margin-bottom: 20px;
  color: var(--color-success);
  font-weight: 700;
}

.slide-title {
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 24px;
  line-height: 1.25;
}

.slide-bullets {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.slide-bullets li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.97rem;
  line-height: 1.55;
  color: var(--color-text);
}

.slide-bullets li::before {
  content: "";
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-brand);
  margin-top: 7px;
  flex-shrink: 0;
}

/* Override bullet dot for checklist items (already have emoji) */
.slide-completion .slide-bullets li::before {
  display: none;
}

/* ── Slide entrance animation ───────────────────────────────── */

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

.slide-entering {
  animation: slideIn 0.35s ease forwards;
}

/* ── Controls Bar ────────────────────────────────────────────── */

#controls {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 14px 32px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* Base button */
.ctrl-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  border-radius: var(--radius);
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background var(--transition), opacity var(--transition);
}

.ctrl-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Play/Pause — primary */
#btn-play {
  background: var(--color-brand);
  color: #fff;
  min-width: 110px;
  justify-content: center;
}

#btn-play:hover:not(:disabled) {
  background: var(--color-brand-dark);
}

/* Prev / Next */
#btn-prev, #btn-next {
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

#btn-prev:hover:not(:disabled),
#btn-next:hover:not(:disabled) {
  background: #e9eaf0;
}

/* Auto-advance toggle */
.auto-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  color: var(--color-muted);
  cursor: pointer;
  margin-left: 6px;
  user-select: none;
}

#auto-advance-toggle {
  accent-color: var(--color-brand);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* Keyboard hint */
#kbd-hint {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--color-muted);
}

kbd {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg);
  font-size: 0.7rem;
  font-family: inherit;
}

/* ── Scrollbar styling (sidebar) ─────────────────────────────── */

#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }

/* ── Responsive — collapse sidebar on small screens ─────────── */

@media (max-width: 720px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-height) auto 1fr auto;
    grid-template-areas:
      "header"
      "sidebar"
      "main"
      "main";
  }

  #sidebar {
    max-height: 220px;
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }

  #slide-stage {
    padding: 16px;
  }

  .slide {
    padding: 24px 20px;
  }

  .slide-title {
    font-size: 1.2rem;
  }

  #controls {
    padding: 10px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }

  #kbd-hint { display: none; }
}

/* =============================================================
   Chatbot — Floating Action Button + Panel
   ============================================================= */

/* ── FAB ──────────────────────────────────────────────────────── */

#chat-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--color-brand);
  color: #fff;
  border: none;
  border-radius: 99px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font-ui);
  box-shadow: 0 4px 18px rgba(214,43,43,0.45);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}

#chat-fab:hover {
  background: var(--color-brand-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(214,43,43,0.5);
}

#chat-fab.active {
  background: #444;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}

#chat-fab-icon { font-size: 1rem; }
#chat-fab-label { font-size: 0.85rem; }

/* ── Chat Panel ───────────────────────────────────────────────── */

#chat-panel {
  position: fixed;
  bottom: 90px;
  right: 28px;
  z-index: 199;
  width: 370px;
  max-height: 560px;
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  overflow: hidden;
  /* Hidden by default */
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

#chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Header */
#chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--color-brand);
  color: #fff;
  flex-shrink: 0;
}

#chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

#chat-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

#chat-title {
  font-size: 0.9rem;
  font-weight: 700;
}

#chat-subtitle {
  font-size: 0.7rem;
  opacity: 0.8;
}

#chat-close {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.85);
  font-size: 1rem;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background var(--transition);
}

#chat-close:hover {
  background: rgba(255,255,255,0.18);
  color: #fff;
}

/* Messages */
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

#chat-messages::-webkit-scrollbar { width: 3px; }
#chat-messages::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 2px; }

.msg {
  display: flex;
  max-width: 88%;
}

.msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-bot {
  align-self: flex-start;
}

.bubble {
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 0.82rem;
  line-height: 1.55;
  word-break: break-word;
}

.msg-user .bubble {
  background: var(--color-brand);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-bot .bubble {
  background: #f1f3f6;
  color: var(--color-text);
  border-bottom-left-radius: 4px;
}

.msg-bot .bubble strong {
  color: var(--color-brand-dark);
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 14px;
}

.typing-indicator span {
  display: block;
  width: 7px;
  height: 7px;
  background: var(--color-muted);
  border-radius: 50%;
  animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-5px); opacity: 1; }
}

/* Quick chips */
#chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

.chip {
  padding: 4px 11px;
  border: 1px solid var(--color-border);
  border-radius: 99px;
  background: var(--color-bg);
  font-size: 0.72rem;
  font-family: var(--font-ui);
  color: var(--color-text);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  white-space: nowrap;
}

.chip:hover {
  background: var(--color-brand-light);
  border-color: var(--color-brand);
  color: var(--color-brand-dark);
}

/* Input row */
#chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

#chat-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 99px;
  font-size: 0.82rem;
  font-family: var(--font-ui);
  background: var(--color-bg);
  color: var(--color-text);
  outline: none;
  transition: border-color var(--transition);
}

#chat-input:focus {
  border-color: var(--color-brand);
}

#chat-send {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--color-brand);
  color: #fff;
  border: none;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  flex-shrink: 0;
}

#chat-send:hover {
  background: var(--color-brand-dark);
}

/* ── Mobile adjustments ───────────────────────────────────────── */

@media (max-width: 720px) {
  #chat-panel {
    right: 12px;
    left: 12px;
    width: auto;
    bottom: 80px;
    max-height: 65vh;
  }

  #chat-fab {
    right: 16px;
    bottom: 16px;
  }
}
