/* ========================================
   Zipgo Learn — ported from zipgo.ai styles.css
   (same tokens/components, adapted to app layouts)
   ======================================== */
:root {
  --primary: #00f0ff;
  --primary-dark: #00a8b3;
  --secondary: #8b5cf6;
  --accent: #f0f;
  --bg-dark: #000000;
  --bg-darker: #050508;
  --bg-card: rgba(255, 255, 255, 0.02);
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-muted: rgba(255, 255, 255, 0.4);
  --border: rgba(255, 255, 255, 0.1);
  --glow: 0 0 20px rgba(0, 240, 255, 0.3);
  /* course themes override these two */
  --course-accent: var(--primary);
  --course-accent2: var(--secondary);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

/* Site-wide themed scrollbars (page, sidebar, module nav, logs) */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 240, 255, 0.35) rgba(255, 255, 255, 0.04);
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.04); }
*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(0, 240, 255, 0.45), rgba(139, 92, 246, 0.45));
  border-radius: 4px;
}
*::-webkit-scrollbar-thumb:hover { background: var(--primary); }
body {
  font-family: 'Rajdhani', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  overflow-x: hidden;
  line-height: 1.6;
  font-size: 1.05rem;
}

/* Deep-space nebula wash — sits beneath the starfield, quieter than it */
body::before {
  content: '';
  position: fixed; inset: -25%;
  z-index: -2; pointer-events: none;
  background:
    radial-gradient(42% 34% at 22% 28%, rgba(139, 92, 246, 0.17) 0%, transparent 70%),
    radial-gradient(36% 30% at 78% 64%, rgba(0, 240, 255, 0.10) 0%, transparent 70%),
    radial-gradient(26% 22% at 62% 15%, rgba(255, 0, 255, 0.06) 0%, transparent 70%),
    radial-gradient(48% 40% at 38% 88%, rgba(64, 66, 160, 0.15) 0%, transparent 70%),
    var(--bg-dark);
  animation: nebula-drift 90s ease-in-out infinite alternate;
}
@keyframes nebula-drift {
  from { transform: translate3d(-1.5%, -1%, 0) scale(1); }
  to { transform: translate3d(1.5%, 1.5%, 0) scale(1.07); }
}
@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
}

/* FTL starfield canvas (drawn by app.js) — above the nebula, behind content */
#warp { position: fixed; inset: 0; z-index: -1; pointer-events: none; }
h1, h2, h3 { font-family: 'Orbitron', sans-serif; letter-spacing: 0.05em; }
a { color: var(--primary); text-decoration: none; }
p { margin-bottom: 1rem; }

/* ========================================
   Page loader — blocks first paint until the JS render settles
   ======================================== */
#loader {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg-dark);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1.3rem;
  transition: opacity 0.4s ease;
}
#loader.done { opacity: 0; pointer-events: none; }
#loader img {
  height: 58px;
  filter: drop-shadow(0 0 18px rgba(0, 240, 255, 0.45));
  animation: loader-pulse 1.6s ease-in-out infinite;
}
@keyframes loader-pulse {
  50% { transform: scale(1.07); opacity: 0.75; }
}
#loader .loader-dots { display: flex; gap: 0.45rem; }
#loader .loader-dots span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--primary);
  animation: loader-dot 1.2s ease-in-out infinite;
}
#loader .loader-dots span:nth-child(2) { animation-delay: 0.15s; }
#loader .loader-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes loader-dot { 40% { opacity: 0.2; transform: translateY(3px); } }

/* ========================================
   Navigation (zipgo.ai navbar)
   ======================================== */
.topbar {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; gap: 2.5rem;
  padding: 1rem 2rem;
  transition: all 0.3s ease;
  background: transparent;
}
.topbar.scrolled {
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
/* Brand sits dead-center in the bar; nav items flow around it */
.brand {
  display: flex; align-items: center; gap: 0.55rem; text-decoration: none;
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
}
/* The hamburger is pinned to the viewport's top-left so it never moves when
   the sidebar opens/closes; sidebar + topbar content clear it. */
.nav-toggle {
  /* vertically centered against the ~67px topbar */
  position: fixed; top: 19px; left: 16px; z-index: 60;
  background: rgba(0, 0, 0, 0.6); border: 1px solid var(--border); color: var(--text-secondary);
  font-size: 1.05rem; padding: 0.3rem 0.7rem; cursor: pointer; transition: color 0.3s ease, border-color 0.3s ease;
}
.nav-toggle:hover { color: var(--primary); border-color: var(--primary); }
body.has-toggle.sidebar-collapsed .topbar { padding-left: 4.6rem; }
body.sidebar-collapsed .sidebar { display: none; }
.brand img { height: 34px; width: auto; transition: transform 0.3s ease; }
.brand:hover img { transform: scale(1.05); }
.brand span {
  /* sized to visually match the 34px Zipgo logo beside it */
  font-family: 'Orbitron', sans-serif; font-weight: 800; font-size: 1.85rem;
  line-height: 1; text-transform: uppercase; letter-spacing: 0.1em;
  position: relative; top: 2px;
}
.brand .hl {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.topbar a.nav-link, .topbar a:not(.brand):not(.btn) {
  color: var(--text-secondary); text-decoration: none;
  font-size: 0.95rem; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase;
  position: relative; padding: 0.5rem 0;
  transition: color 0.3s ease;
}
.topbar a:not(.brand):not(.btn)::after {
  content: ''; position: absolute; bottom: 0; left: 0;
  width: 0; height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 0.3s ease;
}
.topbar a:not(.brand):not(.btn):hover { color: var(--text-primary); }
.topbar a:not(.brand):not(.btn):hover::after { width: 100%; }
.topbar .spacer { flex: 1; }
.topbar .user { color: var(--text-muted); font-size: 0.9rem; letter-spacing: 0.05em; }

/* ========================================
   Layout with sidebar
   ======================================== */
.layout { display: flex; min-height: calc(100vh - 67px); }
/* Sidebar runs the full height of the viewport, alongside (not under) the
   topbar; topbar + content shift right while it's open. */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 280px; z-index: 50;
  border-right: 1px solid var(--border);
  padding: 1.4rem 1.1rem; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(10px);
  overflow-y: auto;
}
body.with-sidebar:not(.sidebar-collapsed) .topbar,
body.with-sidebar:not(.sidebar-collapsed) .main,
body.with-sidebar:not(.sidebar-collapsed) #root { margin-left: 280px; }
.sidebar h3 {
  /* sits to the right of the pinned hamburger */
  margin: 0.55rem 0 1.2rem 3.2rem; font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.3em; color: var(--primary); font-weight: 600;
}
.course-link {
  display: block; padding: 0.6rem 0.75rem; margin-bottom: 0.3rem;
  color: var(--text-primary); border: 1px solid transparent; font-size: 0.98rem; font-weight: 500;
  transition: all 0.3s ease;
}
.course-link:hover { background: var(--bg-card); border-color: var(--border); text-decoration: none; }
.course-link.active { background: rgba(0, 240, 255, 0.05); border-color: rgba(0, 240, 255, 0.3); box-shadow: inset 2px 0 0 var(--primary); }
.course-link .status { font-size: 0.75rem; color: var(--text-muted); display: block; letter-spacing: 0.08em; text-transform: uppercase; }
.course-link .status.generating { color: #ffc86b; }
.course-link .status.failed { color: #ff6b81; }
.main { flex: 1; padding: 2.2rem; min-width: 0; }

/* ========================================
   Hero (home) — zipgo.ai hero pattern
   ======================================== */
/* Home: the INPUT ROW sits at the vertical center of the page — the block is
   flex-centered, then padded at the bottom by roughly the height of the
   title area above the input so the row itself lands on center. */
.hero-main { display: flex; align-items: center; justify-content: center; }
.hero { max-width: 1000px; margin: 10vh auto 0; text-align: center; padding: 2rem; }
.hero-main .hero { margin: 0 auto; padding-bottom: clamp(140px, 24vh, 220px); }
.hero h1 {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(2rem, 6vw, 4rem);
  font-weight: 800; line-height: 1.1; margin-bottom: 1.5rem;
}
.hero h1 .title-line {
  display: block; color: var(--text-secondary);
  font-size: 0.5em; letter-spacing: 0.3em; margin-bottom: 0.5rem;
}
.hero h1 .title-highlight {
  display: block;
  background: linear-gradient(135deg, var(--primary), var(--secondary), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  animation: gradient-shift 5s ease infinite;
  background-size: 200% 200%;
}
@keyframes gradient-shift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
.hero p.sub {
  font-size: clamp(1rem, 2vw, 1.3rem); color: var(--text-secondary);
  max-width: 640px; margin: 0 auto 2.5rem; letter-spacing: 0.05em;
}
.section-tag {
  display: inline-block; font-family: 'Orbitron', sans-serif;
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.3em;
  color: var(--primary); margin-bottom: 1rem; padding: 0.5rem 1.5rem;
  border: 1px solid rgba(0, 240, 255, 0.3); background: rgba(0, 240, 255, 0.05);
}
.topic-form { display: flex; gap: 1rem; margin: 3.2rem auto 1.2rem; max-width: 760px; }
/* The input is the main focal point: tallest element in the row (the cog
   stretches to match) with a brighter-than-default outline. The [type=text]
   in the selector outranks the later global input[type=text] rule, which
   would otherwise shrink the padding and add a bottom margin (making the
   input shorter than the stretched cog). */
.topic-form input[type=text] {
  flex: 1; padding: 0.8rem 1.4rem; margin: 0; font-size: 1.2rem;
  border: 1px solid rgba(0, 240, 255, 0.45); background: rgba(0, 0, 0, 0.6);
  color: var(--text-primary);
  font-family: inherit; letter-spacing: 0.03em; transition: all 0.3s ease;
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.12);
}
.topic-form input[type=text]:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 24px rgba(0, 240, 255, 0.35);
}
.input-tip {
  max-width: 760px; margin: 0 auto 1.5rem; padding: 1rem 1.2rem;
  border: 1px solid rgba(0, 240, 255, 0.3); background: rgba(0, 240, 255, 0.03);
  text-align: left;
}
.input-tip p { color: var(--text-secondary); margin-bottom: 0.8rem; font-size: 0.98rem; }
.input-tip-actions { display: flex; gap: 0.7rem; justify-content: flex-end; }
.model-select {
  padding: 0 1rem; border: 1px solid var(--border); background: rgba(0, 0, 0, 0.55);
  color: var(--text-primary); font-family: 'Orbitron', sans-serif; font-size: 0.82rem;
  letter-spacing: 0.06em; cursor: pointer;
}
.model-select:focus { outline: none; border-color: var(--primary); box-shadow: var(--glow); }
.model-select option { background: #050508; }
.cog-wrap { position: relative; display: flex; }
.btn-cog {
  width: 54px; align-self: stretch; display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.55); border: 1px solid var(--border); color: var(--text-secondary);
  cursor: pointer; transition: all 0.3s ease;
}
.btn-cog:hover { color: var(--primary); border-color: var(--primary); box-shadow: var(--glow); }
.btn-cog:hover svg { transform: rotate(45deg); }
.btn-cog svg { transition: transform 0.4s ease; }
.model-pop {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 20;
  width: max-content; min-width: 200px; max-width: 90vw;
  padding: 1rem 1.1rem; text-align: left;
  background: #05050a; border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.8), var(--glow);
}
.model-pop .model-select { width: 100%; }

/* ========================================
   Buttons (zipgo.ai .btn / .btn-primary / .btn-secondary)
   ======================================== */
.btn {
  --cut: 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.75rem;
  padding: 1rem 2.5rem;
  font-family: 'Orbitron', sans-serif; font-size: 0.9rem; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase; text-decoration: none;
  border: none; border-radius: 0; cursor: pointer; position: relative; overflow: hidden;
  transition: all 0.3s ease;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--bg-dark);
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
}
.btn:hover { transform: translateY(-3px); box-shadow: 0 10px 40px rgba(0, 240, 255, 0.4); text-decoration: none; }
/* Outlined variant: clip-path would clip a real border off at the cut
   corners, so the outline is the button's own background showing through a
   1px-inset fill layer clipped to a matching smaller polygon. */
.btn.secondary {
  background: var(--border); color: var(--text-primary);
}
.btn.secondary::before {
  content: ''; position: absolute; inset: 1px; z-index: -1;
  background: #07070c;
  clip-path: polygon(0 0, calc(100% - var(--cut) + 1px) 0, 100% calc(var(--cut) - 1px), 100% 100%, calc(var(--cut) - 1px) 100%, 0 calc(100% - var(--cut) + 1px));
  transition: background 0.3s ease;
}
.btn.secondary:hover { background: var(--primary); color: var(--primary); box-shadow: none; }
.btn.small {
  --cut: 9px;
  padding: 0.45rem 1.1rem; font-size: 0.72rem;
}
.btn:disabled { opacity: 0.5; cursor: default; transform: none; box-shadow: none; }

/* ========================================
   Cards (zipgo.ai .feature-card)
   ======================================== */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  padding: 1.6rem 1.8rem; margin-bottom: 1rem;
  position: relative; overflow: hidden; transition: all 0.4s ease;
}
.card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  transform: scaleX(0); transition: transform 0.4s ease;
}
.card:hover { border-color: rgba(0, 240, 255, 0.3); }
.card:hover::before { transform: scaleX(1); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1.2rem; }
.grid .card:hover { transform: translateY(-5px); }
.grid .card h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.8rem; }
.muted { color: var(--text-secondary); }
.error { color: #ff6b81; }
.ok { color: var(--primary); }

/* Forms */
input[type=email], input[type=password], input[type=text] {
  width: 100%; padding: 0.8rem 1rem; margin-bottom: 1rem;
  border: 1px solid var(--border); background: rgba(0, 0, 0, 0.55); color: var(--text-primary);
  font-size: 1.05rem; font-family: inherit; transition: all 0.3s ease;
}
input:focus { outline: none; border-color: var(--primary); box-shadow: var(--glow); }
label {
  display: block; font-size: 0.72rem; color: var(--primary); margin-bottom: 0.35rem;
  text-transform: uppercase; letter-spacing: 0.25em; font-weight: 600;
  font-family: 'Orbitron', sans-serif;
}

/* ========================================
   Generation progress
   ======================================== */
.phases { list-style: none; padding: 0; margin: 1.3rem 0; }
.phases li { display: flex; align-items: center; gap: 0.85rem; padding: 0.5rem 0; font-size: 1.05rem; letter-spacing: 0.03em; }
.dot { width: 11px; height: 11px; border-radius: 50%; background: var(--border); flex-shrink: 0; transition: all 0.3s ease; }
.dot.running { background: var(--primary); box-shadow: var(--glow); animation: pulse 1.2s ease-in-out infinite; }
.dot.done { background: var(--primary); }
.dot.failed { background: #ff6b81; }
@keyframes pulse { 50% { opacity: 0.35; } }
.genlog {
  background: var(--bg-card); border: 1px solid var(--border);
  font-family: ui-monospace, monospace; font-size: 0.8rem; padding: 1rem;
  max-height: 45vh; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
  color: var(--text-secondary);
}

/* ========================================
   Course player
   ======================================== */
.player { display: flex; gap: 0; min-height: calc(100vh - 67px); }
.modnav {
  width: 310px; flex-shrink: 0; border-right: 1px solid var(--border); padding: 1.2rem;
  overflow-y: auto; max-height: calc(100vh - 67px); position: sticky; top: 67px;
  background: rgba(0, 0, 0, 0.5);
}
.modnav h2 { font-size: 1rem; margin: 0.2rem 0 0.4rem; }
.modnav .desc { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 1.2rem; }
.mod-item {
  display: flex; align-items: center; gap: 0.65rem; padding: 0.55rem 0.65rem;
  cursor: pointer; font-size: 0.95rem; border: 1px solid transparent; transition: all 0.3s ease;
}
.mod-item:hover { background: var(--bg-card); border-color: var(--border); }
.mod-item.active {
  background: rgba(0, 240, 255, 0.05); border-color: rgba(0, 240, 255, 0.3);
  box-shadow: inset 2px 0 0 var(--course-accent);
}
.mod-item.locked { opacity: 0.4; cursor: not-allowed; }
.mod-item .kind {
  font-size: 0.64rem; color: var(--course-accent); text-transform: uppercase;
  letter-spacing: 0.2em; display: block; font-weight: 600; font-family: 'Orbitron', sans-serif;
}
.mod-check { width: 16px; text-align: center; flex-shrink: 0; color: var(--primary); }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content-frame { flex: 1; border: 0; width: 100%; min-height: calc(100vh - 140px); background: var(--bg-dark); }
.content-head {
  display: flex; align-items: center; gap: 1rem; padding: 0.8rem 1.4rem;
  border-bottom: 1px solid var(--border); background: rgba(0, 0, 0, 0.9); backdrop-filter: blur(20px);
}
.content-head h3 { margin: 0; font-size: 0.92rem; flex: 1; }

/* ========================================
   Quiz runner
   ======================================== */
.quiz-wrap { max-width: 780px; margin: 1.6rem auto; padding: 0 1.4rem 3rem; width: 100%; }
.question { margin-bottom: 1.6rem; }
.question .prompt { font-weight: 600; margin-bottom: 0.55rem; font-size: 1.12rem; }
.choice {
  display: flex; gap: 0.65rem; align-items: flex-start; padding: 0.55rem 0.7rem;
  cursor: pointer; border: 1px solid transparent; transition: all 0.3s ease;
}
.choice:hover { background: var(--bg-card); border-color: var(--border); }
.qresult { padding: 0.6rem 0.9rem; margin-top: 0.5rem; font-size: 0.93rem; border: 1px solid transparent; }
.qresult.correct { background: rgba(0, 240, 255, 0.06); border-color: rgba(0, 240, 255, 0.3); color: var(--primary); }
.qresult.wrong { background: rgba(255, 107, 129, 0.08); border-color: rgba(255, 107, 129, 0.3); color: #ff6b81; }
.score-banner { text-align: center; padding: 1.6rem; margin-bottom: 1.6rem; border: 1px solid var(--border); background: var(--bg-card); }
.score-banner.pass { border-color: rgba(0, 240, 255, 0.35); box-shadow: var(--glow); }
.score-banner.fail { border-color: rgba(255, 107, 129, 0.35); }
.score-banner .big { font-size: 2.6rem; font-weight: 800; font-family: 'Orbitron', sans-serif; }

/* ========================================
   Admin table + badges
   ======================================== */
table.admin { width: 100%; border-collapse: collapse; font-size: 0.97rem; }
table.admin th, table.admin td { text-align: left; padding: 0.65rem 0.8rem; border-bottom: 1px solid var(--border); }
table.admin th {
  color: var(--primary); font-weight: 600; font-size: 0.68rem;
  text-transform: uppercase; letter-spacing: 0.25em; font-family: 'Orbitron', sans-serif;
}
.badge {
  display: inline-block; padding: 0.14rem 0.65rem; font-size: 0.68rem;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.15em;
  font-family: 'Orbitron', sans-serif;
}
.badge.verified { background: rgba(0, 240, 255, 0.05); color: var(--primary); border: 1px solid rgba(0, 240, 255, 0.3); }
.badge.generating { background: rgba(255, 200, 107, 0.06); color: #ffc86b; border: 1px solid rgba(255, 200, 107, 0.35); }
.badge.failed { background: rgba(255, 107, 129, 0.06); color: #ff6b81; border: 1px solid rgba(255, 107, 129, 0.35); }
.badge.ready { background: var(--bg-card); color: var(--text-secondary); border: 1px solid var(--border); }

@media (max-width: 860px) {
  .sidebar, .modnav, .nav-toggle { display: none; }
  body.with-sidebar .topbar, body.with-sidebar .main, body.with-sidebar #root { margin-left: 0; }
  body.has-toggle.sidebar-collapsed .topbar { padding-left: 1.2rem; }
  .main { padding: 1.3rem; }
  .topbar { padding: 1rem 1.2rem; gap: 1.2rem; }
  .brand img { height: 25px; }
}
