:root {
  --primary: #1a237e;
  --primary-light: #3949ab;
  --accent: #e91e8c;
  --accent-soft: #f8bbd0;
  --gold: #f9a825;
  --silver: #78909c;
  --text: #212121;
  --text-muted: #616161;
  --text-light: #9e9e9e;
  --bg: #fafafa;
  --card: #ffffff;
  --border: #e0e0e0;
  --green: #2e7d32;
  --blue-dark: #0d47a1;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Sarabun', 'Inter', sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px 20px;
  color: var(--text);
}

.action-bar {
  width: 100%;
  max-width: 900px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.action-bar .back-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: rgba(255,255,255,0.85);
  font-size: 0.9rem;
  font-weight: 500;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 10px 18px;
  border-radius: 50px;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}
.action-bar .back-btn:hover {
  background: rgba(255,255,255,0.2);
  transform: translateX(-3px);
}

.action-bar .buttons-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-pdf {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: 'Inter', 'Sarabun', sans-serif;
}

.btn-pdf-primary {
  background: linear-gradient(135deg, #e91e8c, #9c27b0);
  color: white;
  box-shadow: 0 6px 20px rgba(233, 30, 140, 0.4);
}
.btn-pdf-primary:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 10px 30px rgba(233, 30, 140, 0.5);
}

.btn-pdf-secondary {
  background: rgba(255,255,255,0.12);
  color: white;
  border: 1px solid rgba(255,255,255,0.25);
  backdrop-filter: blur(10px);
}
.btn-pdf-secondary:hover {
  background: rgba(255,255,255,0.2);
  transform: translateY(-3px);
}

.btn-pdf.loading {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none !important;
}

#resume-book {
  display: flex;
  flex-direction: column;
  gap: 32px;
  align-items: center;
  width: 100%;
}

#resume-paper, #cert-paper {
  width: 100%;
  max-width: 900px;
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.05);
  overflow: hidden;
}

.cert-page-header {
  background: linear-gradient(135deg, #1a237e 0%, #4a148c 60%, #880e4f 100%);
  color: white;
  padding: 36px 50px 30px;
  position: relative; overflow: hidden;
}
.cert-page-header::before {
  content: '';
  position: absolute; top: -50px; right: -50px;
  width: 200px; height: 200px;
  background: rgba(255,255,255,0.05); border-radius: 50%;
}
.cert-page-header::after {
  content: '';
  position: absolute; bottom: -30px; left: 20%;
  width: 140px; height: 140px;
  background: rgba(233,30,140,0.1); border-radius: 50%;
}
.cert-page-header-inner {
  position: relative; z-index: 1;
  display: flex; justify-content: space-between; align-items: flex-end;
}
.cert-page-title {
  font-size: 1.5rem; font-weight: 800; letter-spacing: -0.3px;
}
.cert-page-title span {
  display: block; font-size: 0.85rem; font-weight: 400;
  opacity: 0.75; margin-top: 4px; letter-spacing: 0.3px;
}
.cert-page-label {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 2px;
  text-transform: uppercase; opacity: 0.6;
  border: 1px solid rgba(255,255,255,0.2);
  padding: 4px 12px; border-radius: 999px;
}

.cert-page-body {
  background: #f8f9fc;
  padding: 40px 50px;
}

.cert-page-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}

.cert-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #e0e0e0;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.cert-card-header-strip {
  padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
  background: white;
  border-bottom: 1px solid #f0f0f0;
}
.cert-badge {
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.95rem; flex-shrink: 0;
}
.cb-gold   { background: linear-gradient(135deg,#f57f17,#ffd54f); }
.cb-silver { background: linear-gradient(135deg,#455a64,#90a4ae); }
.cb-blue   { background: linear-gradient(135deg,#1565c0,#42a5f5); }
.cert-card-name { font-size: 0.75rem; font-weight: 700; color: #1a1a2e; line-height: 1.3; }
.cert-card-org  { font-size: 0.65rem; color: #666; margin-top: 1px; }
.cert-card img {
  width: 100%; display: block;
  aspect-ratio: 4/3; object-fit: cover;
}

.cert-page-footer {
  padding: 18px 50px;
  border-top: 1px solid #e0e0e0;
  display: flex; justify-content: space-between; align-items: center;
  background: white;
}
.cert-page-footer p {
  font-size: 0.7rem; color: #999;
}
.cert-page-footer .page-num {
  font-size: 0.7rem; font-weight: 700;
  background: #1a1a2e; color: white;
  padding: 3px 10px; border-radius: 999px;
}

@media (max-width: 700px) {
  .cert-page-body  { padding: 24px 16px; }
  .cert-page-header { padding: 28px 20px 24px; }
  .cert-page-grid { grid-template-columns: 1fr; }
  .cert-page-footer { padding: 14px 16px; }
}

.resume-header {
  background: linear-gradient(135deg, #1a237e 0%, #283593 40%, #3949ab 100%);
  color: white;
  padding: 50px 50px 40px;
  position: relative;
  overflow: hidden;
}

.resume-header::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 250px; height: 250px;
  background: rgba(233, 30, 140, 0.12);
  border-radius: 50%;
}
.resume-header::after {
  content: '';
  position: absolute;
  bottom: -40px; left: 30%;
  width: 180px; height: 180px;
  background: rgba(255,255,255,0.04);
  border-radius: 50%;
}

.header-layout {
  display: flex;
  align-items: flex-start;
  gap: 35px;
  position: relative;
  z-index: 1;
}

.profile-photo {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid rgba(255,255,255,0.3);
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
  flex-shrink: 0;
}

.header-info { flex: 1; }

.header-name {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
  line-height: 1.1;
}

.header-name span {
  background: linear-gradient(90deg, #f8bbd0, #e91e8c, #f8bbd0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-title {
  font-size: 1rem;
  font-weight: 400;
  opacity: 0.85;
  margin-bottom: 20px;
  letter-spacing: 0.5px;
}

.header-contacts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  opacity: 0.9;
}
.contact-item i { font-size: 0.8rem; opacity: 0.75; }
.contact-item a { color: white; text-decoration: none; }
.contact-item a:hover { text-decoration: underline; }

.header-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 18px;
}
.header-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.badge-gold {
  background: rgba(249, 168, 37, 0.25);
  color: #ffd54f;
  border: 1px solid rgba(249, 168, 37, 0.4);
}
.badge-silver {
  background: rgba(120, 144, 156, 0.25);
  color: #cfd8dc;
  border: 1px solid rgba(120, 144, 156, 0.4);
}
.badge-tech {
  background: rgba(233, 30, 140, 0.2);
  color: #f48fb1;
  border: 1px solid rgba(233, 30, 140, 0.3);
}

.resume-body {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 0;
}

.main-col { padding: 40px 45px; border-right: 1px solid var(--border); }
.side-col { padding: 40px 35px; background: #f8f9ff; }

.section { margin-bottom: 36px; }
.section:last-child { margin-bottom: 0; }

.section-title {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--primary-light);
  border-bottom: 2px solid var(--primary-light);
  padding-bottom: 6px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title i { font-size: 0.75rem; color: var(--accent); }

.summary-text {
  font-size: 0.92rem;
  line-height: 1.8;
  color: var(--text-muted);
}

.exp-item { margin-bottom: 24px; }
.exp-item:last-child { margin-bottom: 0; }

.exp-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 4px;
  gap: 10px;
}

.exp-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}
.exp-org {
  font-size: 0.82rem;
  color: var(--primary-light);
  font-weight: 500;
  margin-bottom: 8px;
}
.exp-date {
  font-size: 0.75rem;
  color: var(--text-light);
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 3px;
}

.exp-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.7;
}
.exp-desc li { margin-left: 16px; margin-bottom: 3px; }

.exp-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}
.exp-tag {
  font-size: 0.7rem;
  padding: 2px 9px;
  border-radius: 20px;
  background: #e8eaf6;
  color: var(--primary-light);
  font-weight: 600;
}

.divider { height: 1px; background: var(--border); margin: 16px 0; }

.award-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
}
.award-item:last-child { margin-bottom: 0; }

.award-medal {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.medal-gold { background: linear-gradient(135deg, #f9a825, #ffd54f); }
.medal-silver { background: linear-gradient(135deg, #607d8b, #90a4ae); }
.medal-cert { background: linear-gradient(135deg, #1565c0, #42a5f5); }

.award-name { font-size: 0.88rem; font-weight: 700; color: var(--text); }
.award-org { font-size: 0.78rem; color: var(--text-muted); }

.award-cert-img { display: none; }

.skill-category { margin-bottom: 20px; }
.skill-cat-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--primary-light);
  margin-bottom: 10px;
}

.skill-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.skill-chip {
  font-size: 0.75rem;
  padding: 4px 11px;
  border-radius: 20px;
  font-weight: 500;
  border: 1px solid transparent;
}
.chip-frontend { background: #e3f2fd; color: #1565c0; border-color: #90caf9; }
.chip-backend  { background: #e8f5e9; color: #2e7d32; border-color: #a5d6a7; }
.chip-infra    { background: #f3e5f5; color: #6a1b9a; border-color: #ce93d8; }
.chip-tool     { background: #fff3e0; color: #e65100; border-color: #ffcc80; }
.chip-sec      { background: #fce4ec; color: #880e4f; border-color: #f48fb1; }

.info-list li {
  list-style: none;
  font-size: 0.83rem;
  color: var(--text-muted);
  margin-bottom: 9px;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  line-height: 1.5;
}
.info-list li i {
  font-size: 0.8rem;
  color: var(--primary-light);
  margin-top: 2px;
  flex-shrink: 0;
  width: 14px;
  text-align: center;
}

.lang-item {
  margin-bottom: 12px;
}
.lang-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
  display: flex;
  justify-content: space-between;
}
.lang-name span { color: var(--text-light); font-weight: 400; font-size: 0.75rem; }
.lang-bar {
  height: 5px;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.lang-fill {
  height: 100%;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--primary-light), var(--accent));
}

.edu-item { margin-bottom: 18px; }
.edu-school { font-size: 0.85rem; font-weight: 700; color: var(--text); }
.edu-degree { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.edu-year   { font-size: 0.72rem; color: var(--text-light); margin-top: 3px; }

.resume-footer {
  padding: 18px 45px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f5f5f5;
}
.resume-footer p {
  font-size: 0.72rem;
  color: var(--text-light);
}

@media print {
  body { background: white; padding: 0; }
  .action-bar { display: none; }
  #resume-paper {
    max-width: 100%;
    border-radius: 0;
    box-shadow: none;
  }
}

@media (max-width: 700px) {
  .header-layout { flex-direction: column; align-items: center; text-align: center; }
  .header-contacts { justify-content: center; }
  .header-badges { justify-content: center; }
  .resume-body { grid-template-columns: 1fr; }
  .main-col { padding: 28px 24px; border-right: none; border-bottom: 1px solid var(--border); }
  .side-col { padding: 28px 24px; }
  .resume-header { padding: 36px 24px 30px; }
  .resume-footer { flex-direction: column; gap: 4px; padding: 16px 24px; }
}
