/* =========================================================
   GCal Event Generator — tampilan v2 (mobile-first)
   Ide visual: kalender sobek (tear-off) sebagai pratinjau event
   ========================================================= */

:root {
  --ink: #12263A;
  --ink-soft: #4A5D70;
  --harbor: #123B5C;      /* biru utama */
  --harbor-2: #1C5A8A;
  --tear: #D92D20;        /* merah kalender, hanya di kartu tanggal */
  --paper: #FFFFFF;
  --mist: #EDF1F5;        /* latar */
  --line: #D5DDE5;
  --field: #F6F8FA;
  --ok: #127A55;
  --bad: #B42318;
  --radius-s: 8px;
  --radius-m: 12px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--mist);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--harbor-2); }
:focus-visible { outline: 3px solid #7FB2E5; outline-offset: 2px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--harbor);
  color: #fff;
}
.topbar__brand { font-weight: 700; font-size: 15px; letter-spacing: .01em; }

.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; overflow: hidden;
  background: #2A6A9C; color: #fff; font-weight: 700;
  border: 2px solid rgba(255,255,255,.5);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.menu__panel {
  position: absolute; right: 0; top: 46px; width: min(280px, calc(100vw - 32px));
  background: var(--paper); color: var(--ink);
  border-radius: var(--radius-m);
  box-shadow: 0 12px 32px rgba(18, 38, 58, .22);
  padding: 6px; display: flex; flex-direction: column;
}
.menu__who { padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu__who strong { display: block; font-size: 15px; }
.menu__who span { font-size: 13px; color: var(--ink-soft); word-break: break-all; }
.menu__panel a { padding: 11px 12px; border-radius: var(--radius-s); text-decoration: none; color: var(--ink); font-size: 15px; }
.menu__panel a:hover { background: var(--mist); }
.menu__panel .menu__danger { color: var(--bad); }

/* ---------- Hero / pratinjau ---------- */
.hero {
  background: var(--harbor);
  color: #fff;
  padding: 4px 16px 56px;
}
.hero__hello { margin: 0 0 12px; font-size: 14px; color: #B9D3EA; }
.hero__row { display: flex; gap: 16px; align-items: flex-start; }

.tile {
  flex: 0 0 auto;
  width: 92px;
  background: var(--paper);
  color: var(--ink);
  border-radius: 10px;
  overflow: hidden;
  text-align: center;
  box-shadow: 0 6px 0 -2px #0D2B44, 0 10px 22px rgba(0,0,0,.25);
  display: flex; flex-direction: column;
}
.tile__month {
  background: var(--tear); color: #fff;
  font-size: 12px; font-weight: 700; padding: 5px 4px 4px;
  position: relative;
}
/* lubang ring kalender */
.tile__month::before, .tile__month::after {
  content: ""; position: absolute; top: -3px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--harbor);
}
.tile__month::before { left: 18px; }
.tile__month::after { right: 18px; }
.tile__day { font-size: 44px; font-weight: 800; line-height: 1; padding: 8px 0 2px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.tile__week { font-size: 12px; font-weight: 600; color: var(--ink-soft); padding-bottom: 8px; }
.tile.flip { animation: flip .35s ease; }
@keyframes flip {
  0% { transform: perspective(400px) rotateX(0); }
  45% { transform: perspective(400px) rotateX(-70deg); }
  100% { transform: perspective(400px) rotateX(0); }
}

.preview { min-width: 0; flex: 1; padding-top: 2px; }
.preview__title {
  margin: 0 0 6px; font-size: 20px; font-weight: 700; line-height: 1.25;
  overflow-wrap: anywhere;
}
.preview__title.is-empty { color: #8FB1CF; font-weight: 600; }
.preview__line { margin: 0 0 2px; font-size: 14px; color: #D6E6F4; }

/* ---------- Lembar form ---------- */
.sheet {
  position: relative;
  margin: -40px 12px 0;
  background: var(--paper);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(18,38,58,.06), 0 8px 24px rgba(18,38,58,.08);
}
.group { padding: 20px 16px; border-bottom: 1px solid var(--line); }
.group h2 { margin: 0 0 12px; font-size: 17px; font-weight: 700; }
.group__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.group__head h2 { margin: 0; }
.opt { font-size: 13px; font-weight: 500; color: var(--ink-soft); }

.field { margin-top: 14px; }
.field:first-of-type { margin-top: 0; }
.group > h2 + .field { margin-top: 0; }
label, .label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--ink); }

input[type=text], input[type=number], input[type=date], input[type=time], textarea {
  width: 100%;
  font: inherit; font-size: 16px; /* 16px: cegah auto-zoom iOS */
  color: var(--ink);
  background: var(--field);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-s);
  padding: 11px 12px;
  min-height: 46px;
  -webkit-appearance: none; appearance: none;
  transition: border-color .15s, background .15s;
}
input:focus, textarea:focus { outline: none; border-color: var(--harbor-2); background: #fff; }
input:disabled { opacity: .45; }
input.invalid { border-color: var(--bad); background: #FEF3F2; }
textarea { resize: vertical; min-height: 84px; }
input[type=date], input[type=time] { font-variant-numeric: tabular-nums; }
.hint { margin: 8px 0 0; font-size: 13px; color: var(--ink-soft); }

/* Kapan: grid tanggal + jam */
.when {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 6px 8px;
  align-items: center;
}
.when__label { grid-column: 1 / -1; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-top: 4px; }
.when.allday { grid-template-columns: 1fr; }
.when.allday .time { display: none; }

/* Switch */
.switch {
  display: inline-flex; align-items: center; gap: 10px;
  margin: 0; cursor: pointer; font-size: 15px; font-weight: 600; user-select: none;
}
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track {
  width: 44px; height: 26px; border-radius: 13px; background: #C3CED9;
  position: relative; transition: background .2s; flex: 0 0 auto;
}
.switch__track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s;
}
.switch input:checked + .switch__track { background: var(--harbor-2); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { outline: 3px solid #7FB2E5; outline-offset: 2px; }
.switch--row { display: flex; margin-top: 16px; font-weight: 500; }

/* Segmented control */
.seg { display: flex; background: var(--field); border: 1.5px solid var(--line); border-radius: var(--radius-s); padding: 3px; gap: 2px; }
.seg label { flex: 1; margin: 0; }
.seg input, .days input, .chips input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span {
  display: grid; place-items: center; min-height: 38px; padding: 0 6px;
  border-radius: 6px; font-size: 14px; font-weight: 600; color: var(--ink-soft); cursor: pointer; text-align: center;
}
.seg input:checked + span { background: var(--paper); color: var(--harbor); box-shadow: 0 1px 3px rgba(18,38,58,.18); }
.seg input:focus-visible + span { outline: 3px solid #7FB2E5; }

.every { display: grid; grid-template-columns: 64px 1fr; gap: 8px; align-items: stretch; }
.every input { text-align: center; }

/* Hari */
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.days label { margin: 0; }
.days span {
  display: grid; place-items: center; aspect-ratio: 1; max-height: 48px; width: 100%;
  border-radius: 50%; border: 1.5px solid var(--line); background: var(--field);
  font-size: 13px; font-weight: 700; color: var(--ink-soft); cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.days input:checked + span { background: var(--harbor); border-color: var(--harbor); color: #fff; }
.days input:focus-visible + span { outline: 3px solid #7FB2E5; }

/* Chips pengingat */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { margin: 0; }
.chips span {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px;
  border-radius: 20px; border: 1.5px solid var(--line); background: var(--field);
  font-size: 14px; font-weight: 600; color: var(--ink-soft); cursor: pointer;
}
.chips input:checked + span { background: #E3EEF8; border-color: var(--harbor-2); color: var(--harbor); }
.chips input:focus-visible + span { outline: 3px solid #7FB2E5; }

.suffix { display: flex; align-items: center; gap: 10px; }
.suffix input { max-width: 140px; }
.suffix span { color: var(--ink-soft); font-size: 15px; }

/* Saran email tamu (dropdown) */
.ac { position: relative; }
.ac__list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30;
  margin: 0; padding: 4px; list-style: none;
  background: var(--paper); border: 1.5px solid var(--line); border-radius: var(--radius-m);
  box-shadow: 0 12px 28px rgba(18, 38, 58, .16);
  max-height: 300px; overflow-y: auto;
}
.ac__list li {
  display: flex; align-items: center; gap: 8px;
  min-height: 46px; padding: 0 4px 0 12px; border-radius: var(--radius-s);
  cursor: pointer; font-size: 15px;
}
.ac__list li.is-active, .ac__list li:hover { background: #E3EEF8; }
.ac__email { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac__email b { color: var(--harbor); font-weight: 700; }
.ac__meta { font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.ac__del {
  width: 36px; height: 36px; flex: 0 0 auto; border: 0; border-radius: 50%;
  background: transparent; color: var(--ink-soft); font-size: 20px; line-height: 1; cursor: pointer;
}
.ac__del:hover { background: #FEE4E2; color: var(--bad); }

/* Email tamu */
.emails { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.emails:empty { display: none; }
.emails span {
  font-size: 13px; padding: 3px 10px; border-radius: 12px;
  background: #E3EEF8; color: var(--harbor); font-weight: 600; word-break: break-all;
}
.emails span.bad { background: #FEE4E2; color: var(--bad); text-decoration: line-through; }

.reveal:not([hidden]) { animation: open .2s ease; }
@keyframes open { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* Tombol simpan — menempel di bawah layar HP */
.actionbar {
  position: sticky; bottom: 0; z-index: 10;
  padding: 12px 16px calc(12px + var(--safe-b));
  background: rgba(255,255,255,.94);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  border-radius: 0 0 16px 16px;
}
.btn-primary {
  width: 100%; min-height: 52px; border: 0; border-radius: var(--radius-m);
  background: var(--harbor); color: #fff; font: inherit; font-size: 16px; font-weight: 700;
  cursor: pointer; transition: background .15s, transform .05s;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
}
.btn-primary:hover { background: var(--harbor-2); }
.btn-primary:active { transform: scale(.99); }
.btn-primary:disabled { background: #6E8BA5; cursor: progress; }
.spinner { width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Terakhir dibuat */
.recent { padding: 20px 16px 8px; }
.recent h2 { margin: 0 0 8px; font-size: 17px; }
.recent ul { list-style: none; margin: 0; padding: 0; }
.recent li { border-top: 1px solid var(--line); }
.recent li:first-child { border-top: 0; }
.recent a, .recent li > span { display: flex; flex-direction: column; padding: 12px 0; text-decoration: none; color: var(--ink); }
.recent__title { font-weight: 600; overflow-wrap: anywhere; }
.recent__when { font-size: 13px; color: var(--ink-soft); }

.foot { text-align: center; font-size: 12px; color: var(--ink-soft); padding: 20px 16px calc(28px + var(--safe-b)); }

/* Toast hasil */
.toast {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  padding: 12px 12px calc(12px + var(--safe-b));
  display: flex; justify-content: center;
}
.toast__body {
  width: 100%; max-width: 480px;
  background: var(--ink); color: #fff;
  border-radius: 14px; padding: 16px;
  box-shadow: 0 16px 40px rgba(0,0,0,.3);
  animation: up .25s ease;
  border-left: 6px solid var(--ok);
}
.toast.is-error .toast__body { border-left-color: #F97066; }
.toast__msg { margin: 0; font-weight: 700; overflow-wrap: anywhere; max-height: 50vh; overflow-y: auto; }
.toast__sub { margin: 4px 0 0; font-size: 14px; color: #C9D6E2; overflow-wrap: anywhere; }
.toast__actions { display: flex; gap: 8px; margin-top: 12px; }
.btn-ghost {
  flex: 1; min-height: 42px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px; border: 1.5px solid rgba(255,255,255,.3); background: transparent;
  color: #fff; font: inherit; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn-ghost:hover { background: rgba(255,255,255,.08); }
@keyframes up { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Halaman login ---------- */
.page-login { background: var(--harbor); color: #fff; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.login { flex: 1; width: 100%; max-width: 420px; margin: 0 auto; padding: 56px 24px 24px; display: flex; flex-direction: column; align-items: flex-start; }
.tile--big { width: 120px; margin-bottom: 28px; }
.tile--big .tile__day { font-size: 60px; }
.tile--big .tile__month::before { left: 26px; }
.tile--big .tile__month::after { right: 26px; }
.login__title { font-size: 30px; line-height: 1.15; margin: 0 0 12px; font-weight: 800; letter-spacing: -.01em; }
.login__lead { margin: 0 0 28px; color: #C9DCEE; font-size: 16px; }
.login__note { margin: 14px 0 0; font-size: 13px; color: #9FBDD8; }
.btn-google {
  display: inline-flex; align-items: center; justify-content: center; gap: 12px; width: 100%;
  min-height: 52px; border-radius: var(--radius-m); background: #fff; color: var(--ink);
  font-weight: 700; text-decoration: none; font-size: 16px;
}
.btn-google:hover { background: #F1F5F9; }
.alert { width: 100%; padding: 12px 14px; border-radius: var(--radius-s); margin-bottom: 16px; font-size: 14px; }
.alert--error { background: #FEE4E2; color: var(--bad); }
.page-login .foot { color: #8FB1CF; }

/* ---------- Layar lebar ---------- */
@media (min-width: 900px) {
  .topbar { padding: 12px 32px; }
  .layout {
    max-width: 1080px; margin: 0 auto; padding: 32px 32px 0;
    display: grid; grid-template-columns: 340px 1fr; gap: 32px; align-items: start;
  }
  .hero {
    position: sticky; top: 92px;
    border-radius: 16px; padding: 24px;
  }
  .hero__row { flex-direction: column; }
  .tile { width: 132px; }
  .tile__day { font-size: 64px; }
  .tile__month::before { left: 28px; } .tile__month::after { right: 28px; }
  .preview__title { font-size: 24px; }
  .sheet { margin: 0; }
  .group { padding: 24px 28px; }
  .when { grid-template-columns: 64px 1fr 150px; gap: 10px 10px; }
  .when__label { grid-column: auto; margin: 0; font-size: 14px; }
  .when.allday { grid-template-columns: 64px 1fr; }
  .actionbar { position: static; background: transparent; border-top: 0; padding: 20px 28px 24px; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .btn-primary { width: auto; padding: 0 28px; }
  .recent { padding: 8px 28px 16px; border-top: 1px solid var(--line); }
  .toast { justify-content: flex-end; padding: 24px; }
}

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