/* ============================================================
   Cute & colorful PDF report — 3 pages A4 portrait
   Design: rounded blocks, pastel + bold accents, numbered sections
   ============================================================ */

/* (fonts loaded via <link> in HTML head) */

:root {
  --pdf-bg:        #fdf6e3;     /* cream paper */
  --pdf-paper:     #fdf6e3;
  --pdf-blue:      #2c5aa0;     /* deep blue */
  --pdf-blue-soft: #e8efff;
  --pdf-yellow:    #fcd34d;     /* warm yellow */
  --pdf-yellow-bg: #fef3c7;
  --pdf-orange:    #f97316;
  --pdf-orange-bg: #fed7aa;
  --pdf-red:       #ef4444;
  --pdf-red-bg:    #fecaca;
  --pdf-pink:      #ec4899;
  --pdf-pink-bg:   #fce7f3;
  --pdf-teal:      #06b6d4;
  --pdf-teal-bg:   #cffafe;
  --pdf-ink:       #1e293b;
  --pdf-ink-soft:  #475569;
  --pdf-mute:      #94a3b8;
  --pdf-line:      #e2e8f0;
}

.pdf-doc {
  font-family: 'Kanit', 'Sarabun', sans-serif;
  color: var(--pdf-ink);
  background: var(--pdf-bg);
  width: 794px;
  font-size: 12px;
  line-height: 1.5;
}

.pdf-page {
  background: var(--pdf-paper);
  width: 794px;
  height: 1123px;
  padding: 32px 36px 56px;
  position: relative;
  page-break-after: always;
  box-sizing: border-box;
  overflow: hidden;
}
.pdf-page:last-child { page-break-after: auto; }

/* Decorative corner blobs */
.pdf-blob {
  position: absolute;
  pointer-events: none;
  border-radius: 50%;
}
.pdf-blob-yellow { background: var(--pdf-yellow); }
.pdf-blob-orange { background: var(--pdf-orange); }
.pdf-blob-red    { background: var(--pdf-red); }
.pdf-blob-pink   { background: var(--pdf-pink); }
.pdf-blob-teal   { background: var(--pdf-teal); }

/* ===== Top header ===== */
.pdf-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  margin-bottom: 16px;
}
.pdf-brand {
  display: flex; flex-direction: column;
  align-items: flex-start; gap: 4px;
}
.pdf-logo-img {
  height: 56px;
  width: auto;
  max-width: 220px;
  object-fit: contain;
  display: block;
}
.pdf-brand-tag {
  font-size: 9px; letter-spacing: 0.18em;
  color: var(--pdf-mute);
  font-weight: 500;
}
.pdf-end-logo {
  height: 38px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
  display: block;
  filter: brightness(0) invert(1);  /* ทำให้ logo ขาว บนพื้นน้ำเงิน */
  opacity: 0.95;
}
.pdf-line-qr {
  width: 84px; height: 84px;
  border-radius: 8px;
  background: white;
  padding: 4px;
  display: block;
  margin-left: auto;
  margin-top: 4px;
}
.qr-label {
  font-size: 10px;
  opacity: 0.85;
  text-align: right;
  margin-bottom: 2px;
}
.pdf-meta {
  text-align: right;
  background: var(--pdf-yellow);
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 11px;
  color: var(--pdf-ink);
  line-height: 1.45;
}
.pdf-meta strong { display: block; font-size: 13px; font-weight: 700; }

/* ===== Hero card ===== */
.pdf-hero {
  background: var(--pdf-blue);
  color: white;
  border-radius: 18px;
  padding: 22px 24px;
  position: relative;
  overflow: hidden;
  margin-bottom: 14px;
}
.pdf-hero .badge {
  display: inline-block;
  background: rgba(255,255,255,0.2);
  color: white;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 10px; letter-spacing: 0.1em;
  margin-bottom: 8px;
}
.pdf-hero h1 {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 8px;
  color: white;
  letter-spacing: -0.01em;
}
.pdf-hero h1 .highlight {
  background: var(--pdf-yellow);
  color: var(--pdf-ink);
  padding: 0 10px;
  border-radius: 8px;
}
.pdf-hero p {
  margin: 0; font-size: 11px;
  color: rgba(255,255,255,0.9);
  line-height: 1.6;
  max-width: 480px;
}
.pdf-hero .corner-deco {
  position: absolute; right: -20px; top: -20px;
  width: 110px; height: 110px;
  background: var(--pdf-yellow);
  border-radius: 50%;
  opacity: 0.85;
}
.pdf-hero .corner-deco-2 {
  position: absolute; right: 40px; bottom: -10px;
  width: 50px; height: 50px;
  background: var(--pdf-orange);
  border-radius: 50%;
}

/* ===== Student card ===== */
.pdf-student {
  background: white;
  border-radius: 14px;
  padding: 14px 18px;
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  gap: 16px;
  align-items: center;
  border: 2px solid var(--pdf-blue);
  margin-bottom: 14px;
}
.pdf-avatar {
  width: 46px; height: 46px;
  background: var(--pdf-blue);
  color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700;
}
.pdf-student .name { font-size: 16px; font-weight: 700; color: var(--pdf-blue); line-height: 1.1; }
.pdf-student .name-sub { font-size: 10px; color: var(--pdf-mute); margin-top: 2px; }
.pdf-student .stat { text-align: center; padding: 0 10px; border-left: 1px solid var(--pdf-line); }
.pdf-student .stat .label { font-size: 9px; color: var(--pdf-mute); letter-spacing: 0.05em; }
.pdf-student .stat .value { font-size: 14px; font-weight: 700; color: var(--pdf-blue); }
.pdf-student .stat .value.orange { color: var(--pdf-orange); }

/* ===== Section header (numbered) ===== */
.pdf-section {
  display: flex; align-items: center; gap: 10px;
  margin: 14px 0 10px;
}
.pdf-section .num {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  color: white;
}
.pdf-section .num-1 { background: var(--pdf-yellow); color: var(--pdf-ink); }
.pdf-section .num-2 { background: var(--pdf-orange); }
.pdf-section .num-3 { background: var(--pdf-red); }
.pdf-section .num-4 { background: var(--pdf-yellow); color: var(--pdf-ink); }
.pdf-section .num-5 { background: var(--pdf-orange); }
.pdf-section .num-6 { background: var(--pdf-red); }
.pdf-section .title {
  font-size: 16px; font-weight: 700; color: var(--pdf-ink);
}
.pdf-section .right {
  margin-left: auto;
  font-size: 10px; color: var(--pdf-mute); letter-spacing: 0.1em;
}

/* ===== Stat cards row (4) ===== */
.pdf-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.pdf-stat-card {
  background: var(--pdf-yellow-bg);
  border-radius: 12px;
  padding: 12px 14px;
  position: relative;
}
.pdf-stat-card .icon {
  width: 22px; height: 22px;
  border-radius: 50%;
  position: absolute; top: 10px; right: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: white;
}
.pdf-stat-card .label { font-size: 10px; color: var(--pdf-ink-soft); margin-bottom: 2px; }
.pdf-stat-card .value { font-size: 24px; font-weight: 700; line-height: 1; color: var(--pdf-blue); }
.pdf-stat-card .sub { font-size: 9px; color: var(--pdf-mute); margin-top: 4px; }

.pdf-stat-card.yellow { background: var(--pdf-yellow-bg); }
.pdf-stat-card.yellow .value { color: var(--pdf-blue); }
.pdf-stat-card.yellow .icon { background: var(--pdf-blue); }

.pdf-stat-card.pink { background: var(--pdf-pink-bg); }
.pdf-stat-card.pink .value { color: var(--pdf-pink); }
.pdf-stat-card.pink .icon { background: var(--pdf-pink); }

.pdf-stat-card.red { background: var(--pdf-red-bg); }
.pdf-stat-card.red .value { color: var(--pdf-red); }
.pdf-stat-card.red .icon { background: var(--pdf-red); }

.pdf-stat-card.teal { background: var(--pdf-teal-bg); }
.pdf-stat-card.teal .value { color: var(--pdf-teal); }
.pdf-stat-card.teal .icon { background: var(--pdf-teal); }

/* ===== Two-column row (chart + behavior) ===== */
.pdf-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.pdf-card {
  background: white;
  border-radius: 14px;
  padding: 14px;
  border: 1px solid var(--pdf-line);
  position: relative;
}
.pdf-card .head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.pdf-card .head .pill {
  background: var(--pdf-yellow);
  color: var(--pdf-ink);
  font-size: 10px;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
}
.pdf-card .head .pill.orange { background: var(--pdf-orange); color: white; }
.pdf-card .head .en {
  font-size: 11px; color: var(--pdf-mute); letter-spacing: 0.15em;
}

/* Donut chart block */
.pdf-att-block {
  display: grid; grid-template-columns: 130px 1fr; gap: 14px;
  align-items: center;
}
.pdf-att-block .donut {
  position: relative; width: 130px; height: 130px;
}
.pdf-att-block .donut canvas { width: 130px !important; height: 130px !important; }
.pdf-att-block .donut .center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.pdf-att-block .donut .center .pct {
  font-size: 22px; font-weight: 700; color: var(--pdf-blue);
}
.pdf-att-block .donut .center .lbl {
  font-size: 9px; color: var(--pdf-mute);
}
.pdf-att-block .legend { font-size: 11px; }
.pdf-att-block .legend .row {
  display: grid; grid-template-columns: 12px 1fr auto auto; gap: 6px;
  align-items: center; padding: 3px 0;
}
.pdf-att-block .legend .dot { width: 8px; height: 8px; border-radius: 50%; }
.pdf-att-block .legend .name { color: var(--pdf-ink); }
.pdf-att-block .legend .num { font-weight: 700; color: var(--pdf-ink); }
.pdf-att-block .legend .pct { color: var(--pdf-mute); font-size: 10px; }

/* Behavior block (empty state styled) */
.pdf-beh {
  border: 2px dashed var(--pdf-yellow);
  border-radius: 12px;
  padding: 18px 14px;
  text-align: center;
  background: var(--pdf-yellow-bg);
  min-height: 110px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.pdf-beh .ico {
  width: 30px; height: 30px;
  background: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  margin-bottom: 8px;
}
.pdf-beh .title { font-size: 13px; font-weight: 600; color: var(--pdf-ink); margin-bottom: 4px; }
.pdf-beh .sub { font-size: 10px; color: var(--pdf-ink-soft); line-height: 1.5; }

/* Line chart block */
.pdf-chart-wrap { height: 180px; margin-top: 4px; }
.pdf-chart-wrap canvas { width: 100% !important; height: 100% !important; }
.pdf-chart-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin-top: 10px;
}
.pdf-chart-stats .item {
  text-align: center;
  background: var(--pdf-yellow-bg);
  border-radius: 8px;
  padding: 8px;
}
.pdf-chart-stats .item.pink { background: var(--pdf-pink-bg); }
.pdf-chart-stats .item.red { background: var(--pdf-red-bg); }
.pdf-chart-stats .item.teal { background: var(--pdf-teal-bg); }
.pdf-chart-stats .label { font-size: 10px; color: var(--pdf-ink-soft); }
.pdf-chart-stats .value { font-size: 14px; font-weight: 700; color: var(--pdf-blue); }
.pdf-chart-stats .item.pink .value { color: var(--pdf-pink); }
.pdf-chart-stats .item.red .value { color: var(--pdf-red); }
.pdf-chart-stats .item.teal .value { color: var(--pdf-teal); }

/* ===== Page 2: Behavior story ===== */
.pdf-story-card {
  background: white;
  border: 2px solid var(--pdf-blue);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
}
.pdf-story-grid {
  display: grid; grid-template-columns: 50px 1fr; gap: 14px;
}
.pdf-dropcap {
  width: 44px; height: 44px;
  background: var(--pdf-orange);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 24px; font-weight: 700;
}
.pdf-story-text {
  font-size: 12px;
  line-height: 1.85;
  color: var(--pdf-ink);
  white-space: pre-wrap;
}
.pdf-story-foot {
  display: grid; grid-template-columns: 1fr auto; gap: 8px;
  margin-top: 12px; padding-top: 8px;
  border-top: 1px dashed var(--pdf-line);
  font-size: 10px;
  align-items: center;
}
.pdf-story-foot .tag {
  background: var(--pdf-blue-soft);
  color: var(--pdf-blue);
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 10px;
  width: fit-content;
}
.pdf-story-foot .ts { color: var(--pdf-mute); }

/* Insights two columns */
.pdf-insights {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-bottom: 14px;
}
.pdf-insight-card {
  background: white;
  border-radius: 12px;
  padding: 14px;
  border: 2px solid var(--pdf-line);
}
.pdf-insight-card .head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 2px dashed var(--pdf-line);
}
.pdf-insight-card .head .badge {
  width: 22px; height: 22px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 12px; font-weight: 700;
}
.pdf-insight-card .head h4 {
  font-size: 13px; font-weight: 700; margin: 0;
  color: var(--pdf-ink);
}
.pdf-insight-card .head .en {
  font-size: 10px; color: var(--pdf-mute); margin-left: auto;
}
.pdf-insight-card.blue { border-color: var(--pdf-blue); }
.pdf-insight-card.blue .badge { background: var(--pdf-blue); }
.pdf-insight-card.orange { border-color: var(--pdf-orange); }
.pdf-insight-card.orange .badge { background: var(--pdf-orange); }
.pdf-insight-card ul { list-style: none; padding: 0; margin: 0; }
.pdf-insight-card li {
  font-size: 11px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--pdf-line);
  display: flex;
  align-items: flex-start;
  gap: 6px;
  line-height: 1.55;
}
.pdf-insight-card li:last-child { border-bottom: 0; }
.pdf-insight-card li .bullet {
  flex-shrink: 0;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--pdf-blue);
  color: white;
  display: inline-flex;
  align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
  margin-top: 1px;
}
.pdf-insight-card li .bullet::before { content: '✓'; }
.pdf-insight-card.orange li .bullet { background: var(--pdf-orange); }
.pdf-insight-card.orange li .bullet::before { content: '!'; }
.pdf-insight-card li .text { flex: 1; min-width: 0; word-break: break-word; }
.pdf-insight-card li b { color: var(--pdf-blue); font-weight: 700; }
.pdf-insight-card.orange li b { color: var(--pdf-orange); font-weight: 700; }

/* Goals */
.pdf-goals {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-top: 8px;
}
.pdf-goal {
  border-radius: 12px;
  padding: 14px;
  color: white;
}
.pdf-goal.blue { background: var(--pdf-blue); }
.pdf-goal.orange { background: var(--pdf-orange); }
.pdf-goal .num-pill {
  display: inline-block;
  background: rgba(255,255,255,0.25);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10px;
  margin-bottom: 6px;
}
.pdf-goal .text {
  font-size: 12px; line-height: 1.55;
  font-weight: 500;
}

/* ===== Page 3: Attendance log ===== */
.pdf-log-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  margin-bottom: 14px;
}
.pdf-log-stat {
  background: white;
  border: 1.5px solid var(--pdf-line);
  border-radius: 10px;
  padding: 10px 12px;
  text-align: center;
}
.pdf-log-stat .label { font-size: 9px; color: var(--pdf-mute); }
.pdf-log-stat .value { font-size: 13px; font-weight: 700; color: var(--pdf-blue); margin-top: 2px; }

.pdf-log-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: 10px;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid var(--pdf-blue);
}
.pdf-log-table th {
  background: var(--pdf-blue);
  color: white;
  padding: 8px 6px;
  font-size: 10px;
  font-weight: 600;
  text-align: left;
}
.pdf-log-table td {
  padding: 7px 6px;
  border-bottom: 1px dashed var(--pdf-line);
  vertical-align: middle;
}
.pdf-log-table tr:nth-child(even) td { background: var(--pdf-yellow-bg); }
.pdf-log-table tr:last-child td { border-bottom: 0; }
.pdf-log-table .col-date { white-space: nowrap; color: var(--pdf-ink-soft); font-weight: 500; }
.pdf-log-table .col-cc {
  font-weight: 700; color: var(--pdf-blue);
  background: var(--pdf-blue-soft) !important;
  padding: 3px 8px; border-radius: 6px;
  display: inline-block; font-size: 9px;
}
.pdf-log-table .col-status .pill {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 9px; font-weight: 600;
}
.pdf-log-table .col-score { font-weight: 700; color: var(--pdf-orange); }
.pdf-log-table .col-score .pct { color: var(--pdf-mute); font-weight: 400; font-size: 9px; margin-left: 2px; }
.pdf-log-table .check-y { color: var(--pdf-blue); font-weight: 700; font-size: 12px; }
.pdf-log-table .check-n { color: var(--pdf-line); }

/* End block */
.pdf-end {
  background: var(--pdf-blue);
  color: white;
  border-radius: 14px;
  padding: 18px 22px;
  margin-top: 16px;
  position: relative;
  overflow: hidden;
}
.pdf-end-main {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  position: relative;
  z-index: 1;
}
.pdf-end-text { min-width: 0; }
.pdf-end-qr {
  display: flex; flex-direction: column;
  align-items: center;
  background: white;
  border-radius: 10px;
  padding: 8px 10px 6px;
  color: var(--pdf-ink);
}
.pdf-end-qr .qr-label {
  font-size: 9px; color: var(--pdf-ink-soft);
  margin-bottom: 4px; text-align: center;
  font-weight: 600;
}
.pdf-end-qr .pdf-line-qr {
  width: 78px; height: 78px;
  background: white;
  display: block;
  margin: 0;
  padding: 0;
  border-radius: 0;
}
.pdf-end-corner {
  position: absolute; right: -10px; bottom: -20px;
  width: 80px; height: 80px;
  background: var(--pdf-yellow);
  border-radius: 50%;
}
.pdf-end-title {
  font-size: 10px; letter-spacing: 0.2em; opacity: 0.85;
  margin-bottom: 4px;
}
.pdf-end h3 {
  font-size: 18px; font-weight: 700;
  margin: 0; color: white;
  position: relative; z-index: 1;
}
.pdf-end h3 .name { color: var(--pdf-yellow); }
.pdf-end .contact {
  margin-top: 12px;
  display: grid; grid-template-columns: 1fr 1fr;
  font-size: 10px;
  position: relative; z-index: 1;
  opacity: 0.95;
}
.pdf-end .contact .right { text-align: right; }

/* ===== Footer ===== */
.pdf-footer {
  position: absolute;
  bottom: 16px; left: 36px; right: 36px;
  padding-top: 12px;
  border-top: 1px solid var(--pdf-line);
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  font-size: 9px;
  color: var(--pdf-mute);
}
.pdf-footer strong { color: var(--pdf-blue); font-weight: 700; }
.pdf-footer .center { text-align: center; }
.pdf-footer .right { text-align: right; }
