/* =========================================================
   Buku Tamu — style.css
   ========================================================= */

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

:root {
  --bg-top: #eef1fc;
  --bg-bottom: #f8f9fe;
  --card: #ffffff;
  --field: #fbfbfe;
  --ink: #141726;
  --ink-soft: #39415a;
  --muted: #6b7385;
  --line: #e4e7f2;
  --accent: #4f46e5;
  --accent-2: #8b5cf6;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(20, 23, 38, .05), 0 20px 44px -26px rgba(20, 23, 38, .45);
  --sukses-bg: #e9f8ef;
  --sukses-ink: #0b6b3a;
  --sukses-line: #bfe8d0;
  --galat-bg: #fdeceb;
  --galat-ink: #a01a13;
  --galat-line: #f7c9c6;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--bg-bottom);
  background-image:
    radial-gradient(780px 420px at 6% -10%, rgba(139, 92, 246, .22), transparent 62%),
    radial-gradient(720px 400px at 98% 0%, rgba(56, 189, 248, .20), transparent 60%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 48px 20px 56px;
}

/* ---------- Hero ---------- */

.hero {
  max-width: 640px;
  margin: 0 auto 34px;
  text-align: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 15px;
  border-radius: 999px;
  background: rgba(79, 70, 229, .10);
  border: 1px solid rgba(79, 70, 229, .18);
  color: var(--accent);
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.badge svg { width: 15px; height: 15px; }

.hero h1 {
  margin: 18px 0 10px;
  font-size: clamp(1.85rem, 4.4vw, 2.7rem);
  line-height: 1.15;
  letter-spacing: -.025em;
  font-weight: 800;
  background: linear-gradient(135deg, #1b1f33 20%, #4f46e5 90%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.hero p {
  max-width: 54ch;
  margin: 0 auto;
  color: var(--muted);
  font-size: 1rem;
}

/* ---------- Tata letak ---------- */

.utama {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
  align-items: start;
}

@media (min-width: 900px) {
  .utama { grid-template-columns: 396px minmax(0, 1fr); gap: 28px; }
  .form-card { position: sticky; top: 28px; }
}

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

/* ---------- Form ---------- */

.form-card { padding: 24px; }

.form-card h2 {
  margin: 0 0 18px;
  font-size: 1.1rem;
  letter-spacing: -.01em;
}

.bidang { margin-bottom: 16px; }

.bidang label {
  display: block;
  margin-bottom: 7px;
  font-size: .84rem;
  font-weight: 700;
  letter-spacing: .01em;
}

input[type="text"],
textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

textarea {
  min-height: 128px;
  resize: vertical;
  line-height: 1.55;
}

input[type="text"]::placeholder,
textarea::placeholder { color: #9aa2b5; }

input[type="text"]:focus,
textarea:focus {
  outline: none;
  background: var(--card);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, .15);
}

.hitung {
  margin-top: 6px;
  text-align: right;
  font-size: .74rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.hitung.penuh { color: #d92d20; }

.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  margin-top: 2px;
  padding: 13px 18px;
  font: inherit;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 14px 26px -14px rgba(79, 70, 229, .95);
  transition: filter .18s ease, transform .12s ease, box-shadow .18s ease;
}

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

.btn:hover {
  filter: brightness(1.07);
  box-shadow: 0 16px 30px -14px rgba(79, 70, 229, 1);
}

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

.btn:focus-visible {
  outline: 3px solid rgba(79, 70, 229, .45);
  outline-offset: 3px;
}

.catatan {
  margin: 14px 0 0;
  font-size: .76rem;
  color: var(--muted);
  text-align: center;
}

.catatan code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .95em;
  background: rgba(79, 70, 229, .09);
  padding: 1px 5px;
  border-radius: 5px;
}

/* ---------- Notifikasi ---------- */

.flash {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  margin-bottom: 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: .88rem;
  line-height: 1.45;
}

.flash svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

.flash.sukses { background: var(--sukses-bg); border-color: var(--sukses-line); color: var(--sukses-ink); }
.flash.galat  { background: var(--galat-bg);  border-color: var(--galat-line);  color: var(--galat-ink); }

/* ---------- Daftar pesan ---------- */

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 4px 14px;
}

.list-head h2 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -.01em;
}

.pill {
  padding: 4px 11px;
  border-radius: 999px;
  background: rgba(79, 70, 229, .10);
  color: var(--accent);
  font-size: .76rem;
  font-weight: 700;
  white-space: nowrap;
}

.daftar { overflow: hidden; }

.pesan {
  display: flex;
  gap: 14px;
  padding: 18px 20px;
}

.pesan + .pesan { border-top: 1px solid var(--line); }

.avatar {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: .95rem;
  font-weight: 800;
  letter-spacing: .02em;
  color: #fff;
  background: linear-gradient(135deg, hsl(var(--hue, 250) 76% 60%), hsl(calc(var(--hue, 250) + 34) 72% 46%));
  box-shadow: 0 8px 18px -10px rgba(20, 23, 38, .7);
  user-select: none;
}

.badan { flex: 1 1 auto; min-width: 0; }

.baris {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 12px;
}

.nama {
  font-size: .96rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.waktu {
  font-size: .76rem;
  color: var(--muted);
  white-space: nowrap;
}

.teks {
  margin: 5px 0 0;
  font-size: .94rem;
  color: var(--ink-soft);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---------- Kosong & catatan kaki ---------- */

.kosong {
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
}

.kosong svg {
  width: 46px;
  height: 46px;
  margin-bottom: 10px;
  color: rgba(79, 70, 229, .45);
}

.kosong strong {
  display: block;
  margin-bottom: 4px;
  font-size: 1rem;
  color: var(--ink);
}

.kosong p { margin: 0; font-size: .9rem; }

.kaki {
  margin: 14px 4px 0;
  font-size: .78rem;
  color: var(--muted);
}

/* ---------- Mode gelap ---------- */

@media (prefers-color-scheme: dark) {
  :root {
    --bg-top: #0d1020;
    --bg-bottom: #080a13;
    --card: #12162a;
    --field: #0e1222;
    --ink: #eef1fa;
    --ink-soft: #c3c9dd;
    --muted: #8f98b2;
    --line: #232a44;
    --sukses-bg: #0f2a1e;
    --sukses-ink: #7ce0ab;
    --sukses-line: #1c4633;
    --galat-bg: #2c1414;
    --galat-ink: #ff9d95;
    --galat-line: #4a2220;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 22px 48px -28px rgba(0, 0, 0, .95);
  }

  body {
    background-image:
      radial-gradient(780px 420px at 6% -10%, rgba(99, 102, 241, .30), transparent 62%),
      radial-gradient(720px 400px at 98% 0%, rgba(14, 165, 233, .22), transparent 60%),
      linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  }

  .hero h1 {
    background: linear-gradient(135deg, #ffffff 25%, #a5b4fc 95%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
  }

  .badge,
  .pill {
    background: rgba(129, 140, 248, .14);
    border-color: rgba(129, 140, 248, .26);
    color: #b6bdfa;
  }

  input[type="text"]::placeholder,
  textarea::placeholder { color: #667091; }

  .catatan code { background: rgba(129, 140, 248, .16); }

  .avatar { box-shadow: 0 8px 18px -10px rgba(0, 0, 0, .9); }
}

/* ---------- Preferensi aksesibilitas ---------- */

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}