/* =====================================================================
   Shortlink — styles (light/blue, dark-mode ready)
   ===================================================================== */

:root {
  --accent:        oklch(0.62 0.15 264);     /* cornflower / periwinkle (yakale) */
  --accent-2:      oklch(0.57 0.16 266);
  --accent-hover:  oklch(0.57 0.155 264);
  --on-accent:     oklch(0.99 0 0);
  --accent-quiet:  oklch(0.62 0.15 264 / 0.12);
  --focus:         oklch(0.62 0.15 264 / 0.5);

  --good:          oklch(0.60 0.12 158);
  --good-bg:       oklch(0.93 0.05 158);

  --danger:        oklch(0.60 0.19 25);
  --danger-quiet:  oklch(0.60 0.19 25 / 0.12);
  --ok:            oklch(0.70 0.15 155);

  --font-sans: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;

  --radius:    14px;
  --radius-sm: 10px;
  --pill:      999px;
  --maxw:      1080px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Light (default) */
:root,
[data-theme="light"] {
  --bg:        oklch(0.951 0.005 252);
  --surface:   oklch(1 0 0);
  --surface-2: oklch(0.972 0.004 252);
  --border:    oklch(0.9 0.006 252);
  --border-2:  oklch(0.845 0.008 252);
  --ink:       oklch(0.34 0.04 256);
  --muted:     oklch(0.53 0.022 256);
  --shadow-sm: 0 1px 2px oklch(0.4 0.05 258 / 0.05);
  --shadow:    0 1px 3px oklch(0.4 0.05 258 / 0.05), 0 10px 28px oklch(0.4 0.05 258 / 0.07);
  --shadow-xl: 0 6px 18px oklch(0.45 0.05 260 / 0.08), 0 26px 50px oklch(0.45 0.07 262 / 0.09);
}

/* Dark */
[data-theme="dark"] {
  --bg:        oklch(0.205 0.014 260);
  --surface:   oklch(0.255 0.018 260);
  --surface-2: oklch(0.295 0.020 260);
  --border:    oklch(0.345 0.018 260);
  --border-2:  oklch(0.41 0.020 260);
  --ink:       oklch(0.965 0.008 260);
  --muted:     oklch(0.74 0.016 260);
  --good-bg:   oklch(0.42 0.07 158 / 0.35);
  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.4);
  --shadow:    0 2px 6px oklch(0 0 0 / 0.35), 0 12px 32px oklch(0 0 0 / 0.35);
  --shadow-xl: 0 10px 30px oklch(0 0 0 / 0.45), 0 30px 70px oklch(0 0 0 / 0.4);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
button { font: inherit; }
code { font-family: var(--font-mono); font-size: 0.9em; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.ta-right { text-align: right; }
.inline { display: inline; }

/* ---------- Shell ---------- */
.shell {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding: 0 clamp(18px, 5vw, 40px);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.28rem;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.brand-mark { display: block; flex: none; border-radius: 8px; }

.topbar-actions { display: flex; align-items: center; gap: 9px; }

.content { flex: 1; display: flex; flex-direction: column; padding-bottom: 32px; }

.foot {
  padding: 26px 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 16px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-weight: 550;
  font-size: 0.92rem;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 160ms var(--ease), border-color 160ms var(--ease),
              transform 120ms var(--ease), box-shadow 160ms var(--ease), opacity 160ms var(--ease);
}
.btn:hover { border-color: var(--border-2); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--on-accent);
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hover); border-color: transparent; }

.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }

.btn-pill { border-radius: var(--pill); padding: 0 22px; }
.btn-sm { height: 36px; padding: 0 13px; font-size: 0.86rem; }
.btn-block { width: 100%; }

.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-quiet); border-color: var(--danger); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px; height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: background 160ms var(--ease), border-color 160ms var(--ease), color 160ms var(--ease);
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border-2); }
.icon-btn-sm { width: 30px; height: 30px; border-radius: 8px; }
.icon-btn-sm.copied { color: var(--on-accent); background: var(--accent); border-color: transparent; }

/* Theme icon swap */
.ic-sun { display: none; }
.ic-moon { display: block; }
[data-theme="dark"] .ic-sun { display: block; }
[data-theme="dark"] .ic-moon { display: none; }

/* ---------- Focus ---------- */
:where(a, button, input, [tabindex]):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------- Forms ---------- */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 7px; }
.label { font-size: 0.8rem; font-weight: 550; color: var(--muted); }

.input {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
.input::placeholder { color: var(--muted); opacity: 0.75; }
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-quiet);
}

/* slug input dengan prefix */
.slug-input {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  overflow: hidden;
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
.slug-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-quiet);
}
.slug-prefix {
  display: inline-flex;
  align-items: center;
  padding: 0 4px 0 13px;
  color: var(--muted);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  white-space: nowrap;
  max-width: 46%;
  overflow: hidden;
  text-overflow: ellipsis;
  border-right: 1px solid var(--border);
}
.slug-input .input {
  border: 0;
  background: transparent;
  box-shadow: none;
  font-family: var(--font-mono);
}
.slug-input .input:focus { box-shadow: none; }

/* =====================================================================
   Homepage publik
   ===================================================================== */
.home {
  flex: 1;
  display: grid;
  place-items: center;
  padding: clamp(20px, 6vh, 64px) 0;
}
.hero {
  width: 100%;
  max-width: 720px;
  text-align: center;
}

/* hasil shortlink */
.result {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: clamp(28px, 5vh, 44px);
  animation: rise 360ms var(--ease) both;
}
.copy-circle {
  flex: none;
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 0;
  background: var(--good-bg);
  color: var(--good);
  cursor: pointer;
  transition: transform 160ms var(--ease), filter 160ms var(--ease);
}
.copy-circle:hover { transform: scale(1.06); }
.copy-circle.copied { background: var(--accent); color: var(--on-accent); }
.result-url {
  font-size: clamp(1.5rem, 4.5vw, 2.15rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 2px solid var(--border-2);
  padding-bottom: 4px;
  word-break: break-all;
}
.result-url:hover { border-color: var(--accent); color: var(--accent); }

/* input pill besar */
.shorten { display: block; }
.url-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 36px;
  box-shadow: var(--shadow-xl);
  padding: 12px 22px 12px clamp(24px, 4vw, 34px);
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
.url-bar:focus-within {
  border-color: color-mix(in oklch, var(--accent) 45%, transparent);
  box-shadow: var(--shadow-xl), 0 0 0 4px var(--accent-quiet);
}
.url-input {
  flex: 1;
  min-width: 0;
  height: 60px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1.08rem;
}
.url-input:focus { outline: none; }
.url-input::placeholder { color: var(--muted); opacity: 0.75; }
.send {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 180ms var(--ease), transform 140ms var(--ease), background 180ms var(--ease);
}
.send:hover { color: var(--accent); background: var(--accent-quiet); }
.send:active { transform: scale(0.92); }

/* advanced options */
.adv-toggle {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  margin: 16px 0 0;
  padding-left: clamp(24px, 4vw, 34px);
  color: var(--muted);
  font-size: 0.92rem;
  cursor: pointer;
  user-select: none;
}
.adv-toggle input {
  width: 18px; height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}
.adv {
  max-width: 420px;
  margin: 18px auto 0;
  text-align: left;
  animation: rise 280ms var(--ease) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Auth ---------- */
.auth {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px 0;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px 28px;
  text-align: center;
}
.auth-card .brand-mark-lg { margin: 0 auto 16px; }
.auth-title { font-size: 1.32rem; font-weight: 680; letter-spacing: -0.02em; }
.auth-sub { color: var(--muted); margin: 4px 0 22px; font-size: 0.92rem; }
.auth-card .form { text-align: left; }
.auth-alt { margin-top: 18px; font-size: 0.9rem; color: var(--muted); }
.auth-alt a { color: var(--accent); font-weight: 550; text-decoration: none; }
.auth-alt a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Panel / add bar ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 22px;
}
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.h1 { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; }

.addbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto;
  gap: 14px;
  align-items: end;
}
.addbar-submit { height: 44px; }

/* ---------- Table ---------- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.table { width: 100%; border-collapse: collapse; }
.table thead th {
  text-align: left;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 13px 18px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.table tbody td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background 140ms var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }

.cell-short { display: inline-flex; align-items: center; gap: 8px; }
.slug-link { font-weight: 600; color: var(--ink); text-decoration: none; }
.slug-link:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

.dest {
  display: inline-block;
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  vertical-align: middle;
}
.dest:hover { color: var(--ink); }

.clicks {
  display: inline-block;
  min-width: 30px;
  padding: 2px 9px;
  border-radius: var(--pill);
  background: var(--accent-quiet);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.84rem;
}
[data-theme="dark"] .clicks { color: var(--ink); }

.row-leaving { opacity: 0; transform: translateX(8px); }

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

.row-actions { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; }

/* ---------- Multi-user bits ---------- */
.me-chip {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 11px;
  border-radius: var(--pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}
.owner-tag, .role-tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--pill);
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--accent-quiet);
  color: var(--accent);
  text-transform: capitalize;
}
.owner-anon, .role-tag:not(.role-admin) {
  background: var(--surface-2);
  color: var(--muted);
}
.addbar-user { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 130px auto; }
select.input {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

/* ---------- Stats ---------- */
.stats {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
}
.stat {
  flex: 1 1 0;
  min-width: 130px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 12px 18px;
  border-right: 1px solid var(--border);
}
.stat:last-child { border-right: 0; }
.stat-num {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stat-num.mono { font-size: 1.02rem; color: var(--accent); font-weight: 500; }
.stat-label {
  font-size: 0.78rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- List head + search ---------- */
.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 26px 2px 14px;
}
.h2-sm { font-size: 1.05rem; font-weight: 650; letter-spacing: -0.01em; }
.search-wrap { position: relative; display: flex; align-items: center; }
.search-ic {
  position: absolute;
  left: 12px;
  color: var(--muted);
  pointer-events: none;
}
.search {
  width: 260px;
  max-width: 48vw;
  height: 40px;
  padding: 0 13px 0 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
.search::placeholder { color: var(--muted); opacity: 0.8; }
.search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-quiet);
}
.no-results {
  padding: 28px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
}

/* ---------- QR dialog ---------- */
.qr-dialog {
  border: 0;
  padding: 0;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-xl);
  max-width: calc(100vw - 32px);
}
.qr-dialog::backdrop { background: oklch(0.2 0.02 260 / 0.5); backdrop-filter: blur(2px); }
.qr-box { padding: 22px; display: grid; justify-items: center; gap: 14px; }
.qr-canvas {
  width: 208px; height: 208px;
  padding: 10px;
  background: #fff;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
}
.qr-canvas img, .qr-canvas canvas { display: block; }
.qr-url { font-size: 0.85rem; color: var(--muted); max-width: 240px; text-align: center; word-break: break-all; }
.qr-actions { display: flex; gap: 8px; }

/* ---------- Edit dialog ---------- */
.edit-dialog { width: 420px; }
.edit-form { padding: 22px; display: grid; gap: 15px; }
.edit-title { font-size: 1.1rem; font-weight: 650; letter-spacing: -0.01em; }
.edit-form .qr-actions { margin-top: 4px; }

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: 56px 24px;
  background: var(--surface);
  border: 1px dashed var(--border-2);
  border-radius: var(--radius);
}
.empty-mark {
  display: inline-grid;
  place-items: center;
  width: 54px; height: 54px;
  margin-bottom: 14px;
  border-radius: 16px;
  background: var(--accent-quiet);
  color: var(--accent);
  font-size: 1.6rem;
  font-weight: 700;
}
.empty-title { font-size: 1.15rem; font-weight: 680; margin-bottom: 6px; }
.empty .muted { max-width: 46ch; margin: 0 auto; }
.empty-404 { margin: 56px auto; max-width: 460px; }
.empty-404 .btn { margin-top: 18px; }

/* ---------- Toast ---------- */
.toast {
  margin: 0 0 14px;
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  border: 1px solid var(--border);
  background: var(--surface);
}
.toast-success { border-color: color-mix(in oklch, var(--ok) 50%, var(--border)); background: color-mix(in oklch, var(--ok) 12%, var(--surface)); }
.toast-error   { border-color: color-mix(in oklch, var(--danger) 55%, var(--border)); background: color-mix(in oklch, var(--danger) 12%, var(--surface)); }

.toast-host {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  z-index: 60;
  width: max-content;
  max-width: calc(100vw - 32px);
}
.toast-pop {
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--bg);
  font-size: 0.88rem;
  font-weight: 550;
  box-shadow: var(--shadow);
  animation: toast-in 220ms var(--ease);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .url-input { height: 50px; font-size: 1rem; }
  .send { width: 48px; height: 48px; }
  .result-url { font-size: 1.5rem; }

  .addbar { grid-template-columns: 1fr; }
  .addbar-submit { width: 100%; }
  .slug-prefix { max-width: 55%; }

  .stat { flex-basis: 100%; border-right: 0; border-bottom: 1px solid var(--border); }
  .stat:last-child { border-bottom: 0; }
  .list-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .search, .search-wrap { width: 100%; max-width: none; }
  .row-actions { justify-content: flex-end; }

  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tbody tr { padding: 14px 16px; border-bottom: 1px solid var(--border); }
  .table tbody td {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; padding: 6px 0; border: 0;
  }
  .table tbody td::before {
    content: attr(data-th);
    font-size: 0.74rem; font-weight: 600; letter-spacing: 0.04em;
    text-transform: uppercase; color: var(--muted);
  }
  .dest { max-width: 60vw; }
  .ta-right { text-align: left; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
