/* ============ DESIGN TOKENS ============ */
:root {
  --radius: 0.65rem;
  --background: oklch(1 0 0);
  --foreground: oklch(0.141 0.005 285.823);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.141 0.005 285.823);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.141 0.005 285.823);
  --primary: oklch(0.488 0.243 264.376);
  --primary-foreground: oklch(0.97 0.014 254.604);
  --secondary: oklch(0.967 0.001 286.375);
  --secondary-foreground: oklch(0.21 0.006 285.885);
  --muted: oklch(0.967 0.001 286.375);
  --muted-foreground: oklch(0.552 0.016 285.938);
  --accent: oklch(0.967 0.001 286.375);
  --accent-foreground: oklch(0.21 0.006 285.885);
  --destructive: oklch(0.577 0.245 27.325);
  --border: oklch(0.92 0.004 286.32);
  --input: oklch(0.92 0.004 286.32);
  --ring: oklch(0.708 0 0);
  --chart-1: oklch(0.809 0.105 251.813);
  --chart-2: oklch(0.623 0.214 259.815);
  --chart-3: oklch(0.546 0.245 262.881);
  --chart-4: oklch(0.488 0.243 264.376);
  --chart-5: oklch(0.424 0.199 265.638);
  --sidebar: oklch(0.985 0 0);
  --sidebar-foreground: oklch(0.141 0.005 285.823);
  --sidebar-primary: oklch(0.546 0.245 262.881);
  --sidebar-primary-foreground: oklch(0.97 0.014 254.604);
  --sidebar-accent: oklch(0.967 0.001 286.375);
  --sidebar-accent-foreground: oklch(0.21 0.006 285.885);
  --sidebar-border: oklch(0.92 0.004 286.32);
  --sidebar-ring: oklch(0.708 0 0);

  /* Layout */
  --sidebar-width: 350px;
  --header-height: 56px;
  --content-padding: 24px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.dark {
  --background: oklch(0.141 0.005 285.823);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.21 0.006 285.885);
  --card-foreground: oklch(0.985 0 0);
  --popover: oklch(0.21 0.006 285.885);
  --popover-foreground: oklch(0.985 0 0);
  --primary: oklch(0.488 0.243 264.376);
  --primary-foreground: oklch(0.97 0.014 254.604);
  --secondary: oklch(0.274 0.006 286.033);
  --secondary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.274 0.006 286.033);
  --muted-foreground: oklch(0.705 0.015 286.067);
  --accent: oklch(0.274 0.006 286.033);
  --accent-foreground: oklch(0.985 0 0);
  --destructive: oklch(0.704 0.191 22.216);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.556 0 0);
  --chart-1: oklch(0.809 0.105 251.813);
  --chart-2: oklch(0.623 0.214 259.815);
  --chart-3: oklch(0.546 0.245 262.881);
  --chart-4: oklch(0.488 0.243 264.376);
  --chart-5: oklch(0.424 0.199 265.638);
  --sidebar: oklch(0.21 0.006 285.885);
  --sidebar-foreground: oklch(0.985 0 0);
  --sidebar-primary: oklch(0.623 0.214 259.815);
  --sidebar-primary-foreground: oklch(0.97 0.014 254.604);
  --sidebar-accent: oklch(0.274 0.006 286.033);
  --sidebar-accent-foreground: oklch(0.985 0 0);
  --sidebar-border: oklch(1 0 0 / 10%);
  --sidebar-ring: oklch(0.439 0 0);
}

/* ============ RESET & BASE ============ */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    Arial,
    sans-serif;
  background-color: var(--background);
  color: var(--foreground);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============ SCROLLABLE UTILITY ============ */
.scrollable {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.scrollable::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.scrollable::-webkit-scrollbar-track {
  background: transparent;
}

.scrollable::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}

/* ============ APP LAYOUT ============ */
.app-layout {
  display: grid;
  grid-template-columns: 1fr auto;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ============ RIGHT SIDEBAR ============ */
.right-sidebar {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--card);
  border-left: 1px solid var(--border);
  overflow: hidden;
  transition:
    width var(--transition-normal),
    min-width var(--transition-normal);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: var(--header-height);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
  color: var(--foreground);
}

.sidebar-brand svg {
  color: var(--primary);
  flex-shrink: 0;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
}

.shortcuts-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 11px;
  color: var(--muted-foreground);
}

.shortcuts-hint span {
  display: flex;
  align-items: center;
  gap: 4px;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: inherit;
  font-size: 10px;
  font-weight: 500;
  color: var(--muted-foreground);
}

/* ============ SIDEBAR GROUPS ============ */
.sidebar-group {
  margin-bottom: 20px;
}

.sidebar-group-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 8px;
  margin-bottom: 8px;
}

/* ============ SEARCH FIELD ============ */
.search-field {
  position: relative;
  display: flex;
  align-items: center;
}

.search-field input {
  width: 100%;
  height: 36px;
  padding: 0 32px;
  border: 1px solid var(--input);
  border-radius: var(--radius);
  background: transparent;
  color: var(--foreground);
  font-size: 13px;
  font-family: inherit;
  transition:
    border-color var(--transition-fast),
    box-shadow var(--transition-fast);
}

.search-field input::placeholder {
  color: var(--muted-foreground);
}

.search-field input:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ring) 30%, transparent);
}

/* Remove default search input X on webkit */
.search-field input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.search-icon {
  position: absolute;
  left: 10px;
  color: var(--muted-foreground);
  pointer-events: none;
}

.search-clear {
  position: absolute;
  right: 4px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  color: var(--muted-foreground);
  cursor: pointer;
  transition:
    background var(--transition-fast),
    color var(--transition-fast);
}

.search-clear:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

/* ============ PROGRESS BAR ============ */
.progress-container {
  padding: 0 8px;
}

.progress-track {
  height: 6px;
  background: var(--secondary);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  width: 0%;
  transition: width 500ms ease;
}

.progress-text {
  display: block;
  font-size: 12px;
  color: var(--muted-foreground);
  margin-top: 6px;
}

/* ============ MODULE NAVIGATION ============ */
#moduleNav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.module-btn {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition:
    background var(--transition-fast),
    color var(--transition-fast);
  color: var(--foreground);
}

.module-btn:hover {
  background: var(--sidebar-accent);
  color: var(--sidebar-accent-foreground);
}

.module-btn.active {
  background: var(--sidebar-accent);
  color: var(--sidebar-accent-foreground);
}

.module-btn-label {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
}

.module-btn-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.module-progress-text {
  font-size: 11px;
  color: var(--muted-foreground);
  min-width: 36px;
  font-variant-numeric: tabular-nums;
}

.module-btn.active .module-progress-text {
  color: var(--primary-foreground);
  opacity: 0.8;
}

.module-progress-bar {
  flex: 1;
  height: 3px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.module-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 300ms ease;
}

/* ============ MODULE ACCORDION ============ */
.module-accordion-item {
  border-radius: var(--radius);
  overflow: hidden;
}

.module-accordion-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  color: var(--foreground);
  transition: background var(--transition-fast);
}

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

.module-accordion-header.active {
  background: var(--sidebar-accent);
}

.module-accordion-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.module-accordion-label {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.module-accordion-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.module-accordion-chevron {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  color: var(--muted-foreground);
  transition: transform var(--transition-fast);
  margin-left: auto;
}

.module-accordion-item.expanded .module-accordion-chevron {
  transform: rotate(180deg);
}

.module-accordion-lessons {
  display: none;
  flex-direction: column;
  gap: 1px;
  padding: 2px 0px 6px;
}

.module-accordion-item.expanded .module-accordion-lessons {
  display: flex;
}

/* ============ MAIN CONTENT ============ */
.main-content {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--background);
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: var(--header-height);
  padding: 0 var(--content-padding);
  border-bottom: 1px solid var(--border);
  background: var(--card);
  flex-shrink: 0;
}

.content-course-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

/* ============ CONTENT BODY ============ */
.content-body {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  overflow: hidden;
}

/* ============ VIDEO SECTION ============ */
.video-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: var(--content-padding);
  overflow-y: auto;
}

.video-container,
.lesson-info {
  width: 100%;
  max-width: calc((100vh - 250px) * 16 / 9);
  margin-left: auto;
  margin-right: auto;
}

.video-container {
  aspect-ratio: 16 / 9;
  background: var(--secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.video-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.placeholder {
  color: var(--muted-foreground);
  font-size: 14px;
}

.lesson-info {
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.lesson-info-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--foreground);
  line-height: 1.4;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.control-select-inline {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--background);
  color: var(--foreground);
  font-size: 13px;
  cursor: pointer;
  transition: border-color var(--transition-fast);
  height: 35.99px;
}

.control-select-inline:hover {
  border-color: var(--primary);
}

.control-select-inline:focus {
  outline: none;
  border-color: var(--primary);
}

.autoplay-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.autoplay-toggle.active {
  background-color: var(--primary);
  color: var(--primary-foreground);
}

/* Theater mode toggle button */
.theater-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 8px;
  transition: all var(--transition-fast);
}

.theater-toggle.active {
  background-color: var(--primary);
  color: var(--primary-foreground);
}

/* Video band wrapper */
.video-band {
  width: 100%;
}

/* Theater mode layout */
.app-layout.theater-mode .right-sidebar {
  width: 0;
  min-width: 0;
  border-left: none;
  overflow: hidden;
}

.app-layout.theater-mode .video-section {
  padding: 0;
  gap: 0;
  align-items: center;
  justify-content: flex-start;
}

/* Faixa escura apenas na linha do vídeo */
.app-layout.theater-mode .video-band {
  background: var(--background);
  display: flex;
  justify-content: center;
}

/* Vídeo centralizado com limite de tamanho (estilo YouTube) */
.app-layout.theater-mode .video-container {
  max-width: min(1280px, calc((100vh - 180px) * 16 / 9), 100%);
  width: 100%;
  border-radius: 0;
  border: none;
  background: #000;
}

/* lesson-info usa o background padrão do tema */
.app-layout.theater-mode .lesson-info {
  max-width: min(1280px, 100%);
  width: 100%;
  padding: 12px 24px;
}

.lesson-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-shrink: 0;
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition:
    background var(--transition-fast),
    color var(--transition-fast),
    border-color var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
}

.btn svg {
  flex-shrink: 0;
}

/* Outline variant */
.btn-outline {
  background: transparent;
  color: var(--foreground);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.btn-outline:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-outline:disabled:hover {
  background: transparent;
}

.btn-outline[data-completed="true"] {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}

.btn-outline[data-completed="true"]:hover {
  opacity: 0.9;
}

/* Ghost variant */
.btn-ghost {
  background: transparent;
  color: var(--muted-foreground);
  border: none;
}

.btn-ghost:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}


/* ============ DRAG HANDLES ============ */
.drag-handle {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  padding: 0 2px;
  cursor: grab;
  opacity: 0;
  color: var(--text-muted);
  transition: opacity 0.15s;
}
.drag-handle:active {
  cursor: grabbing;
}
.lesson-item:hover .drag-handle,
.module-btn:hover .drag-handle {
  opacity: 1;
}

/* ============ LESSON ITEMS ============ */
.lesson-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  color: var(--foreground);
  background: transparent;
  transition: background var(--transition-fast);
}

.lesson-item:hover {
  background: var(--sidebar-accent);
}

.lesson-item.active {
  background: var(--sidebar-accent);
  font-weight: 600;
}

/* Completion indicators */
.lesson-item.completed::before {
  content: "";
  width: 18px;
  height: 18px;
  min-width: 18px;
  border-radius: 50%;
  background: var(--primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 10px;
  flex-shrink: 0;
}

.lesson-item:not(.completed)::before {
  content: "";
  width: 18px;
  height: 18px;
  min-width: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: transparent;
  flex-shrink: 0;
}

.lesson-number {
  font-weight: 500;
  color: var(--muted-foreground);
  min-width: 28px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.lesson-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.no-results {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted-foreground);
  font-size: 13px;
}

/* ============ RESPONSIVE: TABLET ============ */
@media (max-width: 1023px) {
  .app-layout {
    grid-template-columns: 1fr 260px;
  }
}

/* ============ RESPONSIVE: MOBILE ============ */
@media (max-width: 767px) {
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
  }

  .main-content {
    height: auto;
    overflow: visible;
  }

  .content-body {
    overflow: visible;
  }

  .video-section {
    overflow: visible;
  }

  .right-sidebar {
    width: 100%;
    min-width: 100%;
    height: auto;
    max-height: 400px;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .lesson-info {
    flex-direction: column;
    align-items: flex-start;
  }

  .lesson-controls {
    width: 100%;
    flex-wrap: wrap;
  }

  .content-header {
    padding: 0 16px;
  }

  .video-section {
    padding: 16px;
  }

}

/* ============ PRINT STYLES ============ */
@media print {
  .right-sidebar,
  .content-header,
  .video-section,
  .lesson-controls {
    display: none;
  }

  .app-layout {
    display: block;
    height: auto;
  }

  .main-content {
    height: auto;
    overflow: visible;
  }

  .content-body {
    display: block;
  }

  .lesson-item {
    page-break-inside: avoid;
  }
}

/* ============ ACCESSIBILITY ============ */
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ============ VIEW SYSTEM ============ */
.view {
  display: none;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

.view.active {
  display: block;
}

#course-editor-view.active {
  overflow-y: auto;
}

/* ============ HOME LAYOUT ============ */
.home-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--background);
}


.home-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--foreground);
}

.home-brand svg {
  color: var(--primary);
  flex-shrink: 0;
}

.home-title {
  font-size: 16px;
  font-weight: 700;
}

.home-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.home-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

/* ============ COURSE GRID ============ */
#courseSections {
  max-width: 1280px;
  margin: 0 auto;
}

.course-section {
  margin-bottom: 40px;
}

.course-section-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--foreground);
}

.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.course-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition:
    box-shadow var(--transition-normal),
    border-color var(--transition-normal),
    transform var(--transition-normal);
}

.course-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.dark .course-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.course-card-thumbnail {
  height: 160px;
  background: var(--secondary);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  color: var(--muted-foreground);
}

.course-card-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

.course-card-body {
  padding: 16px;
}

.course-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.course-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--muted-foreground);
  margin-bottom: 12px;
}

.course-card .progress-track {
  height: 4px;
}

.course-card-footer {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  padding: 0 12px 12px;
}

/* ============ EMPTY STATE ============ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 80px 20px;
  text-align: center;
  color: var(--muted-foreground);
}

.empty-state svg {
  opacity: 0.4;
}

.empty-state h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--foreground);
}

.empty-state p {
  font-size: 14px;
  max-width: 400px;
}

/* ============ PRIMARY BUTTON ============ */
.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  border: 1px solid var(--primary);
}

.btn-primary:hover {
  opacity: 0.9;
}

/* ============ SMALL BUTTON ============ */
.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

/* ============ ICON BUTTON ============ */
.btn-icon {
  width: 30px;
  height: 30px;
  padding: 0;
}

.btn-sm.btn-icon {
  width: 30px;
  padding: 0;
}

/* Destructive outline variant */
.btn-outline-destructive {
  color: var(--destructive);
  border-color: color-mix(in srgb, var(--destructive) 35%, transparent);
}

.btn-outline-destructive:hover {
  background: color-mix(in srgb, var(--destructive) 10%, transparent);
  border-color: var(--destructive);
  color: var(--destructive);
}

/* ============ SIDEBAR GROUP LABEL FLEX ============ */
.sidebar-group-label-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ============ PANEL HEADER FLEX ============ */
.panel-header-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ============ MODULE BUTTON CONTENT ============ */
.module-btn-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.module-btn-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.module-btn:hover .module-btn-actions {
  opacity: 1;
}

/* ============ ACTION BUTTONS (inline edit/delete) ============ */
.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--foreground);
  cursor: pointer;
  transition:
    background var(--transition-fast),
    border-color var(--transition-fast),
    color var(--transition-fast);
}

.action-btn:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.action-delete:hover {
  background: var(--accent);
  color: var(--destructive);
}

.module-btn.active .action-btn {
  color: var(--primary-foreground);
  opacity: 0.7;
}

.module-btn.active .action-btn:hover {
  opacity: 1;
  background: hsl(0 0% 100% / 0.2);
}

.module-btn.active .action-delete:hover {
  background: var(--destructive);
  color: var(--destructive-foreground);
}

/* Lesson actions */
.lesson-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--transition-fast);
  flex-shrink: 0;
}

.lesson-item:hover .lesson-actions {
  opacity: 1;
}

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.15);
}

.dark .modal {
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
}

.modal-small {
  max-width: 400px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--foreground);
}

.modal-close {
  width: 32px;
  height: 32px;
  padding: 0;
}

.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.modal-tab {
  flex: 1;
  padding: 10px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--muted-foreground);
  cursor: pointer;
  transition:
    color var(--transition-fast),
    border-color var(--transition-fast);
}

.modal-tab:hover {
  color: var(--foreground);
}

.modal-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.modal-body {
  padding: 20px;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.modal-action {
  width: 100%;
  margin-top: 16px;
}

/* ============ DIALOG (confirm / alert customizados) ============ */
.dialog-icon {
  display: inline-flex;
  align-items: center;
  margin-right: 6px;
  flex-shrink: 0;
}

.dialog-icon svg {
  display: block;
}

.dialog-message {
  font-size: 14px;
  color: var(--muted-foreground);
  margin: 0 0 20px;
  line-height: 1.6;
}

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

.btn-dialog {
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition:
    background 0.15s,
    color 0.15s;
}

.btn-dialog-primary {
  background: var(--primary);
  color: #fff;
}
.btn-dialog-primary:hover {
  opacity: 0.9;
}

.btn-dialog-secondary {
  background: var(--secondary);
  color: var(--muted-foreground);
  border: 1px solid var(--border);
}
.btn-dialog-secondary:hover {
  background: var(--border);
  color: var(--foreground);
}

.btn-dialog-danger {
  background: #ef4444;
  color: #fff;
}
.btn-dialog-danger:hover {
  background: #dc2626;
}

/* ============ FORM ELEMENTS ============ */
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--foreground);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  height: 38px;
  padding: 4px 12px;
  border: 1px solid var(--input);
  border-radius: var(--radius);
  background: transparent;
  color: var(--foreground);
  font-size: 14px;
  font-family: inherit;
  transition:
    border-color var(--transition-fast),
    box-shadow var(--transition-fast);
  outline: none;
}

.form-input:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 50%, transparent);
}

.form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--input);
  border-radius: var(--radius);
  background: var(--background);
  color: var(--foreground);
  font-size: 13px;
  font-family: monospace;
  resize: vertical;
  min-height: 120px;
  transition:
    border-color var(--transition-fast),
    box-shadow var(--transition-fast);
}

.form-textarea:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ring) 30%, transparent);
}

.form-error {
  font-size: 13px;
  color: var(--destructive);
  margin-top: 8px;
  padding: 8px 12px;
  background: hsl(0 84.2% 60.2% / 0.1);
  border-radius: var(--radius);
}

/* ============ SETTINGS DROPDOWN ============ */
.settings-dropdown {
  position: relative;
}

.settings-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 4px;
  z-index: 60;
}

.dark .settings-menu {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.settings-menu.open {
  display: block;
}

.settings-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--foreground);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.settings-menu-item:hover {
  background: var(--accent);
}

.settings-menu-item svg {
  color: var(--muted-foreground);
  flex-shrink: 0;
}

.settings-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* Theme labels in settings menu */
.theme-label-dark {
  display: none;
}

.dark .theme-label-light {
  display: none;
}

.dark .theme-label-dark {
  display: inline;
}

/* ============ THEME TOGGLE ============ */
.dark .icon-sun {
  display: none;
}

.dark .icon-moon {
  display: block;
}

.icon-sun {
  display: block;
}

.icon-moon {
  display: none;
}

/* ============ IMPORT HELP ============ */
.import-help {
  margin-bottom: 4px;
}

.import-help-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: 8px;
}

.import-steps {
  font-size: 12px;
  color: var(--muted-foreground);
  padding-left: 20px;
  margin-bottom: 12px;
  line-height: 1.8;
}

.import-steps strong {
  color: var(--foreground);
}

.import-steps kbd {
  margin: 0 2px;
}

/* ============ CODE TEMPLATE ============ */
.code-template {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.code-template-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--secondary);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 500;
  color: var(--muted-foreground);
}

.code-template-code {
  padding: 12px;
  margin: 0;
  font-family: "Consolas", "Monaco", "Courier New", monospace;
  font-size: 11px;
  line-height: 1.5;
  color: var(--foreground);
  background: var(--background);
  overflow-x: auto;
  white-space: pre;
  max-height: 100px;
  overflow-y: auto;
}

/* ============ INLINE MODAL TABS ============ */
.inline-modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin: -20px -20px 16px -20px;
}

/* ============ EXTENSION PROMO TAB ============ */
.extension-promo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 8px 0;
  text-align: center;
}

.extension-screenshot {
  width: 100%;
  max-width: 420px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  object-fit: cover;
}

.extension-promo-desc {
  font-size: 13px;
  color: var(--muted-foreground);
  line-height: 1.5;
  max-width: 360px;
}

.extension-install-btn {
  width: 100%;
  max-width: 280px;
  justify-content: center;
}

/* ============ FOOTER ============ */
.home-footer,
.course-footer {
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--card);
  text-align: center;
}

.home-footer p,
.course-footer p {
  color: var(--muted-foreground);
  margin: 0;
}

.home-footer a,
.course-footer a {
  color: var(--primary);
  text-decoration: none;
  transition: opacity var(--transition-fast);
}

.home-footer a:hover,
.course-footer a:hover {
  opacity: 0.8;
  text-decoration: underline;
}

.home-footer {
  padding: 16px 32px;
}

.home-footer p {
  font-size: 12px;
}

.course-footer {
  padding: 12px 16px;
}

.course-footer p {
  font-size: 11px;
}

/* ============ COURSE EDITOR VIEW ============ */
.editor-layout {
  min-height: 100vh;
  background: var(--background);
  padding: 32px 16px 64px;
}

.editor-container {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.editor-header {
  display: flex;
  align-items: center;
  gap: 16px;
}


.editor-heading {
  font-size: 20px;
  font-weight: 600;
  color: var(--foreground);
  margin: 0;
}

.editor-course-name {
  font-size: 16px;
  font-weight: 500;
}

.editor-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 10px);
  padding: 20px 24px;
}

.editor-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: 4px;
}

.editor-section-meta {
  font-size: 13px;
  color: var(--muted-foreground);
}

.editor-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.editor-progress-card {
  margin-top: 12px;
}

.editor-progress-card .progress-track {
  margin-top: 10px;
}

.editor-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--foreground);
}

.editor-progress-pct {
  font-weight: 600;
  color: var(--primary);
}

/* Module list */
.editor-module-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.editor-module {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition-fast);
}

.editor-module-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition-fast);
}

.editor-module-header:hover {
  background: color-mix(in srgb, var(--foreground) 8%, var(--background));
}

.editor-module-header:hover .editor-module-actions {
  opacity: 1;
}

.editor-module-header:hover .editor-drag-handle {
  opacity: 1;
}

.editor-drag-handle {
  opacity: 0;
  cursor: grab;
  color: var(--muted-foreground);
  display: flex;
  align-items: center;
  padding: 2px;
  flex-shrink: 0;
  transition: opacity var(--transition-fast);
}

.editor-drag-handle:active {
  cursor: grabbing;
}

.editor-module-chevron {
  color: var(--muted-foreground);
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin-left: 10px;
  margin-right: 10px;
}

.editor-module-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.editor-module-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.editor-module-meta {
  font-size: 12px;
  color: var(--muted-foreground);
}

.editor-module-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  opacity: 0;
  transition: opacity var(--transition-fast);
  flex-shrink: 0;
}

/* Lesson list within module */
.editor-lesson-list {
  border-top: 1px solid var(--border);
}

.editor-lesson-list.hidden {
  display: none;
}

.editor-lessons-sortable {
  display: flex;
  flex-direction: column;
}

.editor-lesson-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition-fast);
  cursor: default;
}

.editor-lesson-item:last-child {
  border-bottom: none;
}

.editor-lesson-item:hover {
  background: color-mix(in srgb, var(--foreground) 4%, var(--background));
}

.editor-lesson-item:hover .editor-drag-handle {
  opacity: 1;
}

.editor-lesson-item:hover .lesson-actions {
  opacity: 1;
}

.editor-lesson-number {
  width: 34px;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted-foreground);
  text-align: center;
}

.editor-lesson-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--foreground);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Reuse existing .lesson-actions opacity pattern */
.editor-lesson-item .lesson-actions {
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.editor-lesson-item:hover .lesson-actions {
  opacity: 1;
}

.editor-add-lesson-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 9px 14px 9px 36px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted-foreground);
  text-align: left;
  transition:
    background var(--transition-fast),
    color var(--transition-fast);
}

.editor-add-lesson-btn:hover {
  background: var(--secondary);
  color: var(--primary);
}

.editor-add-module-btn {
  width: 100%;
  margin-top: 4px;
  justify-content: center;
  gap: 6px;
}

/* ============ RESPONSIVE: HOME TABLET ============ */
@media (max-width: 767px) {
.home-content {
    padding: 16px;
  }

  .course-grid {
    grid-template-columns: 1fr;
  }

  .home-title {
    font-size: 14px;
  }

  .home-actions .btn span {
    display: none;
  }

  .home-footer {
    padding: 12px 16px;
  }

  .home-footer p {
    font-size: 11px;
  }

  /* Editor responsive */
  .editor-layout {
    padding: 20px 12px 48px;
  }

  .editor-container {
    gap: 16px;
  }

  .editor-section {
    padding: 16px;
  }

  .editor-heading {
    font-size: 18px;
  }

  .editor-module-header {
    padding: 10px 12px;
  }

  .editor-lesson-item {
    padding: 10px 12px;
  }

  .editor-add-lesson-btn {
    padding: 8px 12px 8px 28px;
  }

  .editor-module-actions,
  .editor-lesson-item .lesson-actions {
    opacity: 1;
  }

  .editor-drag-handle {
    opacity: 0.5;
  }
}
