/* ════════════════════════════════════════════════════════════════════
   WanderKids — Shared Profile Photo Component
   /wk-assets/wk-profil-photo.css
   v1.0 — 2026-04-29

   Modal "Ganti Foto Profil" — dipakai panel Ortu, Guru, Admin.
   Mobile-first centered popup, max-width 480px.
   ════════════════════════════════════════════════════════════════════ */

.wkpp-ov {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .65);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  z-index: 9300;
  display: none;
  align-items: center; justify-content: center;
  padding: 12px;
  padding-top: max(12px, env(safe-area-inset-top, 0px));
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  font-family: 'Plus Jakarta Sans', 'Nunito', -apple-system, sans-serif;
}
.wkpp-ov.on { display: flex; animation: wkpp-fade .18s ease; }
@keyframes wkpp-fade { from {opacity:0} to {opacity:1} }

.wkpp-modal {
  background: #fff;
  width: 100%; max-width: 480px;
  max-height: 85vh;
  max-height: min(85dvh, 720px);
  max-height: min(85svh, 720px);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .28),
              0 4px 12px rgba(15, 23, 42, .12);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: wkpp-pop .22s cubic-bezier(.16,1,.3,1);
  color: #0F172A;
}
@keyframes wkpp-pop {
  from { transform: scale(.96); opacity: 0 }
  to   { transform: scale(1);   opacity: 1 }
}

/* HEADER */
.wkpp-hd {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid #E2E8F0;
  flex-shrink: 0;
}
.wkpp-hd-title {
  flex: 1;
  font-size: 15px; font-weight: 800;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wkpp-close {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: transparent; border: none;
  display: flex; align-items: center; justify-content: center;
  color: #64748B; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .12s, color .12s, transform .08s;
}
.wkpp-close:hover { background: #F1F5F9; color: #0F172A }
.wkpp-close:active { transform: scale(.92) }
.wkpp-close svg { width: 20px; height: 20px; stroke-width: 2.4 }

/* BODY */
.wkpp-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 18px;
}

/* FOOTER */
.wkpp-ft {
  flex-shrink: 0;
  padding: 12px 16px;
  border-top: 1px solid #E2E8F0;
  display: flex; gap: 10px; justify-content: flex-end;
  background: #FAFAFB;
}

/* ─── STAGE 1: PREVIEW (foto saat ini + 3 tombol) ─── */
.wkpp-stage-preview { text-align: center; }
.wkpp-avatar {
  width: 140px; height: 140px;
  border-radius: 50%;
  margin: 6px auto 22px;
  background: linear-gradient(135deg, #6EE7B7, #0E8F78);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 56px; font-weight: 800;
  box-shadow: 0 8px 24px rgba(15,23,42,.18);
  border: 4px solid #fff;
  position: relative;
  overflow: hidden;
}
.wkpp-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.wkpp-actions {
  display: flex; flex-direction: column; gap: 10px;
  max-width: 280px; margin: 0 auto;
}
.wkpp-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 13px 16px;
  border-radius: 12px;
  border: 1.5px solid #E2E8F0;
  background: #fff;
  color: #0F172A;
  font-family: inherit; font-size: 14.5px; font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .12s, border-color .12s, transform .08s;
}
.wkpp-btn:hover { background: #F8FAFC; border-color: #CBD5E1 }
.wkpp-btn:active { transform: scale(.98) }
.wkpp-btn svg { width: 20px; height: 20px; stroke-width: 2.2 }
.wkpp-btn.primary {
  background: #0E8F78; color: #fff; border-color: #0E8F78;
}
.wkpp-btn.primary:hover { background: #0a7d68; border-color: #0a7d68 }
.wkpp-btn.danger {
  color: #B91C1C; border-color: #FECACA; background: #FEF2F2;
}
.wkpp-btn.danger:hover { background: #FEE2E2; border-color: #FCA5A5 }
.wkpp-btn.gray {
  color: #64748B; background: #F1F5F9; border-color: #E2E8F0;
}
.wkpp-btn.gray:hover { background: #E2E8F0 }
.wkpp-btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ─── STAGE 2: CROP UI ─── */
.wkpp-stage-crop { display: flex; flex-direction: column; gap: 14px; }
.wkpp-crop-hint {
  font-size: 12.5px; color: #64748B; text-align: center;
  margin: -4px 0 0;
  line-height: 1.5;
}
.wkpp-crop-frame {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 360px;
  margin: 0 auto;
  background: #0F172A;
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.wkpp-crop-frame.dragging { cursor: grabbing; }
.wkpp-crop-img {
  position: absolute;
  top: 50%; left: 50%;
  transform-origin: 0 0;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  display: block;
}
/* Square viewport indicator (subtle inner shadow ring) */
.wkpp-crop-frame::after {
  content: '';
  position: absolute; inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.5);
  pointer-events: none;
}
.wkpp-zoom-row {
  display: flex; align-items: center; gap: 10px;
  padding: 0 8px;
}
.wkpp-zoom-row svg {
  width: 18px; height: 18px; color: #64748B; flex-shrink: 0;
  stroke-width: 2.2;
}
.wkpp-zoom-slider {
  flex: 1;
  -webkit-appearance: none; appearance: none;
  height: 4px;
  background: #E2E8F0;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.wkpp-zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #0E8F78;
  cursor: pointer;
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.wkpp-zoom-slider::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #0E8F78;
  cursor: pointer;
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}

/* ─── STAGE 3 / 4 / 5: LOADING / SUCCESS / ERROR ─── */
.wkpp-feedback {
  text-align: center;
  padding: 32px 8px 16px;
}
.wkpp-feedback-ico {
  width: 72px; height: 72px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
}
.wkpp-feedback-ico.loading { background: #F1F5F9; }
.wkpp-feedback-ico.success { background: #D1FAE5; color: #065F46; }
.wkpp-feedback-ico.error   { background: #FEE2E2; color: #991B1B; }
.wkpp-feedback-ico svg { width: 38px; height: 38px; stroke-width: 2.4; }
.wkpp-feedback-t {
  font-size: 16px; font-weight: 800; color: #0F172A;
  margin-bottom: 6px;
}
.wkpp-feedback-s {
  font-size: 13px; color: #64748B;
  line-height: 1.55;
  max-width: 320px; margin: 0 auto;
}

/* Spinner */
.wkpp-spinner {
  width: 38px; height: 38px;
  border: 3.5px solid #E2E8F0;
  border-top-color: #0E8F78;
  border-radius: 50%;
  animation: wkpp-spin 0.7s linear infinite;
}
@keyframes wkpp-spin { to { transform: rotate(360deg) } }

/* Hidden file input */
.wkpp-file-hidden {
  position: absolute; left: -9999px; opacity: 0;
  width: 0; height: 0;
}

/* ─── Avatar trigger button (di topbar/sidebar host) ─── */
.wkpp-trigger {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.85);
  background: linear-gradient(135deg, #6EE7B7, #0E8F78);
  color: #fff;
  font-size: 14px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
  font-family: inherit;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  transition: transform .08s, border-color .15s;
  position: relative;
}
.wkpp-trigger:hover { border-color: #fff; }
.wkpp-trigger:active { transform: scale(.93) }
.wkpp-trigger img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.wkpp-trigger::after {
  content: '';
  position: absolute;
  bottom: -1px; right: -1px;
  width: 12px; height: 12px;
  background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230E8F78' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><path d='M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7'/><path d='M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z'/></svg>") center/8px no-repeat;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  pointer-events: none;
}

/* ─── Mobile fine-tune ─── */
@media (max-width: 480px) {
  .wkpp-modal { border-radius: 18px; max-width: 100%; }
  .wkpp-hd { padding: 12px 14px }
  .wkpp-hd-title { font-size: 14.5px }
  .wkpp-body { padding: 16px }
  .wkpp-ft { padding: 10px 14px }
  .wkpp-avatar {
    width: 120px; height: 120px;
    font-size: 48px;
    margin-bottom: 18px;
  }
  .wkpp-btn { padding: 12px 14px; font-size: 14px }
  .wkpp-crop-frame { max-width: 100%; }
}

/* ─── prefers-reduced-motion ─── */
@media (prefers-reduced-motion: reduce) {
  .wkpp-ov.on, .wkpp-modal { animation: none }
  .wkpp-spinner { animation: wkpp-spin 1.4s linear infinite }
}
