/* ===== CSS VARIABLES ===== */
:root {
  --bg: #fff;
  --fg: #111;
  --muted: #7a7a7a;
  --accent: #22c55e;
  --line: #e5e5e5;
  --done: #bdbdbd;
  --upcoming: #111;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0b;
    --fg: #efefef;
    --muted: #a0a0a0;
    --accent: #22c55e;
    --line: #262626;
    --done: #4a4a4a;
    --upcoming: #fff;
  }
}

/* ===== BASE STYLES ===== */
html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 'Lexend', system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

/* ===== LAYOUT ===== */
.wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.header-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px;
  width: 100%;
}

.config-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 20px;
  width: 100%;
}

.progress-container {
  width: 100%;
  padding: 20px 0;
  background: var(--bg);
  position: relative;
}

/* Hide website link in normal view */
.website-link {
  display: none;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px 0;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  color: var(--accent);
  flex-shrink: 0;
}

header .title {
  font-size: 24px;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.2;
}

.tagline {
  font-size: 14px;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.3;
}

.support-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  color: #ff6b6b;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.support-btn:hover {
  background: rgba(255, 107, 107, 0.1);
  transform: scale(1.1);
}

.support-btn svg {
  width: 24px;
  height: 24px;
}

.row {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1;
}

@media (max-width:880px) {

  .header-container,
  .config-container {
    padding: 0px 16px 0px 16px;
  }

  .progress-container {
    padding: 16px 0;
  }
}

/* ===== FORM ELEMENTS ===== */
.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

/* Configuration card specific styling */
.card.editor {
  background: var(--bg);
}

label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 500;
}

/* Title and topics section - side by side */
.form-section {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 20px;
  margin-bottom: 20px;
}

.form-section .title-group {
  display: flex;
  flex-direction: column;
}

.form-section .topics-group {
  display: flex;
  flex-direction: column;
}

input[type="text"],
textarea,
select,
input[type="number"] {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--fg);
  border-radius: 8px;
  padding: 12px;
  font: inherit;
  min-height: 44px;
  transition: border-color 0.2s ease;
}

input[type="text"]:focus,
textarea:focus,
select:focus,
input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
}

textarea {
  min-height: 140px;
  resize: vertical;
  font-family: inherit;
}

/* Controls section - organized in a clean grid */
.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 16px;
  align-items: end;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.controls .group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.controls .group label {
  margin-bottom: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.controls .group input,
.controls .group select {
  min-height: 40px;
  padding: 10px;
  font-size: 14px;
}

/* Color picker styling */
.color-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.color-picker-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  padding: 4px;
  border: 2px solid var(--line);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.color-picker-btn:hover {
  border-color: var(--accent);
  transform: scale(1.05);
}

.color-preview {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Button section */
.button-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.action-buttons {
  display: flex;
  gap: 12px;
}

.tips-text {
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
}

button {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--fg);
  border-radius: 999px;
  padding: 8px 16px;
  /* Increased horizontal padding */
  font: inherit;
  cursor: pointer;
  min-height: 36px;
  /* Fixed minimum height */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  /* Prevent text wrapping */
}

button.primary {
  border-color: var(--fg)
}

/* Green Apply button */
#apply.primary {
  background: #22c55e;
  border-color: #22c55e;
  color: #000000;
  min-width: 80px;
  /* Fixed minimum width */
}

#apply.primary:hover {
  background: #16a34a;
  border-color: #16a34a;
  color: #000000;
}

button:disabled {
  opacity: .5;
  cursor: not-allowed
}

/* Button container for consistent spacing */
.controls button {
  margin-top: auto;
  /* Push buttons to bottom of their grid cell */
}

/* Color picker button */
.color-picker-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  padding: 2px;
  border: 2px solid var(--line);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.color-picker-btn:hover {
  border-color: var(--fg);
}

.color-preview {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Center color picker when opened */
input[type="color"] {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
}

/* SVG Icon styles */
button svg {
  width: 20px;
  height: 20px;
  display: block;
}

/* Icon-only buttons */
#prev,
#next,
#startOver,
#reset {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.tiny {
  font-size: 12px;
  color: var(--muted)
}

/* ===== PROGRESS MODULE ===== */
.progress-shell {
  width: 100%;
  margin: 0;
  padding: 32px 20px;
  position: relative;
  min-height: 320px;
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 0;
  border-left: none;
  border-right: none;
  overflow: auto;
  box-sizing: border-box;
}

/* Hide progress-header and normal-bar in normal view */
.progress-header {
  display: none;
}

.normal-bar {
  display: flex;
}

#lessonHeaderNormal {
  display: block;
}

.progress-title {
  font-weight: 600;
  margin-bottom: 24px;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--fg);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

.progress {
  --gap: 24px;
  --size: 12px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  position: relative;
  padding: 16px 0;
  min-height: 160px;
  max-width: 100%;
  margin: 0 auto;
  overflow: visible;
}

.progress.horizontal {
  flex-direction: row;
  align-items: flex-start;
  flex-wrap: nowrap;
  justify-content: space-between;
  overflow-x: auto;
  overflow-y: visible;
  padding: 16px 20px;
  min-width: min-content;
}

.step {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  min-height: calc(var(--size) + 12px);
  flex-shrink: 0;
  padding: 4px 0;
  padding-left: calc(var(--size) + 18px);
}

.progress.horizontal .step {
  flex-direction: column;
  align-items: center;
  text-align: center;
  flex: 1;
  min-width: 80px;
  max-width: none;
  margin: 0;
  flex-shrink: 1;
  padding-left: 0;
}

.progress.horizontal .step .dot {
  position: relative;
  left: auto;
  top: auto;
  margin-top: 2px;
  transform: none;
}

@media (max-width: 880px) {
  .progress-shell {
    padding: 24px 16px;
  }

  .progress.horizontal {
    padding: 16px;
  }
}

.step .dot {
  position: absolute;
  left: 0;
  top: 7px;
  z-index: 1;
  width: var(--size);
  height: var(--size);
  border-radius: 999px;
  border: 2px solid var(--line);
  background: var(--bg);
  flex: none;
  margin: 2px;
}

.step .label {
  user-select: none;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
  max-width: 200px;
  margin-top: 0;
  width: 100%;
}

.progress.horizontal .step .label {
  margin-top: 8px;
  /* Fixed spacing in horizontal mode */
  font-size: 12px;
  /* Slightly smaller for horizontal layout */
  max-width: 100px;
  /* Smaller max width for horizontal */
}

/* ===== PROGRESS STATES ===== */
.step.done .dot {
  background: var(--done);
  border-color: var(--done)
}

.step.done .label {
  color: var(--done)
}

.step.active .dot {
  background: var(--accent);
  border-color: var(--accent)
}

.step.active .label {
  color: var(--accent)
}

.step.upcoming .dot {
  background: var(--bg);
  border-color: var(--line)
}

.step.upcoming .label {
  color: var(--upcoming)
}

/* ===== CONNECTORS ===== */
.progress .step::before {
  display: none;
}

.links {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* ===== CONTROLS BAR ===== */
.bar {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 24px;
  padding: 20px 0 0 0;
  justify-content: center;
  align-items: center;
  min-height: 60px;
  border-top: 1px solid var(--line);
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

.bar button {
  padding: 12px 16px;
  min-width: 52px;
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.bar button:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.muted {
  color: var(--muted)
}

/* ===== COLOR PICKER DIALOG ===== */
.color-dialog {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.color-dialog.open {
  display: flex;
}

.color-dialog-content {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  max-width: 320px;
  width: 90%;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.color-dialog h3 {
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
  text-align: center;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.color-option {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all 0.2s ease;
  position: relative;
}

.color-option:hover {
  transform: scale(1.1);
  border-color: var(--line);
}

.color-option.selected {
  border-color: var(--fg);
  transform: scale(1.1);
}

.color-option.selected::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-weight: bold;
  font-size: 16px;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.5);
}

.color-dialog-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.color-btn-cancel,
.color-btn-apply {
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
}

.color-btn-cancel:hover {
  background: var(--line);
}

.color-btn-apply {
  background: #22c55e;
  border-color: #22c55e;
  color: #000000;
}

.color-btn-apply:hover {
  background: #16a34a;
  border-color: #16a34a;
}

/* ===== SEO CONTENT SECTIONS ===== */
.seo-content {
  background: var(--bg);
  border-top: 1px solid var(--line);
  padding: 60px 0;
}

.seo-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.seo-section {
  margin-bottom: 80px;
}

.seo-section:last-child {
  margin-bottom: 0;
}

.seo-header {
  text-align: center;
  margin-bottom: 48px;
}

.seo-header .seo-icon {
  color: var(--accent);
  margin-bottom: 16px;
}

.seo-header h2 {
  font-size: 32px;
  font-weight: 700;
  color: var(--fg);
  margin: 0;
  line-height: 1.2;
}

.seo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 32px;
  margin-top: 48px;
}

.seo-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.seo-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), #22c55e);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.seo-card:hover::before {
  transform: scaleX(1);
}

.seo-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  border-color: var(--accent);
}

.seo-card svg {
  color: var(--accent);
  margin-bottom: 20px;
}

.seo-card h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--fg);
  margin: 0 0 16px 0;
  line-height: 1.3;
}

.seo-card p {
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
  font-size: 15px;
}

/* Keywords Section */
.seo-keywords {
  background: rgba(34, 197, 94, 0.05);
  border-radius: 16px;
  padding: 48px;
  border: 1px solid rgba(34, 197, 94, 0.1);
}

.keywords-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 32px;
}

.keyword-tag {
  background: var(--accent);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: default;
}

.keyword-tag:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
  .seo-content {
    padding: 40px 0;
  }
  
  .seo-container {
    padding: 0 16px;
  }
  
  .seo-section {
    margin-bottom: 60px;
  }
  
  .seo-header h2 {
    font-size: 24px;
  }
  
  .seo-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  
  .seo-card {
    padding: 24px;
  }
  
  .seo-keywords {
    padding: 32px 24px;
  }
}

/* Hide SEO content in view-only mode */
.view-only .seo-content {
  display: none;
}

/* ===== SUPPORT DIALOG ===== */
.support-dialog {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

.support-dialog.open {
  display: flex;
}

.support-dialog-content {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.support-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 24px 0 24px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}

.support-dialog-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  color: var(--fg);
  padding-bottom: 16px;
}

.support-close-btn {
  background: none;
  border: none;
  font-size: 32px;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.support-close-btn:hover {
  background: var(--line);
  color: var(--fg);
}

.support-dialog-body {
  padding: 0 24px 24px 24px;
}

.support-dialog-body p {
  margin: 0 0 24px 0;
  line-height: 1.6;
  color: var(--fg);
}

.support-links {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.support-link {
  display: block;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.2s ease;
  background: var(--bg);
}

.support-link:hover {
  border-color: #ff6b6b;
  background: rgba(255, 107, 107, 0.05);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 107, 107, 0.15);
}

.support-link-name {
  font-weight: 600;
  font-size: 16px;
  color: var(--fg);
  margin-bottom: 4px;
}

.support-link-desc {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.4;
}

/* View-only mode hides editor and specific buttons */
.view-only .editor {
  display: none
}

.view-only .wrap {
  max-width: none;
  padding: 0;
  gap: 0;
}

.view-only .header-container {
  display: none;
}

.view-only .config-container {
  display: none;
}

.view-only .progress-container {
  padding: 0;
  position: relative;
  min-height: auto;
}

.view-only .progress-shell {
  border: none;
  border-radius: 0;
  padding: 12px;
  min-height: auto;
  height: fit-content;
  display: flex;
  flex-direction: column;
  overflow: visible;
}

/* Header section with title only */
.view-only .progress-header {
  display: none;
}

.view-only .progress-title {
  display: none;
}

/* Hide all navigation bars in pop-out view */
.view-only .bar {
  display: none;
}

.view-only .normal-bar {
  display: none;
}

/* Hide normal elements in pop-out view */
.view-only #lessonHeaderNormal {
  display: none;
}

.view-only .progress {
  /* Inherit ALL styles from main progress - no overrides */
  overflow: visible;
  max-height: none;
  min-height: auto;
  height: fit-content;
}

.view-only .progress.horizontal {
  /* Inherit ALL styles from main progress.horizontal - no overrides */
  overflow: visible;
  height: fit-content;
}

.view-only .progress.vertical {
  /* Inherit ALL styles from main progress.vertical - no overrides */
  overflow: visible;
  height: fit-content;
}

.view-only .bar button {
  padding: 4px 8px;
  font-size: 11px;
  min-width: 28px;
  border-radius: 4px;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.view-only .bar button:hover {
  opacity: 1;
  transform: none;
  box-shadow: none;
}

.view-only .bar button svg {
  width: 14px;
  height: 14px;
}

/* Remove ALL view-only step and progress overrides - inherit from main styles */

/* Better spacing for horizontal mode */
.view-only .progress.horizontal {
  gap: calc(var(--gap) * 0.8);
}

/* Website link in top right corner for pop-out view */
.view-only .website-link {
  display: block;
  position: fixed;
  top: 8px;
  right: 8px;
  font-size: 10px;
  color: var(--muted);
  text-decoration: none;
  z-index: 1000;
  opacity: 0.7;
}

.view-only .website-link:hover {
  color: var(--fg);
  opacity: 1;
}

/* Hide specific buttons and footer text in pop-out view */
.view-only #openPop,
.view-only #copyLink,
.view-only .tiny {
  display: none !important;
}

/* ===== ACCESSIBILITY ===== */
/* Ultra-minimal focus */
.progress-shell:focus-within {
  outline: 2px solid var(--line);
  outline-offset: 3px
}
