@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700&display=swap');

:root {
  --font-body: 'Manrope', system-ui, sans-serif;
  --bg-primary: #f6f7f3;
  --bg-secondary: #ffffff;
  --bg-tertiary: #eceee8;
  --bg-sidebar: #f1f3ee;
  --border-color: #d9ddd2;
  --text-primary: #1d211c;
  --text-secondary: #586052;
  --text-muted: #858d7c;
  --accent: #107c41;
  --accent-light: #e4f1e8;
  --accent-hover: #0b5d31;
  --success: #107c41;
  --success-light: #e4f1e8;
  --error: #b42318;
  --error-light: #fae6e3;
  --warning: #946200;
  --shadow-sm: 0 1px 2px rgba(29, 33, 28, 0.08);
  --shadow-md: 0 6px 18px rgba(29, 33, 28, 0.08);
  --sidebar-width: 320px;
  --header-height: 68px;
  --transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease, opacity 160ms ease;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
}

[data-theme="dark"] {
  --bg-primary: #151713;
  --bg-secondary: #1d201a;
  --bg-tertiary: #282d24;
  --bg-sidebar: #181b16;
  --border-color: #33392f;
  --text-primary: #f2f4ee;
  --text-secondary: #c1c8b8;
  --text-muted: #89917e;
  --accent: #4fb477;
  --accent-light: #203d2d;
  --accent-hover: #68c489;
  --success: #4fb477;
  --success-light: #203d2d;
  --error: #ffb4aa;
  --error-light: #442420;
  --warning: #d4a742;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.24);
  --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.22);
}

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

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  transition: var(--transition);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.app-container {
  display: flex;
  width: 100vw;
  min-height: 100vh;
}

.auth-overlay,
.admin-view {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--bg-primary);
  padding: 24px;
}

.auth-overlay {
  display: grid;
  place-items: center;
}

.admin-view {
  display: block;
  overflow: auto;
}

.auth-overlay[hidden],
.admin-view[hidden],
[hidden] {
  display: none !important;
}

.auth-card {
  width: min(420px, 100%);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 28px;
}

.password-field {
  position: relative;
}

.auth-logo,
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--text-primary);
}

.auth-logo {
  margin-bottom: 24px;
}

.auth-card h1 {
  font-size: 24px;
  line-height: 1.2;
  margin-bottom: 8px;
}

.auth-card p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 22px;
}

.auth-card label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}

.auth-card input {
  width: 100%;
  height: 44px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 0 12px;
  outline: none;
  transition: var(--transition);
}

.password-field input {
  padding-right: 92px;
}

.password-toggle {
  position: absolute;
  right: 6px;
  top: 6px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  transition: var(--transition);
}

.password-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.auth-card input + label {
  margin-top: 14px;
}

.auth-card input:focus,
.quiz-text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.auth-error {
  min-height: 20px;
  margin: 10px 0 16px;
  color: var(--error);
  font-size: 13px;
  line-height: 1.4;
}

.admin-shell {
  width: min(1320px, 100%);
  min-height: calc(100vh - 48px);
  margin: 0 auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.admin-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
}

.admin-header h2 {
  font-size: 20px;
  margin-bottom: 4px;
}

.admin-header p {
  color: var(--text-secondary);
  font-size: 14px;
}

.admin-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--border-color);
}

.admin-summary div {
  padding: 18px 24px;
  border-right: 1px solid var(--border-color);
}

.admin-summary div:last-child {
  border-right: none;
}

.admin-summary strong {
  display: block;
  font-size: 24px;
  margin-bottom: 4px;
}

.admin-summary span {
  color: var(--text-secondary);
  font-size: 13px;
}

.admin-tabs {
  display: flex;
  gap: 6px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-primary);
}

.admin-tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 9px 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.admin-tab:hover,
.admin-tab.is-active {
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border-color: var(--border-color);
}

.admin-tab-panel[hidden] {
  display: none;
}

.admin-table-wrap {
  overflow-x: auto;
  max-height: 360px;
}

.admin-progress-section,
.admin-log-section {
  min-height: 0;
}

.admin-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px 10px;
}

.admin-section-header h3 {
  font-size: 16px;
}

.admin-section-header p {
  color: var(--text-secondary);
  font-size: 13px;
}

.progress-table-wrap {
  max-height: 420px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th,
.admin-table td {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
  vertical-align: middle;
}

.admin-table th {
  color: var(--text-secondary);
  background: var(--bg-primary);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}

.admin-table td strong,
.admin-table td span {
  display: block;
}

.admin-table td span,
.admin-table small {
  color: var(--text-secondary);
}

.admin-table td:nth-child(1) {
  white-space: nowrap;
}

.admin-table td:nth-child(2) {
  font-weight: 700;
}

.admin-table td:nth-child(4) {
  max-width: 480px;
  color: var(--text-secondary);
}

.table-progress {
  width: 110px;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 6px;
}

.table-progress span {
  display: block;
  height: 100%;
  background: var(--success);
}

.progress-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 160px;
}

.progress-cell strong {
  font-size: 13px;
}

.muted-value {
  color: var(--text-secondary);
  font-weight: 700;
}

.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 180ms ease;
}

.sidebar-header {
  padding: 22px 20px;
  border-bottom: 1px solid var(--border-color);
}

.logo-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
}

.progress-card {
  margin: 18px 20px;
  padding: 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 14px;
}

.progress-circle-container {
  position: relative;
  width: 60px;
  height: 60px;
  flex: 0 0 auto;
}

.progress-circle-bg {
  fill: none;
  stroke: var(--bg-tertiary);
  stroke-width: 5;
}

.progress-circle-bar {
  fill: none;
  stroke: var(--success);
  stroke-width: 5;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  stroke-dasharray: 172.7;
  stroke-dashoffset: 172.7;
  transition: stroke-dashoffset 240ms ease;
}

.progress-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
}

.progress-info h4 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
}

.progress-info p {
  font-size: 12px;
  color: var(--text-secondary);
}

.syllabus-menu {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 18px;
}

.chapter-container {
  margin-bottom: 8px;
}

.chapter-header {
  width: 100%;
  padding: 11px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
  font-size: 13px;
  font-weight: 700;
  transition: var(--transition);
}

.chapter-header:hover,
.chapter-container.expanded .chapter-header {
  background: var(--bg-secondary);
  border-color: var(--border-color);
}

.chevron {
  font-size: 18px;
  line-height: 1;
  transform: rotate(0deg);
  transition: transform 160ms ease;
}

.chapter-container.expanded .chevron {
  transform: rotate(90deg);
}

.lessons-list {
  display: none;
  padding: 4px 0 6px;
}

.chapter-container.expanded .lessons-list {
  display: block;
}

.lesson-item {
  width: 100%;
  padding: 9px 8px 9px 18px;
  background: transparent;
  border: 0;
  border-left: 2px solid var(--border-color);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  text-align: left;
  transition: var(--transition);
}

.lesson-item:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.lesson-item.active {
  color: var(--text-primary);
  border-left-color: var(--accent);
  background: var(--accent-light);
  font-weight: 600;
}

.lesson-status {
  flex: 0 0 auto;
  min-width: 36px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: right;
}

.lesson-item.completed .lesson-status {
  color: var(--success);
  font-weight: 700;
}

.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-header {
  min-height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 90;
}

.hamburger-btn {
  display: none;
  background: transparent;
  border: 0;
  color: var(--text-primary);
  font-size: 22px;
  cursor: pointer;
}

.header-title-container {
  min-width: 0;
}

.header-title-container h1 {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
}

.header-title-container p {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.theme-toggle-btn,
.admin-panel-btn,
.logout-btn {
  height: 36px;
  padding: 0 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: var(--transition);
}

.theme-toggle-btn:hover,
.admin-panel-btn:hover,
.logout-btn:hover,
.btn-secondary:hover {
  background: var(--bg-tertiary);
}

.admin-panel-btn {
  color: var(--accent);
  border-color: var(--accent);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 260px;
  min-width: 0;
  height: 36px;
  padding: 0 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.user-avatar {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
}

.user-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
}

.content-body {
  flex: 1;
  max-width: 940px;
  width: 100%;
  margin: 0 auto;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.step-navigation {
  display: flex;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.step-tab {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  border-right: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 11px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
}

.step-tab:last-child {
  border-right: 0;
}

.step-tab:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.step-tab.active {
  color: var(--text-primary);
  background: var(--accent-light);
}

.step-tab.completed {
  color: var(--success);
}

.step-icon {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: 1px solid currentColor;
  display: grid;
  place-items: center;
  font-size: 11px;
  line-height: 1;
  flex: 0 0 auto;
}

.active-step-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.content-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  line-height: 1.65;
}

.content-card h2 {
  font-size: 24px;
  line-height: 1.25;
  font-weight: 700;
  margin-bottom: 20px;
}

.content-card h3 {
  font-size: 18px;
  line-height: 1.35;
  font-weight: 700;
  margin-top: 24px;
  margin-bottom: 10px;
}

.content-card p {
  color: var(--text-secondary);
  margin-bottom: 14px;
  font-size: 15px;
}

.content-card ul,
.content-card ol {
  margin-bottom: 18px;
  padding-left: 20px;
  color: var(--text-secondary);
}

.content-card li {
  margin-bottom: 8px;
  font-size: 15px;
}

pre {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  padding: 14px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: 16px 0;
}

code {
  font-family: Consolas, 'Courier New', monospace;
  font-size: 14px;
  color: var(--accent);
  background: var(--accent-light);
  padding: 2px 5px;
  border-radius: 4px;
}

pre code {
  color: var(--text-primary);
  background: transparent;
  padding: 0;
}

.tip-box {
  background: var(--bg-primary);
  border-left: 3px solid var(--accent);
  padding: 14px 16px;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin: 18px 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.tip-box.info {
  border-left-color: var(--success);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  font-size: 14px;
}

th,
td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

th {
  background: var(--bg-primary);
  font-weight: 700;
  color: var(--text-primary);
}

.video-wrapper {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: #000000;
}

.video-wrapper video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #000000;
}

.video-description {
  margin-top: 14px;
}

.quiz-container {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.quiz-question {
  font-size: 16px;
  font-weight: 700;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quiz-option-btn {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  color: var(--text-secondary);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 12px;
}

.quiz-option-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.quiz-option-btn.selected {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--text-primary);
}

.quiz-option-indicator {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: 1px solid var(--text-muted);
  display: grid;
  place-items: center;
  font-size: 12px;
  flex: 0 0 auto;
}

.quiz-option-btn.selected .quiz-option-indicator,
.quiz-option-btn.correct-choice .quiz-option-indicator {
  border-color: var(--success);
  background: var(--success);
  color: #ffffff;
}

.quiz-option-btn.wrong-choice .quiz-option-indicator {
  border-color: var(--error);
  background: var(--error);
  color: #ffffff;
}

.quiz-text-input {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  font-family: Consolas, 'Courier New', monospace;
  font-size: 15px;
  outline: none;
  transition: var(--transition);
}

.quiz-action-bar {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-top: 4px;
}

.btn {
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  background: var(--bg-tertiary);
  color: var(--text-muted);
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-success {
  background: var(--success);
  color: #ffffff;
}

.quiz-feedback {
  margin-top: 4px;
  padding: 16px;
  border-radius: var(--radius-md);
  display: none;
}

.quiz-feedback.show {
  display: block;
}

.quiz-feedback.success {
  background: var(--success-light);
  border: 1px solid var(--success);
}

.quiz-feedback.error {
  background: var(--error-light);
  border: 1px solid var(--error);
}

.feedback-header {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 6px;
}

.feedback-explanation {
  font-size: 14px;
  color: var(--text-secondary);
}

.quiz-option-btn.correct-choice {
  border-color: var(--success);
  background: var(--success-light);
  color: var(--text-primary);
}

.quiz-option-btn.wrong-choice {
  border-color: var(--error);
  background: var(--error-light);
  color: var(--text-primary);
}

.lesson-nav-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border-top: 1px solid var(--border-color);
  padding-top: 24px;
  margin-top: 8px;
}

.nav-direction-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.nav-item-title {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 700;
}

.nav-btn-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.nav-btn-content.right {
  align-items: flex-end;
}

.nav-icon {
  font-size: 15px;
  line-height: 1;
}

.completion-card {
  text-align: left;
}

.trophy-icon {
  display: none;
}

.completion-card h3 {
  font-size: 22px;
  margin-bottom: 10px;
}

.completion-card ul {
  max-width: 620px;
  margin: 18px 0;
}

.final-words {
  font-weight: 700;
  color: var(--success) !important;
}

.confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 250;
}

@media (max-width: 1100px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-md);
  }

  .main-wrapper {
    margin-left: 0;
  }

  .hamburger-btn {
    display: block;
  }

  .main-header {
    padding: 0 20px;
  }
}

@media (max-width: 760px) {
  .main-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 16px;
  }

  .header-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .user-badge {
    flex: 1 1 180px;
    max-width: none;
  }

  .content-body {
    padding: 18px 14px;
  }

  .content-card,
  .auth-card {
    padding: 20px;
  }

  .step-navigation {
    flex-direction: column;
  }

  .step-tab {
    justify-content: flex-start;
    border-right: 0;
    border-bottom: 1px solid var(--border-color);
  }

  .step-tab:last-child {
    border-bottom: 0;
  }

  .lesson-nav-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .lesson-nav-footer .btn {
    width: 100%;
    justify-content: space-between;
  }

  .nav-btn-content,
  .nav-btn-content.right {
    align-items: flex-start;
  }

  .admin-summary {
    grid-template-columns: 1fr;
  }

  .admin-tabs {
    padding: 12px;
    overflow-x: auto;
  }

  .admin-tab {
    flex: 0 0 auto;
  }

  .admin-summary div {
    border-right: 0;
    border-bottom: 1px solid var(--border-color);
  }

  .admin-summary div:last-child {
    border-bottom: 0;
  }
}
