/* ===========================================================
   LMS Sanstar — Sistema de diseño
   Apple-minimalist · identidad índigo · sidebar fijo
   =========================================================== */
:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --ink: #1d1d1f;
  --ink-2: #424245;
  --muted: #86868b;
  --line: #e5e5ea;
  --line-2: #d2d2d7;

  --primary: #4f46e5;
  --primary-d: #4338ca;
  --primary-soft: #eef2ff;

  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;

  --radius: 14px;
  --radius-sm: 9px;
  --sidebar-w: 248px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 30px rgba(0,0,0,.06);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; align-self: start; height: 100vh;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 22px 16px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 22px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--primary), #7c74f0);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 16px;
  letter-spacing: -.5px;
}
.brand-name { font-weight: 650; letter-spacing: -.3px; }
.brand-sub { font-size: 11px; color: var(--muted); margin-top: -2px; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.nav-label { font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px;
  border-radius: var(--radius-sm); color: var(--ink-2); cursor: pointer;
  font-weight: 500; font-size: 14px; border: none; background: none; width: 100%;
  text-align: left; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--primary-soft); color: var(--primary-d); font-weight: 600; }
.nav-item .ic { width: 18px; height: 18px; flex: none; }
.nav-item.muted { color: var(--line-2); cursor: default; }
.nav-item.muted:hover { background: none; }

.sidebar-foot { margin-top: auto; padding-top: 16px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px;
  border-radius: var(--radius-sm); }
.user-chip img, .user-chip .ph { width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: var(--line); object-fit: cover; }
.user-chip .nm { font-size: 13px; font-weight: 600; line-height: 1.2; }
.user-chip .rl { font-size: 11px; color: var(--muted); }

/* ---------- Topbar ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 16px 32px; background: rgba(245,245,247,.8);
  backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 21px; font-weight: 650; letter-spacing: -.4px; margin: 0; }
.topbar .spacer { flex: 1; }

.lang-toggle { display: inline-flex; background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 2px; }
.lang-toggle button { border: none; background: none; padding: 5px 13px; border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.lang-toggle button.on { background: var(--primary); color: #fff; }

.content { padding: 28px 32px 60px; max-width: 1100px; width: 100%; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px;
  border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface);
  color: var(--ink); font-weight: 600; font-size: 14px; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 6px 11px; font-size: 13px; }

/* ---------- Cards / rows ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); }
.section-head { display: flex; align-items: center; gap: 12px; margin: 0 0 18px; }
.section-head h2 { font-size: 17px; font-weight: 650; letter-spacing: -.3px; margin: 0; }
.section-head .spacer { flex: 1; }
.muted { color: var(--muted); }

.course-row {
  display: flex; align-items: center; gap: 16px; padding: 16px 18px 16px 14px;
  border-bottom: 1px solid var(--line); cursor: pointer; position: relative;
  transition: background .12s;
}
.course-row:last-child { border-bottom: none; }
.course-row:hover { background: var(--surface-2); }
.course-row .edge { width: 4px; align-self: stretch; border-radius: 4px; flex: none;
  background: var(--line-2); }
.course-row .ttl { font-weight: 600; }
.course-row .meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.course-row .grow { flex: 1; min-width: 0; }
.course-row .nums { display: flex; gap: 18px; font-size: 12.5px; color: var(--muted); }
.course-row .nums b { color: var(--ink-2); font-weight: 600; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; }
.badge.draft { background: #f1f1f3; color: #6e6e73; }
.badge.published { background: #e7f7ef; color: #0a8a4f; }
.badge.archived { background: #fdeaea; color: #b42318; }
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; }

/* ---------- Forms ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); }
input[type=text], input[type=number], textarea, select {
  font-family: inherit; font-size: 14px; padding: 10px 12px; border: 1px solid var(--line-2);
  border-radius: 10px; background: var(--surface); color: var(--ink); width: 100%;
}
select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding-right: 38px; cursor: pointer; font-weight: 500;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234f46e5' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 13px center;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
select:hover { background-color: var(--surface-2); border-color: var(--line); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { resize: vertical; min-height: 78px; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { display: none; }
.switch .track { width: 42px; height: 25px; border-radius: 999px; background: var(--line-2);
  position: relative; transition: background .18s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 21px;
  height: 21px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .18s; }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(17px); }

/* ---------- Content builder ---------- */
.module { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px;
  background: var(--surface); overflow: hidden; }
.module-head { display: flex; align-items: center; gap: 10px; padding: 13px 16px;
  background: var(--surface-2); border-bottom: 1px solid var(--line); }
.module-head input { font-weight: 600; border-color: transparent; background: transparent; padding: 6px 8px; }
.module-head input:focus { background: #fff; border-color: var(--primary); }
.lesson { display: flex; align-items: center; gap: 12px; padding: 11px 16px;
  border-bottom: 1px solid var(--line); }
.lesson:last-child { border-bottom: none; }
.lesson .type-pill { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px;
  text-transform: uppercase; letter-spacing: .03em; }
.type-html { background: #eef2ff; color: #4338ca; }
.type-video { background: #fef3e7; color: #b45309; }
.type-pdf { background: #fdeaea; color: #b42318; }
.type-quiz { background: #e7f7ef; color: #0a8a4f; }
.lesson .ll { flex: 1; min-width: 0; font-weight: 500; }

.empty { text-align: center; padding: 54px 20px; color: var(--muted); }
.empty .big { font-size: 15px; color: var(--ink-2); font-weight: 600; margin-bottom: 4px; }

/* ---------- Modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.32); display: grid;
  place-items: center; z-index: 100; padding: 20px; }
.modal { background: var(--surface); border-radius: 18px; box-shadow: 0 24px 70px rgba(0,0,0,.25);
  width: 100%; max-width: 520px; max-height: 88vh; overflow: auto; }
.modal-head { padding: 20px 24px 0; }
.modal-head h3 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -.3px; }
.modal-body { padding: 18px 24px; }
.modal-foot { padding: 14px 24px 22px; display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- Toast / spinner ---------- */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 11px 20px; border-radius: 999px;
  font-size: 13.5px; font-weight: 500; z-index: 200; box-shadow: 0 8px 30px rgba(0,0,0,.25);
  opacity: 0; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast.err { background: var(--danger); }

.center-screen { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 30px; height: 30px; border: 3px solid var(--line);
  border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.cover-prev { width: 100%; max-width: 360px; aspect-ratio: 16/9; border-radius: 10px; object-fit: cover;
  background: var(--surface-2); border: 1px solid var(--line); display: block; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; transform: translateX(-100%);
    transition: transform .2s; width: var(--sidebar-w); box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .content, .topbar { padding-left: 18px; padding-right: 18px; }
  .grid-2 { grid-template-columns: 1fr; }
  .menu-btn { display: inline-flex !important; }
}
.menu-btn { display: none; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
