/*
 * prostolms design system
 * Flat, light, elegant. Inspired by Linear/Notion/Vercel aesthetics.
 * Loaded after output.css so overrides win without touching compiled CSS.
 */

/* ── Design Tokens ───────────────────────────────────────────────── */
:root {
  --brand-radius: 0.625rem;
  --brand-radius-lg: 0.75rem;
  --brand-primary: #4f46e5;
  --brand-primary-hover: #4338ca;
  --brand-primary-soft: #eef2ff;
  --brand-primary-ring: rgba(79, 70, 229, 0.18);
  --brand-accent: #0d9488;
  --brand-accent-soft: #f0fdfa;
  --brand-surface: #ffffff;
  --brand-surface-muted: #f8fafc;
  --brand-surface-raised: #ffffff;
  --brand-border: #e2e8f0;
  --brand-border-light: #f1f5f9;
  --brand-text: #0f172a;
  --brand-text-secondary: #475569;
  --brand-text-muted: #94a3b8;
  --brand-success: #059669;
  --brand-success-soft: #ecfdf5;
  --brand-warning: #d97706;
  --brand-warning-soft: #fffbeb;
  --brand-danger: #dc2626;
  --brand-danger-soft: #fef2f2;
}

/* ── Base ─────────────────────────────────────────────────────────── */
html, body {
  color: var(--brand-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--brand-surface-muted);
}

/* Smooth transitions globally */
*, *::before, *::after {
  transition-property: color, background-color, border-color, box-shadow, opacity;
  transition-duration: 150ms;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Exclude transforms/layout properties from global transition */
a, button, input, select, textarea, video, audio, img {
  transition-property: color, background-color, border-color, box-shadow, opacity, transform;
}

/* ── Cards & Surfaces ─────────────────────────────────────────────── */
.lms-ui .card,
.lms-ui .stats,
.lms-ui .collapse,
.lms-ui .alert,
.lms-ui .rounded-box {
  border: 1px solid var(--brand-border);
  border-radius: var(--brand-radius-lg);
  background: var(--brand-surface);
  box-shadow: none;
}

.lms-ui .mockup-code {
  border: 1px solid var(--brand-border);
  border-radius: var(--brand-radius-lg);
  background: #f8fafc;
}

.lms-ui .drawer-side aside {
  border-color: var(--brand-border);
  background: var(--brand-surface);
}

/* ── Buttons ──────────────────────────────────────────────────────── */
.lms-ui .btn {
  border-radius: var(--brand-radius);
  font-weight: 500;
  letter-spacing: -0.01em;
  box-shadow: none;
  border: 1px solid transparent;
}

.lms-ui .btn:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

.lms-ui .btn-primary {
  border-color: var(--brand-primary);
  background: var(--brand-primary);
  color: #ffffff;
}

.lms-ui .btn-primary:hover {
  border-color: var(--brand-primary-hover);
  background: var(--brand-primary-hover);
}

.lms-ui .btn-secondary {
  border-color: var(--brand-accent);
  background: var(--brand-accent);
  color: #ffffff;
}

.lms-ui .btn-secondary:hover {
  background: #0f766e;
  border-color: #0f766e;
}

.lms-ui .btn-outline {
  border-color: var(--brand-border);
  background: var(--brand-surface);
  color: var(--brand-text);
}

.lms-ui .btn-outline:hover {
  border-color: var(--brand-primary);
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
}

.lms-ui .btn-ghost {
  background: transparent;
  color: var(--brand-text-secondary);
}

.lms-ui .btn-ghost:hover {
  background: var(--brand-surface-muted);
  color: var(--brand-text);
}

.btn-brand {
  border-radius: var(--brand-radius);
  border: 1px solid var(--brand-primary);
  background: var(--brand-primary);
  color: #ffffff;
  font-weight: 500;
}

.btn-brand:hover {
  background: var(--brand-primary-hover);
  border-color: var(--brand-primary-hover);
}

/* ── Badges ───────────────────────────────────────────────────────── */
.lms-ui .badge-outline {
  border-color: var(--brand-border);
  background: var(--brand-surface);
  color: var(--brand-text-secondary);
}

.lms-ui .badge-ghost {
  border: none;
  background: var(--brand-surface-muted);
  color: var(--brand-text-secondary);
}

/* ── Tables ───────────────────────────────────────────────────────── */
.lms-ui .table {
  border-color: var(--brand-border);
  background: var(--brand-surface);
}

.lms-ui .table :where(th, td) {
  white-space: nowrap;
}

.lms-ui .table :where(th) {
  color: var(--brand-text-muted);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.lms-ui .table.table-sm :where(th, td) {
  padding: 0.625rem 0.75rem;
}

.lms-ui .table tbody tr {
  border-bottom-color: var(--brand-border-light);
}

.lms-ui .table tbody tr:last-child {
  border-bottom-color: transparent;
}

/* ── Form Controls ────────────────────────────────────────────────── */
.lms-ui .input,
.lms-ui .textarea,
.lms-ui .select,
.lms-ui .file-input {
  min-height: 2.5rem;
  border: 1px solid var(--brand-border);
  border-radius: var(--brand-radius);
  background: var(--brand-surface);
  color: var(--brand-text);
  font-size: 0.875rem;
}

.lms-ui .input:focus,
.lms-ui .textarea:focus,
.lms-ui .select:focus,
.lms-ui .file-input:focus {
  border-color: var(--brand-primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-primary-ring);
}

.lms-ui .input::placeholder,
.lms-ui .textarea::placeholder {
  color: var(--brand-text-muted);
}

.lms-ui .label-text,
.lms-ui label.text-xs,
.lms-ui label.text-sm {
  color: var(--brand-text-secondary);
  font-weight: 500;
  font-size: 0.8125rem;
}

.lms-ui form.grid,
.lms-ui form.space-y-3,
.lms-ui form.space-y-4 {
  gap: 0.75rem;
}

/* ── Links ────────────────────────────────────────────────────────── */
.lms-ui .link {
  text-underline-offset: 0.2em;
  text-decoration-color: var(--brand-border);
}

.lms-ui .link:hover {
  text-decoration-color: var(--brand-primary);
}

/* ── Lesson Reader Content ────────────────────────────────────────── */
.lms-reader {
  font-family: 'Source Serif 4', Georgia, serif;
  font-optical-sizing: auto;
  line-height: 1.85;
  color: #1e293b;
  font-size: 1.0625rem;
}

.lms-reader h1,
.lms-reader h2,
.lms-reader h3,
.lms-reader h4 {
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 600;
  line-height: 1.35;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  color: #0f172a;
  letter-spacing: -0.01em;
}

.lms-reader h1 {
  font-size: 1.75rem;
}

.lms-reader h2 {
  font-size: 1.375rem;
}

.lms-reader h3 {
  font-size: 1.125rem;
}

.lms-reader p {
  margin-bottom: 1.25rem;
}

.lms-reader ul,
.lms-reader ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

.lms-reader ul {
  list-style: disc;
}

.lms-reader ol {
  list-style: decimal;
}

.lms-reader ul ul {
  list-style: circle;
}

.lms-reader ol ol {
  list-style: lower-alpha;
}

.lms-reader li {
  margin-bottom: 0.375rem;
}

.lms-reader a {
  color: #2563eb;
  text-decoration: underline;
  text-underline-offset: 0.16em;
}

.lms-reader a:hover {
  color: #1d4ed8;
}

.lms-reader a:visited {
  color: #6d28d9;
}

.lms-reader blockquote {
  border-left: 2px solid #e2e8f0;
  padding-left: 1.25rem;
  margin: 1.5rem 0;
  color: #64748b;
  font-style: italic;
}

.lms-reader pre {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.875rem;
}

.lms-reader code {
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: 0.875em;
}

.lms-reader img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
  margin: 1.5rem 0;
}

/* ── Menus ────────────────────────────────────────────────────────── */
.lms-ui .menu li > *:not(ul):not(.menu-title):not(details):active,
.lms-ui .menu li > *:not(ul):not(.menu-title):not(details).active,
.lms-ui .menu li > details > summary:active {
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
}

/* ── Alerts ───────────────────────────────────────────────────────── */
.lms-ui .alert {
  border-radius: var(--brand-radius);
}

.lms-ui .alert-info {
  border-color: #dbeafe;
  background: #eff6ff;
  color: #1e40af;
}

.lms-ui .alert-warning {
  border-color: #fde68a;
  background: var(--brand-warning-soft);
  color: #92400e;
}

.lms-ui .alert-success {
  border-color: #a7f3d0;
  background: var(--brand-success-soft);
  color: #065f46;
}

/* ── Stats ────────────────────────────────────────────────────────── */
.lms-ui .stats {
  border-radius: var(--brand-radius-lg);
}

.lms-ui .stat {
  border-color: var(--brand-border-light);
}

/* ── Hero Section ─────────────────────────────────────────────────── */
.lms-hero {
  position: relative;
  overflow: hidden;
  background: var(--brand-surface);
}

.lms-hero::after {
  position: absolute;
  right: -6rem;
  top: -6rem;
  z-index: 0;
  height: 20rem;
  width: 20rem;
  border-radius: 9999px;
  background: radial-gradient(circle, rgba(79, 70, 229, 0.06), transparent 70%);
  content: "";
  pointer-events: none;
}

.lms-hero > * {
  position: relative;
  z-index: 1;
}

/* ── Topbar ───────────────────────────────────────────────────────── */
.lms-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--brand-border);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.lms-topbar a {
  color: var(--brand-text-secondary);
}

.lms-topbar a:hover,
.lms-topbar .active {
  color: var(--brand-text);
}

/* ── Sidebar ──────────────────────────────────────────────────────── */
.lms-sidebar {
  background: var(--brand-surface);
  border-right: 1px solid var(--brand-border);
}

.lms-sidebar[data-sidebar-collapsible] {
  transition: width 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.lms-sidebar .lms-sidebar-toggle {
  min-height: 1.75rem;
  min-width: 1.75rem;
}

.lms-sidebar-header {
  position: relative;
}

.lms-sidebar-title {
  padding-right: 2.25rem;
  line-height: 1.3;
}

.lms-menu-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lms-menu-link svg {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  color: var(--brand-text-muted);
}

.lms-menu-label {
  white-space: nowrap;
}

@media (min-width: 1024px) {
  .lms-sidebar[data-sidebar-collapsible].is-collapsed {
    width: 4.5rem;
  }

  .lms-sidebar[data-sidebar-collapsible].is-collapsed .lms-section-title,
  .lms-sidebar[data-sidebar-collapsible].is-collapsed .lms-sidebar-title,
  .lms-sidebar[data-sidebar-collapsible].is-collapsed .lms-menu-label,
  .lms-sidebar[data-sidebar-collapsible].is-collapsed .lms-sidebar-footer,
  .lms-sidebar[data-sidebar-collapsible].is-collapsed .lms-sidebar-meta,
  .lms-sidebar[data-sidebar-collapsible].is-collapsed .badge {
    display: none;
  }

  .lms-sidebar[data-sidebar-collapsible].is-collapsed .lms-sidebar-toggle {
    margin-left: auto;
    margin-right: auto;
  }

  .lms-sidebar[data-sidebar-collapsible].is-collapsed .lms-sidebar-panel .menu li > a {
    justify-content: center;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .lms-sidebar[data-sidebar-collapsible].is-collapsed .lms-sidebar-panel section,
  .lms-sidebar[data-sidebar-collapsible].is-collapsed .lms-sidebar-panel .menu {
    width: 100%;
  }
}

.lms-sidebar-panel {
  display: flex;
  min-height: calc(100vh - 1px);
  flex-direction: column;
}

.lms-sidebar-panel .menu li > a {
  border-radius: var(--brand-radius);
  color: var(--brand-text-secondary);
  font-weight: 450;
  font-size: 0.875rem;
}

.lms-sidebar-panel .menu li > a:hover {
  background: var(--brand-surface-muted);
  color: var(--brand-text);
}

.lms-sidebar-panel .menu li > a.active {
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
  font-weight: 500;
}

.lms-sidebar-panel .menu li > a.active svg {
  color: var(--brand-primary);
}

/* ── Quill Editor ─────────────────────────────────────────────────── */
.lms-ui .ql-toolbar.ql-snow,
.lms-ui .ql-container.ql-snow {
  border-color: var(--brand-border);
}

.lms-ui .ql-toolbar.ql-snow {
  border-top-left-radius: var(--brand-radius);
  border-top-right-radius: var(--brand-radius);
  background: var(--brand-surface-muted);
}

.lms-ui .ql-container.ql-snow {
  border-bottom-left-radius: var(--brand-radius);
  border-bottom-right-radius: var(--brand-radius);
  background: var(--brand-surface);
}

.lms-ui .ql-editor {
  min-height: 14rem;
  color: var(--brand-text);
  line-height: 1.7;
  font-size: 0.9375rem;
}

.lms-ui .ql-editor.ql-blank::before {
  color: var(--brand-text-muted);
  font-style: normal;
}

/* ── Builder Drag & Drop ──────────────────────────────────────────── */
.lms-ui .lms-builder-module-list,
.lms-ui .lms-builder-lesson-list {
  transition: box-shadow 150ms ease, background-color 150ms ease;
}

.lms-ui .builder-drop-active {
  background: var(--brand-primary-soft);
  box-shadow: inset 0 0 0 1px rgba(79, 70, 229, 0.2);
}

.lms-ui .builder-ghost {
  opacity: 0.4;
  background: var(--brand-primary-soft);
}

.lms-ui .builder-chosen {
  box-shadow: 0 0 0 2px var(--brand-primary);
}

.lms-ui .builder-dragging {
  transform: scale(0.995);
}

/* ── Course Lesson Nav ────────────────────────────────────────────── */
.lms-lesson-nav-link {
  display: block;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--brand-radius);
  padding: 0.5rem 0.625rem;
  color: var(--brand-text-secondary);
  font-size: 0.875rem;
  line-height: 1.5;
}

.lms-lesson-nav-link:hover {
  background: var(--brand-surface-muted);
  color: var(--brand-text);
}

.lms-lesson-nav-link:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

.lms-lesson-nav-link.active {
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
  font-weight: 500;
}

/* ── Utility: Divider ─────────────────────────────────────────────── */
.lms-ui .divider::before,
.lms-ui .divider::after {
  background: var(--brand-border-light);
}

/* ── Animations (respect reduced motion) ──────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
  }
}
