/* ==========================================================================
   Portal Sertifikat Workshop — PGRI Cabang Pulau Sembilan
   ========================================================================== */

:root {
  --red: #c62828;
  --red-dark: #9b1c1c;
  --red-soft: #fdeceb;
  --gold: #f2c94c;
  --gold-soft: #fdf6dc;
  --green: #2e7d32;
  --green-soft: #e8f5e9;
  --ink: #1f2328;
  --ink-soft: #5f6672;
  --ink-faint: #8b919b;
  --line: #e8e1d5;
  --bg: #faf7f0;
  --card: #ffffff;
  --radius-lg: 24px;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 24px 60px -32px rgba(72, 48, 24, 0.45);
  --shadow-soft: 0 10px 30px -20px rgba(72, 48, 24, 0.4);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1100px 520px at 12% -8%, #fdeae8 0%, transparent 60%),
    radial-gradient(900px 480px at 100% 0%, #fdf6dc 0%, transparent 55%),
    var(--bg);
  line-height: 1.6;
}

/* Ruang untuk footer tetap di halaman publik */
body:not(.admin-body) {
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

/* Bar aksen atas */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 5px;
  background: linear-gradient(90deg, var(--red) 0%, var(--gold) 50%, var(--green) 100%);
  z-index: 50;
}

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

a {
  color: var(--red);
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.9em;
  background: #f4efe6;
  padding: 1px 6px;
  border-radius: 6px;
}

/* ==========================================================================
   Halaman publik
   ========================================================================== */

.page {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 0 24px 24px;
}

.site-header {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 52px 4px 8px;
}

.logo {
  width: 72px;
  height: 72px;
  flex: 0 0 auto;
  filter: drop-shadow(0 8px 16px rgba(120, 40, 30, 0.18));
}

.header-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--red);
}

.site-header h1 {
  margin: 0;
  font-size: clamp(1.35rem, 1.1rem + 1.4vw, 1.95rem);
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 0.98rem;
  font-weight: 500;
}

.event-date {
  margin: 2px 0 0;
  color: var(--ink-faint);
  font-size: 0.88rem;
}

.content {
  padding-top: 26px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

.search-card {
  position: relative;
  padding: 30px 30px 26px;
  box-shadow: var(--shadow);
}

.search-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  background: linear-gradient(90deg, var(--red), var(--gold) 55%, var(--green));
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
}

.search-card h2 {
  margin: 0 0 4px;
  font-size: 1.25rem;
}

.lead {
  margin: 0 0 20px;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.input-wrap {
  position: relative;
}

/* --- Dropdown saran nama --- */

.suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 60;
  padding: 6px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 26px 50px -22px rgba(60, 40, 20, 0.38);
  max-height: 292px;
  overflow-y: auto;
  animation: dropIn 0.16s ease both;
}

@keyframes dropIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.suggestion-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  font-size: 0.95rem;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s ease;
}

.suggestion-item:hover,
.suggestion-item.is-active {
  background: #fdf3f0;
}

.suggestion-avatar {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--red-soft);
  color: var(--red);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.suggestion-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestion-name mark {
  background: transparent;
  color: var(--red);
  font-weight: 700;
}

.suggestion-empty {
  padding: 14px 12px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 0.86rem;
}

.input-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  width: 20px;
  height: 20px;
  transform: translateY(-50%);
  color: var(--ink-faint);
  pointer-events: none;
}

.input-hint {
  position: absolute;
  left: 48px;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: #a9a49a;
  font-size: 1.02rem;
  line-height: 1.35;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.input-wrap.has-value .input-hint {
  opacity: 0;
}

.hint-example {
  color: #b5afa4;
}

#name-input {
  width: 100%;
  height: 58px;
  padding: 0 16px 0 48px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: #fffdf9;
  font-size: 1.05rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

#name-input::placeholder {
  color: #a9a49a;
  font-size: 0.92em;
}

#name-input:focus {
  outline: none;
  background: #ffffff;
  border-color: var(--red);
  box-shadow: 0 0 0 4px rgba(198, 40, 40, 0.12);
}

.btn-search {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 54px;
  margin-top: 12px;
  border: none;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #d02f2f 0%, var(--red) 45%, var(--red-dark) 100%);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.12s ease, box-shadow 0.2s ease, filter 0.2s ease;
  box-shadow: 0 12px 24px -14px rgba(198, 40, 40, 0.8);
}

.btn-search:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.04);
  box-shadow: 0 16px 30px -14px rgba(198, 40, 40, 0.85);
}

.btn-search:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-search:disabled {
  cursor: progress;
  opacity: 0.85;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* --- Hasil pencarian ----------------------------------------------------- */

.result {
  margin-top: 22px;
  scroll-margin: 24px 0;
}

.result-card {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding: 24px;
  animation: rise 0.32s ease both;
}

.result-card.success {
  border-left: 5px solid var(--green);
}

.result-card.not-found {
  border-left: 5px solid var(--gold);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-icon {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  font-weight: 800;
}

.result-icon.success {
  background: var(--green-soft);
  color: var(--green);
}

.result-icon.warn {
  background: var(--gold-soft);
  color: #a8791a;
}

.result-body {
  min-width: 0;
  flex: 1;
}

.result-label {
  margin: 0 0 2px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.result-name {
  margin: 0 0 14px;
  font-size: 1.3rem;
  line-height: 1.3;
}

.result-text {
  margin: 0 0 16px;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.result-text strong {
  color: var(--ink);
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 22px;
  border-radius: 14px;
  background: linear-gradient(135deg, #388e3c 0%, var(--green) 100%);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  touch-action: manipulation;
  box-shadow: 0 12px 24px -16px rgba(46, 125, 50, 0.9);
  transition: transform 0.12s ease, filter 0.2s ease;
}

.btn-download:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.btn-download svg {
  width: 19px;
  height: 19px;
}

.result-note {
  margin: 12px 0 0;
  font-size: 0.78rem;
  color: var(--ink-faint);
}

.btn-wa {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 12px 20px;
  border-radius: 14px;
  background: #25d366;
  color: #08351a;
  font-weight: 700;
  font-size: 0.92rem;
  text-decoration: none;
  touch-action: manipulation;
  box-shadow: 0 12px 24px -16px rgba(37, 211, 102, 0.9);
  transition: transform 0.12s ease, filter 0.2s ease;
}

.btn-wa:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.btn-wa svg {
  width: 18px;
  height: 18px;
}

/* --- Footer & toast ------------------------------------------------------ */

.site-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: 11px 24px calc(11px + env(safe-area-inset-bottom));
  text-align: center;
  color: var(--ink-faint);
  font-size: 0.8rem;
  background: rgba(250, 247, 240, 0.88);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.site-footer p {
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 200;
  max-width: min(92vw, 460px);
  padding: 13px 20px;
  border-radius: 14px;
  background: #26211b;
  color: #fff;
  font-size: 0.9rem;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.6);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Di halaman publik, toast naik agar tidak menutupi footer tetap */
body:not(.admin-body) .toast {
  bottom: calc(76px + env(safe-area-inset-bottom));
}

/* ==========================================================================
   Panel admin
   ========================================================================== */

.admin-body {
  background:
    radial-gradient(900px 420px at 0% -10%, #fdeae8 0%, transparent 55%),
    var(--bg);
}

.admin-shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 24px 56px;
}

.auth-card {
  max-width: 420px;
  margin: 12vh auto 0;
  padding: 34px 32px 28px;
  box-shadow: var(--shadow);
  text-align: center;
}

.auth-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
}

.auth-card h1 {
  margin: 0;
  font-size: 1.4rem;
}

.auth-sub {
  margin: 4px 0 22px;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.auth-form {
  text-align: left;
}

.auth-form label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  font-weight: 600;
}

.auth-form input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fffdf9;
}

.auth-form input:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 4px rgba(198, 40, 40, 0.1);
}

.auth-form .btn {
  margin-top: 14px;
}

.auth-link {
  display: inline-block;
  margin-top: 20px;
  color: var(--ink-faint);
  font-size: 0.82rem;
  text-decoration: none;
}

.auth-link:hover {
  color: var(--red);
}

.form-error {
  min-height: 20px;
  margin: 10px 0 0;
  color: #b3261e;
  font-size: 0.83rem;
  line-height: 1.4;
}

/* --- Header dashboard ---------------------------------------------------- */

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.admin-brand img {
  width: 48px;
  height: 48px;
}

.admin-brand h1 {
  margin: 0;
  font-size: 1.3rem;
}

.admin-brand p {
  margin: 0;
  color: var(--ink-faint);
  font-size: 0.82rem;
}

.admin-header-actions {
  display: flex;
  gap: 8px;
}

/* --- Tombol -------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: #f7f2e9;
  border-color: #dcd3c4;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

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

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

.btn.primary:hover:not(:disabled) {
  background: var(--red-dark);
  border-color: var(--red-dark);
}

.btn.ghost {
  background: transparent;
}

.btn.block {
  width: 100%;
}

.btn.tiny {
  padding: 6px 11px;
  font-size: 0.8rem;
  border-radius: 9px;
}

.btn.danger {
  color: #b3261e;
  border-color: #f0ccc9;
}

.btn.danger:hover:not(:disabled) {
  background: #fdf0ef;
  border-color: #e4b3af;
}

/* --- Statistik ----------------------------------------------------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat {
  padding: 16px 18px;
  border-radius: var(--radius);
  box-shadow: none;
}

.stat-label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.stat strong {
  font-size: 1.55rem;
  line-height: 1.2;
}

.stat-top {
  font-size: 1rem !important;
  font-weight: 700;
}

/* --- Toolbar ------------------------------------------------------------- */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  margin-bottom: 16px;
  border-radius: var(--radius);
  box-shadow: none;
}

.toolbar-left {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-right input {
  width: 240px;
  height: 40px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fffdf9;
  font-size: 0.9rem;
}

.toolbar-right input:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.1);
}

/* --- Tabel --------------------------------------------------------------- */

.table-card {
  overflow: hidden;
  border-radius: var(--radius);
  box-shadow: none;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
}

thead th {
  padding: 13px 16px;
  text-align: left;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-faint);
  background: #fbf7f0;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid #f2ece1;
  font-size: 0.9rem;
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: #fdfaf4;
}

.name-cell {
  font-weight: 600;
}

.link-cell a {
  color: var(--red);
  text-decoration: none;
  font-size: 0.84rem;
}

.link-cell a:hover {
  text-decoration: underline;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

th.num {
  text-align: right;
}

td.actions,
th.actions {
  text-align: right;
  white-space: nowrap;
}

td.actions .btn + .btn {
  margin-left: 6px;
}

.empty {
  margin: 0;
  padding: 34px 20px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 0.9rem;
}

/* --- Dialog -------------------------------------------------------------- */

.dialog {
  width: min(520px, calc(100vw - 32px));
  padding: 0;
  border: none;
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 40px 90px -30px rgba(30, 20, 10, 0.55);
}

.dialog::backdrop {
  background: rgba(28, 20, 12, 0.45);
  backdrop-filter: blur(2px);
}

.dialog form {
  padding: 26px 26px 22px;
}

.dialog h2 {
  margin: 0 0 16px;
  font-size: 1.2rem;
}

.dialog label {
  display: block;
  margin: 14px 0 6px;
  font-size: 0.85rem;
  font-weight: 600;
}

.dialog input[type="text"],
.dialog input[type="password"],
.dialog textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fffdf9;
  font-size: 0.93rem;
  resize: vertical;
}

.dialog input:focus,
.dialog textarea:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.1);
}

.field-help {
  margin: 6px 0 0;
  color: var(--ink-faint);
  font-size: 0.78rem;
}

.dialog-help {
  margin: 0 0 14px;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.import-file-row {
  margin-bottom: 14px;
}

.import-file-row input[type="file"] {
  font-size: 0.84rem;
  width: 100%;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* ==========================================================================
   Responsif
   ========================================================================== */

@media (max-width: 720px) {
  .page {
    padding: 0 16px 32px;
  }

  .site-header {
    padding-top: 40px;
    gap: 14px;
  }

  .logo {
    width: 56px;
    height: 56px;
  }

  .search-card {
    padding: 24px 20px 22px;
    border-radius: 20px;
  }

  .result-card {
    padding: 20px 18px;
    gap: 14px;
  }

  .result-icon {
    width: 38px;
    height: 38px;
  }

  .btn-download,
  .btn-wa {
    width: 100%;
    justify-content: center;
  }

  .admin-shell {
    padding: 32px 16px 48px;
  }

  .site-footer {
    padding: 9px 16px calc(9px + env(safe-area-inset-bottom));
    font-size: 0.74rem;
  }

  .suggestions {
    max-height: 42vh;
    border-radius: 14px;
  }

  .suggestion-item {
    padding: 11px 10px;
  }

  #name-input::placeholder {
    font-size: 0.86em;
  }

  .input-hint {
    font-size: 0.86rem;
    line-height: 1.32;
  }

  .stats {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .toolbar {
    align-items: stretch;
  }

  .toolbar-left,
  .toolbar-right {
    width: 100%;
  }

  .toolbar-right input {
    width: 100%;
  }

  .toolbar-left .btn {
    flex: 1;
  }

  .admin-header {
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
