/* =========================================================
   HaloBestie Community — semua style
   Mobile-first. Warm, soft, aman.
   ========================================================= */

:root {
  --bg: #FFF8F0;
  --card: #FFFFFF;
  --text: #2D2D2D;
  --muted: #7A7068;
  --line: #F0E6DC;
  --primary: #FF8FA3;
  --primary-dark: #F0748B;
  --primary-soft: #FFE6EB;
  --bestie: #7C6FE0;
  --bestie-soft: #EFEDFF;
  --wa: #25D366;
  --danger: #E5484D;
  --danger-soft: #FFECEC;
  --ok: #2E9E6A;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  --radius-card: 16px;
  --radius-btn: 12px;
  --radius-form: 24px;
  --skeleton: #F3EAE1;

  /* Warna pastel per kategori */
  --cat-patah_hati: #FFE0E6;
  --cat-overthinking: #FFF1CC;
  --cat-keluarga: #FFE3D1;
  --cat-burnout: #DDF3E4;
  --cat-kesepian: #DCEBFF;
  --cat-lainnya: #EDE7F6;
  --cat-text: #5A4A42;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1A1A2E;
    --card: #252540;
    --text: #E8E8E8;
    --muted: #A5A5C0;
    --line: #34345A;
    --primary-soft: #3A2B45;
    --bestie-soft: #2F2C55;
    --danger-soft: #3D2230;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --skeleton: #2E2E4D;

    --cat-patah_hati: #4A2B3A;
    --cat-overthinking: #4A4127;
    --cat-keluarga: #4A3326;
    --cat-burnout: #26433A;
    --cat-kesepian: #26364F;
    --cat-lainnya: #3A3150;
    --cat-text: #F0E6F0;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

img { max-width: 100%; }

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 16px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 20px;
  border: 0;
  border-radius: var(--radius-btn);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-soft { background: var(--primary-soft); color: var(--text); }
.btn-outline { background: transparent; color: var(--text); border: 1.5px solid var(--line); }
.btn-bestie { background: var(--bestie); color: #fff; }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 6px 14px; font-size: 14px; }

/* ---------- Header / Hero ---------- */
.site-header {
  padding: 28px 0 8px;
  text-align: center;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
  text-decoration: none;
}
.logo span { color: var(--primary); }
.tagline {
  margin: 6px 0 20px;
  color: var(--muted);
  font-size: 15px;
}
.hero-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.hero-note {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.compact-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
}
.compact-header .logo { font-size: 20px; }

/* ---------- Feed ---------- */
.feed-title {
  margin: 28px 0 12px;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.feed { display: flex; flex-direction: column; gap: 14px; }

.card {
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 18px;
}

.fade-in { animation: fadeIn 0.3s ease both; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .fade-in { animation: none; }
  .skeleton-line { animation: none !important; }
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--cat-text);
  background: var(--cat-lainnya);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70%;
}
.badge.cat-patah_hati { background: var(--cat-patah_hati); }
.badge.cat-overthinking { background: var(--cat-overthinking); }
.badge.cat-keluarga { background: var(--cat-keluarga); }
.badge.cat-burnout { background: var(--cat-burnout); }
.badge.cat-kesepian { background: var(--cat-kesepian); }
.badge.cat-lainnya { background: var(--cat-lainnya); }
.badge.bestie-post-badge { background: var(--bestie-soft); color: var(--bestie); }
.badge.crisis { background: var(--danger-soft); color: var(--danger); }

.time { font-size: 13px; color: var(--muted); white-space: nowrap; }

.post-title {
  margin: 0 0 6px;
  font-size: 18px;
  line-height: 1.4;
}
.post-content {
  display: block;
  margin: 0;
  color: var(--text);
  text-decoration: none;
  white-space: pre-wrap;
  word-wrap: break-word;
}
a.post-content:hover { opacity: 0.85; }

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.react-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 4px 12px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.react-btn:active { transform: scale(0.94); }
.react-btn.reacted { background: var(--primary-soft); border-color: var(--primary); }
.react-btn.pop { animation: pop 0.3s ease; }
@keyframes pop { 50% { transform: scale(1.15); } }
.share-btn {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  padding: 6px 4px;
}

/* Respons Bestie */
.response {
  margin-top: 14px;
  padding: 14px;
  border-radius: 14px;
  background: var(--bestie-soft);
  border-left: 3px solid var(--bestie);
}
.bestie-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.avatar {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--bestie);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
}
.avatar { position: relative; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.bestie-name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.bestie-label {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--bestie);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  vertical-align: middle;
}
.bestie-bio { font-size: 12px; color: var(--muted); line-height: 1.3; }
.response p { margin: 0; white-space: pre-wrap; word-wrap: break-word; }

.wa-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: var(--radius-btn);
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  text-align: center;
  text-decoration: none;
}
.wa-cta:hover { background: var(--primary-dark); }
.wa-cta { flex-wrap: wrap; column-gap: 4px; }
.nowrap { white-space: nowrap; }

.waiting {
  margin-top: 12px;
  font-size: 14px;
  color: var(--muted);
}

.load-more-wrap { text-align: center; margin: 20px 0 8px; }
.empty-state, .error-state {
  text-align: center;
  color: var(--muted);
  padding: 32px 16px;
}

/* Skeleton */
.skeleton .skeleton-line {
  height: 14px;
  border-radius: 8px;
  background: var(--skeleton);
  margin-bottom: 10px;
  animation: shimmer 1.2s ease-in-out infinite;
}
.skeleton .skeleton-line.short { width: 40%; }
.skeleton .skeleton-line.mid { width: 75%; }
.skeleton .skeleton-block { height: 80px; border-radius: 14px; background: var(--skeleton); margin-top: 14px; animation: shimmer 1.2s ease-in-out infinite; }
@keyframes shimmer { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 40px;
  padding: 28px 0 48px;
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}
.site-footer p { margin: 0 0 10px; }
.app-links, .social-links {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.app-links a, .social-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-btn);
  border: 1.5px solid var(--line);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
.disclaimer { font-size: 12px; line-height: 1.5; max-width: 440px; margin: 16px auto 0 !important; }

/* ---------- Modal / Form Curhat ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: rgba(20, 16, 30, 0.45);
}
.modal.open { display: flex; }
.modal-panel {
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: var(--radius-form) var(--radius-form) 0 0;
  padding: 22px 18px 28px;
  animation: slideUp 0.25s ease;
}
@media (min-width: 600px) {
  .modal { align-items: center; }
  .modal-panel { border-radius: var(--radius-form); padding: 28px; }
}
@keyframes slideUp { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.modal-head h2 { margin: 0; font-size: 20px; }
.close-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
}

.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
textarea, select, input[type="text"], input[type="password"], input[type="url"], input[type="tel"] {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* cegah zoom otomatis di iPhone */
}
textarea { min-height: 150px; resize: vertical; line-height: 1.5; }
textarea:focus, select:focus, input:focus { outline: none; border-color: var(--primary); }
.counter { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 4px; }
.counter.over { color: var(--danger); }
.form-note { font-size: 13px; color: var(--muted); margin: 8px 0 14px; }
.form-error { color: var(--danger); font-size: 14px; margin: 8px 0; min-height: 0; }
#turnstile-box { margin: 6px 0 14px; min-height: 0; }

.result { text-align: center; padding: 8px 0; }
.result .big-emoji { font-size: 48px; line-height: 1; margin-bottom: 8px; }
.result h3 { margin: 0 0 8px; font-size: 20px; }
.result p { margin: 0 0 16px; }
.result .btn { margin-bottom: 10px; }
.crisis-box {
  text-align: left;
  background: var(--danger-soft);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 14px;
}
.crisis-box p { margin: 0 0 10px; }
.crisis-box p:last-child { margin: 0; }

/* Tombol melayang "Curhat" */
.fab {
  position: fixed;
  right: 16px;
  bottom: 20px;
  z-index: 40;
  box-shadow: 0 6px 20px rgba(255, 143, 163, 0.45);
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.fab.show { opacity: 1; pointer-events: auto; transform: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 88px;
  z-index: 60;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* ---------- Halaman per-entry ---------- */
.entry-ctas { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.entry-apps { text-align: center; font-size: 14px; color: var(--muted); margin: 14px 0 0; }
.entry-apps a { font-weight: 600; }
.back-link { font-size: 14px; text-decoration: none; }

/* ---------- Admin ---------- */
.admin-body .container { max-width: 760px; }
.tone-guide {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: 0 -16px;
  padding: 12px 16px;
  background: var(--bestie);
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: var(--shadow);
}
.tone-guide strong { font-size: 14px; }
.tone-guide ul { margin: 6px 0 6px; padding-left: 18px; }
.tone-guide .why { opacity: 0.9; font-style: italic; }
@media (max-width: 599px) {
  .tone-guide { position: static; }
}

.admin-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 0 8px; }
.admin-top h1 { margin: 0; font-size: 18px; line-height: 1.3; }
.admin-top > div { display: flex; gap: 6px; flex-shrink: 0; }

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 0 12px;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  padding: 8px 14px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.tab .count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 12px; }

.admin-card.crisis-card { border: 2px solid var(--danger); background: var(--danger-soft); }
.crisis-alert { color: var(--danger); font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.admin-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.respond-box { margin-top: 12px; }
.respond-box select { margin-bottom: 8px; }
.respond-box textarea { min-height: 96px; }
.reminder {
  font-size: 13px;
  background: var(--primary-soft);
  border-radius: 10px;
  padding: 8px 12px;
  margin: 8px 0;
}
.meta-line { font-size: 12px; color: var(--muted); margin-top: 8px; }
.subtabs { display: flex; gap: 6px; margin-bottom: 12px; }

.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 600px) { .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.stat { background: var(--card); border-radius: var(--radius-card); box-shadow: var(--shadow); padding: 14px; }
.stat .num { font-size: 26px; font-weight: 800; line-height: 1.2; }
.stat .lbl { font-size: 13px; color: var(--muted); }
.stats-section-title { margin: 20px 0 8px; font-size: 15px; }

.bestie-item { display: flex; align-items: center; gap: 12px; }
.bestie-item .info { flex: 1; min-width: 0; }
.bestie-item .info div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inactive { opacity: 0.55; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }

.login-card { max-width: 400px; margin: 24px auto; }
