/* ==========================================================
   STYLING APLIKASI PRESENSI PELATIHAN & GENERATOR PIAGAM
   MOBILE-FIRST & RESPONSIVE UI/UX UNTUK HANDPHONE
   ========================================================== */

:root {
  --primary: #0f2942;
  --primary-light: #1e4976;
  --accent: #b48811;
  --accent-light: #f3e5ab;
  --whatsapp: #25D366;
  --whatsapp-dark: #128C7E;
  --success: #16a34a;
  --danger: #dc2626;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 16px;
  --shadow: 0 10px 25px -5px rgba(15, 41, 66, 0.08), 0 8px 10px -6px rgba(15, 41, 66, 0.04);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom, 20px);
}

/* Navbar / Topbar */
.topbar {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  padding: 0.85rem 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  min-width: 0;
}

.brand span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-badge {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, #ebd197, #b48811);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.05rem;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.nav-links a {
  color: rgba(255, 255, 255, 0.95);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 0.85rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.14);
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-links a:hover,
.nav-links a:active {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

/* Containers */
.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.25rem 1rem;
}

.container-narrow {
  max-width: 560px;
  margin: 0 auto;
  padding: 1rem 0.9rem 3.5rem;
}

/* Step Indicator untuk Peserta di Handphone */
.step-indicator {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  margin-bottom: 1rem;
  background: #e2e8f0;
  padding: 0.35rem;
  border-radius: 12px;
}

@media (max-width: 520px) {
  .step-indicator {
    grid-template-columns: 1fr 1fr;
  }
}

/* Stat Cards untuk Rekapitulasi */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid var(--border);
  border-left: 5px solid var(--primary);
  border-radius: 12px;
  padding: 1rem 1.15rem;
  box-shadow: 0 2px 8px rgba(15, 41, 66, 0.05);
}

.stat-card.gold {
  border-left-color: var(--accent);
}

.stat-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.4px;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
  margin-top: 0.25rem;
}

.step-pill {
  text-align: center;
  padding: 0.55rem 0.5rem;
  font-size: 0.82rem;
  font-weight: 700;
  border-radius: 9px;
  color: var(--text-muted);
  transition: all 0.25s;
}

.step-pill.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 2px 6px rgba(15, 41, 66, 0.1);
}

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 1.35rem;
  margin-bottom: 1.15rem;
}

.card-header-banner {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  padding: 1.5rem 1.35rem;
  border-radius: var(--radius) var(--radius) 0 0;
  margin: -1.35rem -1.35rem 1.35rem -1.35rem;
  border-bottom: 4px solid var(--accent);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.badge-open {
  background: #dcfce7;
  color: #15803d;
}

.badge-closed {
  background: #fee2e2;
  color: #b91c1c;
}

.badge-gold {
  background: rgba(235, 209, 151, 0.2);
  color: #f3e5ab;
  border: 1px solid rgba(235, 209, 151, 0.45);
}

/* Forms (Ukuran font wajib >= 16px agar iOS/Android tidak auto-zoom saat diketik) */
.form-group {
  margin-bottom: 1.2rem;
}

.form-label {
  display: block;
  font-weight: 700;
  font-size: 0.94rem;
  margin-bottom: 0.45rem;
  color: var(--text);
}

.form-hint {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  line-height: 1.4;
}

.form-control {
  width: 100%;
  min-height: 48px;
  padding: 0.75rem 1rem;
  font-size: 16px;
  border: 1.5px solid #cbd5e1;
  border-radius: 12px;
  background-color: #fff;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
  appearance: none;
}

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23475569' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 13px;
  padding-right: 2.5rem;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3.5px rgba(30, 73, 118, 0.16);
}

/* Buttons (Touch-Friendly min-height 48px di HP) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0.75rem 1.2rem;
  font-size: 0.96rem;
  font-weight: 700;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s, background-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
  text-align: center;
  user-select: none;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-block {
  width: 100%;
  min-height: 52px;
  padding: 0.9rem 1.25rem;
  font-size: 1.02rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(15, 41, 66, 0.18);
}

.btn-gold {
  background: linear-gradient(135deg, #c59b27 0%, #9a740b 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(180, 136, 17, 0.22);
}

.btn-wa {
  background: var(--whatsapp);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.22);
}

.btn-wa:hover:not(:disabled) {
  background: var(--whatsapp-dark);
}

.btn-outline {
  background: #fff;
  color: var(--text);
  border: 1.5px solid #cbd5e1;
}

.btn-outline:hover:not(:disabled) {
  background: #f8fafc;
  border-color: #94a3b8;
}

.btn-danger {
  background: #fee2e2;
  color: var(--danger);
}

.btn-sm {
  min-height: 38px;
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
  border-radius: 9px;
}

/* Action Button Groups (Otomatis menumpuk vertikal di layar HP) */
.action-group-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.toolbar-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.85rem;
}

/* Certificate Canvas Preview Wrapper */
.canvas-preview-container {
  position: relative;
  width: 100%;
  background: #0f172a;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid var(--border);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none; /* Mencegah layar ikut tergulir saat jari menggeser teks piagam di HP */
}

.canvas-preview-container canvas {
  width: 100%;
  height: auto;
  display: block;
}

/* Admin Layout Tabs (Horizontal Scrollable di HP) */
.admin-tabs {
  display: flex;
  gap: 0.45rem;
  margin-bottom: 1.25rem;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.admin-tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  padding: 0.65rem 1.05rem;
  border-radius: 10px;
  border: none;
  background: #e2e8f0;
  color: var(--text-muted);
  font-weight: 700;
  cursor: pointer;
  font-size: 0.88rem;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 10px rgba(15, 41, 66, 0.2);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.grid-editor {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 1.25rem;
  align-items: start;
}

/* Tables & Responsive Mobile Cards */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th, td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: #f8fafc;
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Alert Box */
.alert {
  padding: 0.95rem 1.1rem;
  border-radius: 12px;
  margin-bottom: 1.15rem;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.45;
}

.alert-success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-info {
  background: #e0f2fe;
  color: #075985;
  border: 1px solid #bae6fd;
}

/* Range Slider Control Box */
.control-section {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.control-section-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--primary);
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.slider-row {
  display: grid;
  grid-template-columns: 125px 1fr 54px;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
}

.slider-row input[type="range"] {
  width: 100%;
  height: 28px;
  accent-color: var(--primary);
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* ==========================================================
   STANDARD DATA TABLE CONTROLS & PAGINATION
   ========================================================== */

.dt-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.dt-length-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-muted);
}

.dt-select {
  min-height: 38px;
  padding: 0.35rem 2rem 0.35rem 0.7rem;
  font-size: 0.88rem;
  font-weight: 600;
  border: 1.5px solid #cbd5e1;
  border-radius: 9px;
  background-color: #fff;
  color: var(--text);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23475569' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  background-size: 11px;
  cursor: pointer;
}

.dt-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

.dt-info {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.dt-pagination {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.dt-page-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  font-family: inherit;
}

.dt-page-btn:hover:not(:disabled):not(.active) {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.dt-page-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.dt-page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.dt-ellipsis {
  padding: 0 0.35rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 700;
}

/* ==========================================================
   MEDIA QUERIES KHUSUS LAYAR HANDPHONE & TABLET
   ========================================================== */

@media (max-width: 900px) {
  .grid-2, .grid-editor {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 0.75rem 0.85rem;
  }

  .brand {
    font-size: 0.95rem;
  }

  .brand-badge {
    width: 32px;
    height: 32px;
    font-size: 0.95rem;
  }

  .nav-links a {
    padding: 0.42rem 0.68rem;
    font-size: 0.78rem;
  }

  .container, .container-narrow {
    padding: 0.75rem 0.75rem 3rem;
  }

  .card {
    padding: 1.1rem;
    border-radius: 14px;
  }

  .card-header-banner {
    padding: 1.25rem 1.1rem;
    margin: -1.1rem -1.1rem 1.15rem -1.1rem;
    border-radius: 14px 14px 0 0;
  }

  /* Tombol Download PDF & PNG menumpuk penuh di HP agar mudah ditekan ibu jari */
  .action-group-2 {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .toolbar-flex {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-flex > * {
    width: 100%;
  }

  .slider-row {
    grid-template-columns: 1fr auto;
    row-gap: 0.2rem;
  }

  .slider-row input[type="range"] {
    grid-column: 1 / -1;
    order: 3;
  }

  /* Ubah Tabel Rekap Admin menjadi Kartu Vertikal (Card View) di Handphone */
  table.mobile-card-table thead {
    display: none;
  }

  table.mobile-card-table,
  table.mobile-card-table tbody,
  table.mobile-card-table tr,
  table.mobile-card-table td {
    display: block;
    width: 100%;
  }

  table.mobile-card-table tr {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem 0.9rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
  }

  table.mobile-card-table td {
    padding: 0.38rem 0;
    border-bottom: 1px dashed #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    text-align: right !important;
    font-size: 0.88rem;
  }

  table.mobile-card-table td:last-child {
    border-bottom: none;
    padding-top: 0.65rem;
    justify-content: flex-end;
  }

  table.mobile-card-table td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.76rem;
    text-transform: uppercase;
    text-align: left;
    flex-shrink: 0;
  }

  .dt-footer {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
}

/* Modal Dialog */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 500px;
  overflow: hidden;
  border: 1px solid var(--border);
  animation: modalPopIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPopIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 1.15rem 1.35rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 0.3rem;
  transition: color 0.15s;
}

.modal-close-btn:hover {
  color: #fff;
}

.modal-body {
  padding: 1.35rem;
}

.modal-footer {
  padding: 1rem 1.35rem;
  background: #f8fafc;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}
