/*
  Learn It — Parent Course
  App-specific semantic aliases + component styles.
  Built on top of tokens.css — link that file before this one.
*/

:root {
  /* ---------- Semantic aliases (light theme default) ---------- */
  --surface-page: #ffffff;
  --surface-sidebar: #fafafc;
  --surface-input: var(--neutral-10);
  --text-primary: var(--neutral-100);
  --text-secondary: var(--neutral-70);
  --text-muted: var(--neutral-50);
  --border-subtle: var(--neutral-10);
  --border-interactive: var(--neutral-20);
  --card-thumb-mix-base: #ffffff;
  --nav-hover-bg: var(--neutral-20);
  --nav-active-bg: #ffffff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-family);
  font-size: var(--text-base);
  font-weight: var(--fw-regular);
  line-height: 1.5;
  background: var(--surface-page);
  color: var(--text-primary);
}

/* ---------- Strict heading scale: size + weight only, no bold/black ---------- */
h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: var(--fw-medium);
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}
h1 { font-size: var(--h1-size); }
h2 { font-size: var(--h2-size); }
h3 { font-size: var(--h3-size); }
h4 { font-size: var(--h4-size); }
h5 { font-size: var(--h5-size); }
h6 { font-size: var(--h6-size); }

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

/* Visible, high-contrast focus ring on every interactive element */
a:focus-visible,
button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--color-primary-500);
  outline-offset: 2px;
}

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 256px;
  flex-shrink: 0;
  background: var(--surface-sidebar);
  border-right: 1px solid var(--border-subtle);
  box-shadow: 6px 0 24px -18px rgba(16, 15, 30, 0.35);
  padding: var(--space-20) var(--space-16);
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease, padding 0.2s ease;
  overflow: hidden;
}

.sidebar.collapsed {
  width: 72px;
  padding: var(--space-20) var(--space-12);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  padding: var(--space-6) var(--space-4) var(--space-20);
}

.sidebar.collapsed .brand {
  justify-content: center;
  height: 34px;
  align-items: center;
}

.sidebar.collapsed .brand-name {
  display: none;
}

/* Collapsed state: show brand-icon by default, swap to collapse-btn on sidebar hover */
.sidebar.collapsed .collapse-btn {
  display: none;
}

.sidebar.collapsed:hover .brand-icon {
  display: none;
}

.sidebar.collapsed:hover .collapse-btn {
  display: flex;
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, var(--color-primary-400), var(--color-primary-500));
  box-shadow: 0 4px 10px rgba(162, 37, 251, 0.30), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  flex-shrink: 0;
}

.brand-name {
  font-weight: var(--fw-medium);
  font-size: var(--text-lg);
  flex: 1;
}

.collapse-btn {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--surface-page);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}

.collapse-btn svg {
  transition: transform 0.2s ease;
}

.sidebar.collapsed .collapse-btn svg {
  transform: rotate(180deg);
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  padding: var(--space-8) var(--space-12);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--text-base);
  font-weight: var(--fw-regular);
  cursor: pointer;
  text-decoration: none;
}

.nav-item svg { flex-shrink: 0; }

.nav-item:hover {
  background: var(--nav-hover-bg);
}

.nav-item.active {
  background: var(--nav-active-bg);
  color: var(--color-primary-600);
  font-weight: var(--fw-medium);
  box-shadow: 0 1px 3px rgba(16, 15, 30, 0.06), 0 1px 2px rgba(16, 15, 30, 0.04);
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: var(--space-8);
}

.sidebar.collapsed .nav-label {
  display: none;
}

/* Main content */
.main {
  flex: 1;
  padding: var(--space-24);
  min-width: 0;
  background: var(--surface-page);
  overflow-y: auto;
}

.top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-20);
  gap: var(--space-16);
}

.title-block h1 {
  margin: 0 0 var(--space-6);
}

.breadcrumb {
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-6);
  margin: 0;
  padding: 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.breadcrumb a {
  color: var(--color-primary-600);
  font-weight: var(--fw-medium);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb li:not(:first-child) {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.breadcrumb li:not(:first-child)::before {
  content: "/";
  color: var(--text-muted);
}

.new-course-btn {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  background: linear-gradient(180deg, var(--color-primary-400), var(--color-primary-500));
  color: #ffffff;
  border: none;
  padding: var(--space-12) var(--space-20);
  border-radius: var(--radius-control);
  font-size: var(--text-base);
  font-weight: var(--fw-medium);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(162, 37, 251, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
  transition: box-shadow 0.15s ease, filter 0.15s ease;
}

.new-course-btn:hover {
  filter: brightness(1.05);
  box-shadow: 0 3px 8px rgba(162, 37, 251, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

hr.divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: var(--space-4) calc(-1 * var(--space-24)) var(--space-24);
}

.search-wrap {
  max-width: 320px;
  position: relative;
  margin-bottom: var(--space-32);
}

.search-wrap input {
  width: 100%;
  padding: var(--space-12) var(--space-40) var(--space-12) var(--space-16);
  border-radius: var(--radius-control);
  border: 1px solid var(--border-interactive);
  background: var(--surface-input);
  box-shadow: none;
  font-family: var(--font-family);
  font-size: var(--text-base);
  font-weight: var(--fw-regular);
  color: var(--text-primary);
  outline: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.search-wrap input:focus-visible {
  background: var(--surface-page);
  border-color: var(--color-primary-400);
}

.search-wrap input::placeholder {
  color: var(--text-muted);
}

.search-wrap i {
  position: absolute;
  right: var(--space-12);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
}

.ti {
  font-size: 16px;
  line-height: 1;
}

/* Folder grid — each card carries its own --card-accent custom property,
   set inline per-card (from the 6-color palette), driving both the flag
   and the auto-generated thumbnail tint via color-mix(). */
.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-48) var(--space-24);
}

.folder-card {
  position: relative;
  background: linear-gradient(180deg, #F9FAFB 0%, #ececec85 100%);
  border-radius: 0 24px 24px 24px;
  z-index: 0;
  cursor: pointer;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
}

.folder-card::before {
  content: '';
  position: absolute;
  inset: 1px;
  border-radius: 0 23px 23px 23px;
  background: linear-gradient(180deg, #F9FAFB 0%, #fcfcfc 100%);
  z-index: -1;
}

.folder-card:focus-visible {
  outline: 2px solid var(--color-primary-500);
  outline-offset: 2px;
}

/* Badge + ribbon share one row: the ribbon tucks behind the badge via negative margin
   (cards have no real active/inactive data model yet — badge is decorative) */
.folder-card-wrap {
  display: flex;
  flex-direction: column;
}


.folder-card-topbar {
  display: flex;
  align-items: stretch;
  gap: 0;
}

.folder-card-badge-frame {
  position: relative;
  z-index: 2;
  display: inline-flex;
  background: #F9FAFB;
  padding: var(--space-8) var(--space-8) 0;
  border-radius: 20px 0 0 0;
}

/* Active badge */
.folder-card-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px 4px 7px;
  border-radius: 999px;
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #d6f1df;
  font-size: 11px;
  font-weight: var(--fw-medium);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
}

/* Inactive state */
.folder-card-wrap[data-active="false"] .folder-card-badge {
  background: #f9fafb;
  color: #6b7280;
  border-color: #e7e7e7;

}

.folder-card-badge i {
  flex-shrink: 0;
  font-size: 11px;
  transition: transform 0.15s ease;
  opacity: 0.6;
}

.folder-card-badge.open i {
  transform: rotate(180deg);
}

/* Status dot */
.folder-card-badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
}

.folder-card-wrap[data-active="false"] .folder-card-badge::before {
  background: #d1d5db;
}

/* Badge dropdown */
.badge-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(16,15,30,0.10), 0 2px 6px rgba(16,15,30,0.06);
  min-width: 148px;
  z-index: 100;
  overflow: hidden;
  display: none;
  padding: 4px;
}

.badge-dropdown.open {
  display: block;
}

.badge-dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  padding: 7px 10px;
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  cursor: pointer;
  color: var(--text-primary);
  border-radius: 6px;
}

.badge-dropdown-item:hover {
  background: #f9fafb;
}

.badge-dropdown-item .status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-dropdown-item[data-value="active"] .status-dot { background: #22c55e; }
.badge-dropdown-item[data-value="active"] { color: #15803d; }
.badge-dropdown-item[data-value="inactive"] .status-dot { background: #9ca3af; }
.badge-dropdown-item[data-value="inactive"] { color: #6b7280; }

/* Card title row with kebab */
.folder-card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

.folder-card-title {
  font-size: var(--h4-size);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-card-kebab {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.folder-card:hover .folder-card-kebab,
.folder-card-kebab.open {
  opacity: 1;
}

.folder-card-kebab:hover,
.folder-card-kebab.open {
  background: rgba(16,15,30,0.06);
  color: var(--text-primary);
}

/* Kebab dropdown */
.card-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(16,15,30,0.10), 0 2px 6px rgba(16,15,30,0.06);
  min-width: 130px;
  z-index: 100;
  overflow: hidden;
  display: none;
  padding: 4px;
}

.card-dropdown.open {
  display: block;
}

.card-dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  padding: 7px 10px;
  font-size: var(--text-sm);
  font-weight: var(--fw-regular);
  cursor: pointer;
  color: var(--text-primary);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  border-radius: 6px;
}

.card-dropdown-item:hover {
  background: #f9fafb;
}

.card-dropdown-item.delete {
  color: #dc2626;
}

.card-dropdown-item.delete:hover {
  background: #fff1f2;
  color: #b91c1c;
}

/* Two-layer Side ribbon: the base flag is a flat #F9FAFB back layer sitting flush
   to the badge frame; the accent layer (.folder-card-flag-accent) is the same svg
   in its own div, pulled left with a negative margin so it stacks on top and the
   #F9FAFB base peeks out as a light edge on the right. */
.folder-card-flag {
  position: relative;
  z-index: 1;
  display: block;
  color: #F9FAFB;
  height: 34.1px;
  width: auto;
}

.folder-card-flag-accent {
  position: relative;
  z-index: 2;
  margin-left: -4px;
}

.folder-card-flag-accent .folder-card-flag {
  color: #F9FAFB;
}

.folder-card-title {
  padding-right: var(--space-24);
  font-size: var(--h4-size);
}

.folder-card-thumb {
  flex: 1;
  min-height: 160px;
  border-radius: var(--radius-control);
  background: linear-gradient(150deg, color-mix(in srgb, var(--card-accent) 5%, var(--card-thumb-mix-base)) 0%, color-mix(in srgb, var(--card-accent) 10%, var(--card-thumb-mix-base)) 100%);
  padding: 12px;
  display: flex;
  align-items: flex-start;
  overflow: hidden;
}

.folder-card-thumb-text {
  display: block;
  max-width: 100%;
  font-size: 36px;
  font-weight: 700;
  line-height: 1.3;
  color: color-mix(in srgb, var(--card-accent) 25%, var(--card-thumb-mix-base));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.folder-card-wrap[data-active="false"] .folder-card-thumb {
  background: #F5F7F9;
}

.folder-card-wrap[data-active="false"] .folder-card-thumb-text {
  color: #CFD9E2;
}

/* ---------- New Course modal ---------- */
dialog.modal {
  border: none;
  padding: 0;
  width: min(400px, 92vw);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  background: var(--surface-page);
  color: var(--text-primary);
}

dialog.modal::backdrop {
  background: rgba(16, 15, 30, 0.45);
}

.modal-form {
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-20) var(--space-20) 0;
}

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--nav-hover-bg);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  padding: var(--space-20);
}

.field-label {
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
}

.field-input {
  width: 100%;
  padding: var(--space-12) var(--space-16);
  border-radius: var(--radius-control);
  border: 1px solid var(--border-interactive);
  background: var(--surface-input);
  box-shadow: none;
  font-family: var(--font-family);
  font-size: var(--text-base);
  font-weight: var(--fw-regular);
  color: var(--text-primary);
  outline: none;
  margin-bottom: var(--space-8);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.field-input:focus-visible {
  background: var(--surface-page);
  border-color: var(--color-primary-400);
  outline: none;
}

.color-swatch-group {
  display: flex;
  gap: var(--space-12);
  margin-bottom: var(--space-8);
}

.color-swatch {
  position: relative;
  display: inline-flex;
  width: 28px;
  height: 28px;
  cursor: pointer;
}

.color-swatch-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.color-swatch-dot {
  position: relative;
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--sw);
  box-shadow: inset 0 0 0 1px rgba(16, 15, 30, 0.12);
  transition: box-shadow 0.15s ease;
}

.color-swatch-input:checked + .color-swatch-dot {
  box-shadow: 0 0 0 2px var(--surface-page), 0 0 0 4px var(--sw);
}

.color-swatch-input:checked + .color-swatch-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #ffffff;
}

.color-swatch-input:focus-visible + .color-swatch-dot {
  outline: 2px solid var(--color-primary-500);
  outline-offset: 2px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-8);
  padding: var(--space-20);
}

.btn-secondary {
  padding: var(--space-12) var(--space-20);
  border-radius: var(--radius-control);
  border: 1px solid var(--border-interactive);
  background: var(--surface-page);
  color: var(--text-secondary);
  font-size: var(--text-base);
  font-weight: var(--fw-medium);
  cursor: pointer;
}

.btn-secondary:hover {
  background: var(--nav-hover-bg);
}
