/* Empire Docs — inspired by empire.edu.vn/khoa-hoc */

:root {
  --bg: #f8fafc;
  --white: #ffffff;
  --ink: #111827;
  --ink-2: #171717;
  --muted: #525252;
  --muted-2: #737373;
  --line: #e5e7eb;
  --orange: #f59e0b;
  --orange-2: #f97316;
  --orange-3: #f99d0d;
  --orange-soft: #fff7ed;
  --green: #16a34a;
  --green-soft: #e8f7ec;
  --shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);
  --r: 16px;
  --header-h: 64px;
  --max: 1120px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

img {
  max-width: 100%;
  display: block;
}

.wrap {
  width: min(100% - 32px, var(--max));
  margin: 0 auto;
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.header-row {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.logo-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(145deg, #fbbf24, #f97316);
  color: #fff;
  font-weight: 800;
  display: grid;
  place-items: center;
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.logo-text b {
  font-size: 15px;
  font-weight: 800;
}

.logo-text small {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.searchbox {
  flex: 1;
  max-width: 360px;
}

.searchbox input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 16px;
  background: #fff;
  outline: none;
}

.searchbox input:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

/* Page */
.page {
  padding: 24px 0 48px;
  min-height: calc(100vh - var(--header-h));
}

/* Banner like empire */
.banner {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  min-height: 160px;
  margin-bottom: 28px;
  background: linear-gradient(120deg, #fff7ed 0%, #ffedd5 45%, #fed7aa 100%);
  border: 1px solid #ffedd5;
  padding: 28px 28px 24px;
}

.banner h1 {
  margin: 0 0 8px;
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink-2);
}

.banner p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  max-width: 48ch;
}

.banner-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #fff;
  border: 1px solid #fed7aa;
  color: #9a3412;
}

.chip.green {
  border-color: #bbf7d0;
  color: var(--green);
  background: var(--green-soft);
}

.chip.gray {
  border-color: var(--line);
  color: var(--muted);
  background: #fff;
}

/* Section */
.section-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.section-bar h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}

.section-bar span {
  font-size: 13px;
  color: var(--muted);
}

/* Course grid — empire style */
.course-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (min-width: 640px) {
  .course-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
  }
}

@media (min-width: 960px) {
  .course-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
  }
}

.course-card {
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0, 0, 0, 0.04);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.course-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.course-card:focus-visible {
  outline: 3px solid rgba(249, 115, 22, 0.35);
  outline-offset: 2px;
}

.course-thumb {
  aspect-ratio: 16 / 10;
  background: #fff7ed;
  overflow: hidden;
}

.course-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.course-body {
  padding: 12px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.course-title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.7em;
}

.course-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag {
  font-size: 11px;
  font-weight: 600;
  color: #525252;
  background: #f3f4f6;
  padding: 3px 8px;
  border-radius: 999px;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.course-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 4px;
}

.price {
  font-size: 13px;
  font-weight: 800;
  color: var(--orange-2);
}

.price s {
  margin-left: 4px;
  color: #a3a3a3;
  font-weight: 500;
  font-size: 11px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.btn-orange {
  background: linear-gradient(180deg, #fbbf24, #f97316);
  color: #fff;
}

.btn-orange:hover {
  filter: brightness(1.03);
}

.btn-white {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-soft {
  background: var(--orange-soft);
  color: #c2410c;
  border: 1px solid #fed7aa;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  background: #f3f4f6;
  color: var(--ink);
  border: 0;
  font-size: 16px;
  cursor: pointer;
}

/* Course detail layout */
.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--orange-2);
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 16px;
}

.back:hover {
  text-decoration: underline;
}

.detail {
  display: grid;
  gap: 20px;
}

@media (min-width: 960px) {
  .detail {
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 28px;
    align-items: start;
  }
}

.side-card {
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

@media (min-width: 960px) {
  .side-card {
    position: sticky;
    top: calc(var(--header-h) + 16px);
  }
}

.side-cover {
  aspect-ratio: 16 / 10;
  background: #fff7ed;
}

.side-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.side-pad {
  padding: 16px;
}

.side-pad h1 {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.stat {
  text-align: center;
  background: var(--orange-soft);
  border: 1px solid #fed7aa;
  border-radius: 12px;
  padding: 10px 4px;
}

.stat b {
  display: block;
  color: var(--orange-2);
  font-size: 16px;
  font-weight: 800;
}

.stat span {
  font-size: 11px;
  color: #9a3412;
  font-weight: 600;
}

.side-desc {
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
  max-height: 140px;
  overflow: auto;
}

.side-desc p {
  margin: 0 0 8px;
}

/* Curriculum */
.tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.tools input {
  flex: 1;
  min-width: 180px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  outline: none;
  background: #fff;
}

.tools input:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.12);
}

.panel {
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.chapter {
  border-bottom: 1px solid #f3f4f6;
}

.chapter:last-child {
  border-bottom: 0;
}

.chapter-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.chapter-btn:hover {
  background: #fffaf5;
}

.chapter-no {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #c2410c;
  font-weight: 800;
  font-size: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.chapter-info {
  flex: 1;
  min-width: 0;
}

.chapter-info b {
  display: block;
  font-size: 14px;
  font-weight: 700;
}

.chapter-info span {
  font-size: 12px;
  color: var(--muted);
}

.chapter-arrow {
  color: #a3a3a3;
  transition: transform 0.15s;
}

.chapter.open .chapter-arrow {
  transform: rotate(180deg);
}

.chapter-body {
  display: none;
  padding: 0 12px 14px;
}

.chapter.open .chapter-body {
  display: block;
}

.lesson {
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 10px;
  overflow: hidden;
}

.lesson:last-child {
  margin-bottom: 0;
}

.lesson-head {
  padding: 10px 12px;
  background: #f9fafb;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
  font-weight: 700;
}

.lesson-head small {
  display: block;
  font-weight: 500;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.doc-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 0;
  border-top: 1px solid #f3f4f6;
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.doc-row:first-of-type {
  border-top: 0;
}

.doc-row:hover {
  background: #fffbeb;
}

.doc-ico {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--green-soft);
  color: var(--green);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
}

.doc-meta {
  flex: 1;
  min-width: 0;
}

.doc-meta b {
  display: block;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}

.doc-meta span {
  font-size: 12px;
  color: var(--muted);
}

/* States */
.center-msg {
  text-align: center;
  padding: 48px 16px;
  color: var(--muted);
}

.spinner {
  width: 32px;
  height: 32px;
  margin: 0 auto 12px;
  border: 3px solid #ffedd5;
  border-top-color: var(--orange-2);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.error-box {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
}

/* ========== PDF LAYER (fixed, isolated) ========== */
.pdf-layer {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none; /* closed by default */
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.pdf-layer.open {
  display: flex;
}

.pdf-layer-bg {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
}

.pdf-modal {
  position: relative;
  z-index: 1;
  width: min(1000px, 100%);
  height: min(90vh, 860px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pdf-toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.pdf-sub {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.pdf-name {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  max-width: 52vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pdf-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.pdf-frame {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: #404040;
}

.pdf-error {
  flex: 1;
  display: grid;
  place-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  background: #f9fafb;
}

/* Mobile PDF fullscreen */
@media (max-width: 720px) {
  .logo-text small {
    display: none;
  }

  .pdf-layer {
    padding: 0;
  }

  .pdf-modal {
    width: 100%;
    height: 100%;
    border-radius: 0;
  }

  .pdf-name {
    max-width: 42vw;
  }

  .banner {
    padding: 20px 16px;
  }

  .course-title {
    font-size: 12px;
  }
}

body.pdf-open {
  overflow: hidden;
}
