/* ============================================
   Presensi — Elegant Islamic Theme
   ============================================ */

:root {
  --green-deep: #0f5132;
  --green-mid: #157347;
  --green-soft: #d1e7dd;
  --gold: #b8985a;
  --gold-soft: #f5ead0;
  --gold-deep: #8a6d3b;
  --ink: #1c2321;
  --ink-soft: #4a5c54;
  --muted: #8a9a93;
  --bg: #f4f6f4;
  --card: #ffffff;
  --border: #e4e9e5;
  --danger: #b02a37;
  --danger-soft: #f8d7da;
  --success: #157347;
  --success-soft: #d1e7dd;
  --warning: #997404;
  --warning-soft: #fff3cd;
  --shadow-lg: 0 20px 50px -20px rgba(15, 81, 50, 0.18);
  --shadow-md: 0 8px 24px -8px rgba(15, 81, 50, 0.12);
  --shadow-sm: 0 2px 6px rgba(15, 81, 50, 0.06);
  --radius: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { min-height: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
}

/* ============ BACKGROUND ISLAMIC ============ */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(21, 115, 71, 0.08), transparent 60%),
    radial-gradient(ellipse 60% 50% at 100% 100%, rgba(184, 152, 90, 0.06), transparent 60%),
    linear-gradient(180deg, #f8faf9 0%, #f4f6f4 100%);
}

.bg-pattern {
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.35;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'><g fill='none' stroke='%230f5132' stroke-width='0.7' stroke-opacity='0.35'><path d='M80 10 L150 80 L80 150 L10 80 Z'/><path d='M80 25 L135 80 L80 135 L25 80 Z'/><circle cx='80' cy='80' r='30'/><circle cx='80' cy='80' r='14'/><path d='M80 0 L80 20 M80 140 L80 160 M0 80 L20 80 M140 80 L160 80'/></g></svg>");
  background-size: 160px 160px;
  animation: bgDrift 120s linear infinite;
  pointer-events: none;
}

@keyframes bgDrift {
  from { background-position: 0 0; }
  to   { background-position: 320px 320px; }
}

.bg-glow {
  position: fixed;
  width: 520px; height: 520px;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  pointer-events: none;
  opacity: 0.5;
  animation: glowFloat 24s ease-in-out infinite;
}
.bg-glow.g1 { top: -140px; left: -140px; background: #a7d3ba; }
.bg-glow.g2 { bottom: -140px; right: -140px; background: #e6d3a8; animation-delay: -12s; }

@keyframes glowFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(30px, 30px) scale(1.08); }
}

/* ============ LAYOUT ============ */
.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 16px 64px;
  position: relative;
}

/* ============ HEADER ============ */
.hero {
  text-align: center;
  padding: 24px 8px 28px;
  animation: fadeUp 0.7s ease-out both;
}

.hero-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px; height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--white-deep), var(--green-mid));
  color: var(--gold-soft);
  box-shadow: 0 12px 28px -10px rgba(15, 81, 50, 0.5), inset 0 -2px 0 rgba(0,0,0,0.1);
  margin-bottom: 16px;
  position: relative;
}
.hero-mark::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1.5px solid var(--gold);
  opacity: 0.35;
}
.hero-mark svg { width: 36px; height: 36px; }

.hero h1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(24px, 5vw, 34px);
  font-weight: 700;
  color: var(--green-deep);
  letter-spacing: -0.3px;
  margin-bottom: 6px;
}
.hero .subtitle {
  font-size: 13px;
  color: var(--ink-soft);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-weight: 500;
}
.hero .divider {
  width: 60px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  margin: 14px auto 0;
}
  /* Menyesuaikan ukuran logo di dalam lingkaran header */
  .hero-mark img {
    width: 44px;
    height: 44px;
    object-fit: contain;
  }
/* ============ CARD ============ */
/* ============ CARD ============ */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  padding: 28px;
  margin-bottom: 20px;
  animation: fadeUp 0.6s ease-out both;
  position: relative;
  /* Ubah overflow menjadi visible agar dropdown tidak terpotong */
  overflow: visible; 
}

/* Pindahkan garis gradient ke pseudo-element agar tidak bocor ke luar */
.card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--green-deep), var(--gold), var(--green-deep));
  opacity: 0.85;
  /* Kunci lengkungan atas mengikuti border-radius card */
  border-radius: var(--radius) var(--radius) 0 0;
}

/* Khusus untuk mobile, padding dikecilkan */
@media (max-width: 480px) {
  .card { padding: 20px 16px; }
}
.card.delay-1 { animation-delay: 0.1s; }
.card.delay-2 { animation-delay: 0.2s; }
.card.delay-3 { animation-delay: 0.3s; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============ SECTION TITLE ============ */
.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--green-deep);
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.section-title .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green-deep);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.section-title .num.done {
  background: var(--green-mid);
  color: #fff;
}

/* ============ FORM ============ */
.form-group { margin-bottom: 18px; }
.form-group:last-child { margin-bottom: 0; }

.form-group > label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 8px;
  letter-spacing: 0.2px;
}
.form-group > label .req { color: var(--danger); margin-left: 2px; }

input[type=text],
input[type=email],
input[type=password],
input[type=tel],
input[type=date],
input[type=time],
input[type=file],
select,
textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  background: #fbfcfb;
  transition: all 0.18s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green-mid);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(21, 115, 71, 0.1);
}
select:disabled, input:disabled {
  background: #f1f3f2;
  color: var(--muted);
  cursor: not-allowed;
}

.hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.5;
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
  background: linear-gradient(135deg, var(--green-deep), var(--green-mid));
  color: #fff;
  box-shadow: 0 6px 16px -6px rgba(15, 81, 50, 0.5);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px -8px rgba(15, 81, 50, 0.6);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-ghost {
  background: #fff;
  color: var(--green-deep);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { border-color: var(--green-mid); background: #f8faf9; }

.btn-gold {
  background: var(--gold-soft);
  color: var(--gold-deep);
  border: 1.5px solid rgba(184,152,90,0.3);
}
.btn-gold:hover:not(:disabled) { background: var(--gold); color: #fff; }

.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 24px; font-size: 15px; }

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.btn-group .btn { flex: 1; min-width: 130px; }

/* ============ STATUS BANNER ============ */
.status {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid transparent;
  margin-top: 10px;
}
.status svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.status-pending { background: #fef9e7; color: var(--warning); border-color: #f7e5a5; }
.status-ok      { background: var(--success-soft); color: var(--success); border-color: #b8dfc7; }
.status-err     { background: var(--danger-soft); color: var(--danger); border-color: #f0b8bd; }

/* ============ ACARA BAR ============ */
.acara-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  background: linear-gradient(135deg, #f0f7f2, #e8f2ec);
  border: 1px solid #d4e6db;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 14px;
  font-size: 13px;
}
.acara-bar .item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--green-deep);
  font-weight: 500;
}
.acara-bar .item strong {
  font-weight: 700;
}
.acara-bar svg { width: 14px; height: 14px; opacity: 0.7; }

/* ============ PROGRESS ============ */
.progress-bar {
  height: 6px;
  background: #e8ede9;
  border-radius: 100px;
  overflow: hidden;
  margin: 12px 0;
}
.progress-bar .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green-mid), var(--gold));
  border-radius: 100px;
  transition: width 0.6s ease;
}
.progress-steps {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}
.progress-steps span.active { color: var(--green-mid); font-weight: 700; }
.progress-steps span.done { color: var(--green-mid); }

/* ============ SIGNATURE CANVAS ============ */
.signature-wrapper {
  border: 1.5px dashed #c8d5cd;
  border-radius: var(--radius-sm);
  padding: 8px;
  background: #fbfcfb;
  position: relative;
  transition: border-color 0.2s;
}
.signature-wrapper:focus-within,
.signature-wrapper.signed {
  border-color: var(--green-mid);
  background: #fff;
}
#signatureCanvas {
  width: 100%;
  height: 180px;
  display: block;
  touch-action: none; /* PENTING: Mencegah layar ikut ter-scroll saat menggambar */
  background: #fff;
  border-radius: 6px;
}
.signature-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

/* ============ VIDEO ============ */
.video-wrap {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #1a1a1a;
  aspect-ratio: 4/3;
  max-width: 320px;
  box-shadow: var(--shadow-sm);
}
#video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.video-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.7);
  font-size: 12px;
  pointer-events: none;
  text-align: center;
  padding: 16px;
}
.video-overlay.hidden { display: none; }

.preview-img {
  width: 120px;
  height: 90px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  border: 2px solid var(--green-soft);
}

/* ============ MODAL ============ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(12, 28, 20, 0.55);
  backdrop-filter: blur(4px);
  z-index: 9998;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}
.modal-overlay.active { display: flex; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 28px;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: popIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  border-top: 3px solid var(--gold);
}
@keyframes popIn {
  from { transform: scale(0.92) translateY(8px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}
.modal-box h3 {
  font-family: 'Playfair Display', Georgia, serif;
  color: var(--green-deep);
  margin-bottom: 6px;
  font-size: 20px;
}
.modal-box .subtitle {
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 20px;
}
.modal-box .actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}
.modal-msg {
  font-size: 13px;
  margin-top: 12px;
  min-height: 18px;
  padding: 8px 10px;
  border-radius: 6px;
  display: none;
}
.modal-msg.show { display: block; }
.modal-msg.err { color: var(--danger); background: var(--danger-soft); }
.modal-msg.ok  { color: var(--success); background: var(--success-soft); }

/* ============ LOADING ============ */
.loading-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px 16px;
  color: var(--ink-soft);
  font-size: 14px;
}
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--green-soft);
  border-top-color: var(--green-mid);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ EMPTY STATE ============ */
.empty-state {
  text-align: center;
  padding: 40px 20px;
}
.empty-state svg {
  width: 64px;
  height: 64px;
  color: var(--muted);
  opacity: 0.5;
  margin-bottom: 16px;
}
.empty-state h3 {
  font-family: 'Playfair Display', Georgia, serif;
  color: var(--ink);
  font-size: 18px;
  margin-bottom: 8px;
}
.empty-state p {
  font-size: 13px;
  color: var(--ink-soft);
  max-width: 340px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ============ FOOTER ============ */
.footer {
  text-align: center;
  padding: 24px 8px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.3px;
}
.footer svg {
  display: inline-block;
  vertical-align: middle;
  width: 12px;
  height: 12px;
  margin: 0 4px;
  opacity: 0.6;
}

/* ============ INPUT WITH BUTTON ============ */
.input-with-btn {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.input-with-btn > div { flex: 1; min-width: 0; }
.input-with-btn .btn { padding: 11px 14px; flex-shrink: 0; }

/* ============ TOMSELECT OVERRIDE ============ */
.ts-wrapper .ts-control {
  padding: 10px 14px !important;
  border: 1.5px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  min-height: 44px;
  background: #fbfcfb !important;
  font-size: 14px;
  font-family: inherit;
}
.ts-wrapper.focus .ts-control {
  border-color: var(--green-mid) !important;
  background: #fff !important;
  box-shadow: 0 0 0 3px rgba(21, 115, 71, 0.1) !important;
}
.ts-wrapper.single .ts-control::after {
  border-color: var(--green-deep) transparent transparent transparent !important;
}
.ts-dropdown {
  border: 1.5px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow-md) !important;
  margin-top: 4px !important;
  font-family: inherit;
  font-size: 14px;
}
.ts-dropdown .optgroup-header {
  background: #f4f6f4 !important;
  color: var(--green-deep) !important;
  font-weight: 700 !important;
  font-size: 11px !important;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 12px !important;
  border-top: 1px solid var(--border);
}
.ts-dropdown .option {
  padding: 10px 12px !important;
  border-bottom: 1px solid #f4f6f4;
}
.ts-dropdown .option:hover,
.ts-dropdown .option.active {
  background: var(--green-soft) !important;
  color: var(--green-deep) !important;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 480px) {
  .page { padding: 20px 12px 40px; }
  .card { padding: 20px 16px; border-radius: 12px; }
  .hero h1 { font-size: 22px; }
  .hero-mark { width: 60px; height: 60px; }
  .hero-mark svg { width: 30px; height: 30px; }
  .btn-group .btn { min-width: 100%; }
  .acara-bar { flex-direction: column; gap: 6px; }
  #signatureCanvas { height: 140px; }
}
/* Pastikan dropdown TomSelect selalu di posisi paling atas */
.ts-dropdown {
  z-index: 9999 !important;
}

/* Pastikan container yang sedang aktif mencari berada di atas kartu lain */
.card:focus-within {
  z-index: 10;
  position: relative;
}