/* ============================================================
   links.hanif.app — design tokens (locked)
   Arah: "Google Blue klasik". Netral disiplin, satu warna sinyal
   (#1A73E8) cuma buat CTA, fokus, dan baris aktif.
   Type: Roboto (body) + Roboto Mono (angka, nomor, timestamp).
   Radius: 4/8/12/999. Motion: 120–180ms, easing standar Material.
   ============================================================ */

:root {
  --bg:            #ffffff;
  --bg-sunken:     #f8f9fa;
  --surface:       #ffffff;
  --surface-hover: #f8f9fa;
  --text:          #202124;
  --text-muted:    #5f6368;
  --text-faint:    #80868b;
  --border:        #dadce0;
  --border-strong: #bdc1c6;
  --accent:        #1a73e8;
  --accent-hover:  #1765cc;
  --accent-quiet:  #e8f0fe;
  --danger:        #d93025;
  --ok:            #188038;
  --scrim:         rgba(32, 33, 36, .5);

  --shadow-1: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
  --shadow-2: 0 1px 3px rgba(60,64,67,.3), 0 4px 8px 3px rgba(60,64,67,.15);

  --r-sm: 4px;  --r-md: 8px;  --r-lg: 12px;  --r-full: 999px;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px;

  --ease: cubic-bezier(.2, 0, 0, 1);
  --dur: 140ms;

  --font: Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --bg:            #131314;
  --bg-sunken:     #1b1c1d;
  --surface:       #1e1f20;
  --surface-hover: #26282a;
  --text:          #e8eaed;
  --text-muted:    #9aa0a6;
  --text-faint:    #80868b;
  --border:        #3c4043;
  --border-strong: #5f6368;
  --accent:        #8ab4f8;
  --accent-hover:  #a8c7fa;
  --accent-quiet:  #1f2a3d;
  --danger:        #f28b82;
  --ok:            #81c995;
  --scrim:         rgba(0, 0, 0, .6);
  --shadow-1: 0 1px 2px rgba(0,0,0,.6), 0 1px 3px 1px rgba(0,0,0,.3);
  --shadow-2: 0 1px 3px rgba(0,0,0,.6), 0 4px 8px 3px rgba(0,0,0,.3);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg-sunken);
  color: var(--text);
  font: 400 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }

/* ---------- App bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--s-4);
  height: 64px; padding: 0 var(--s-5);
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.brand {
  display: flex; align-items: center; gap: var(--s-2);
  font-weight: 500; font-size: 20px; letter-spacing: -.2px; text-decoration: none;
}
.brand svg { color: var(--accent); }
.appbar .spacer { flex: 1; }

.theme-toggle { display: flex; gap: 2px; padding: 2px; background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--r-full); }
.theme-toggle button {
  border: 0; background: transparent; cursor: pointer; padding: 5px 11px;
  border-radius: var(--r-full); font-size: 12px; color: var(--text-muted);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.theme-toggle button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

/* ---------- Layout ---------- */
.wrap { max-width: 1080px; margin: 0 auto; padding: var(--s-6) var(--s-5) 96px; }
.head { display: flex; align-items: flex-end; gap: var(--s-4); margin-bottom: var(--s-5); flex-wrap: wrap; }
.head h1 { margin: 0; font-size: 28px; font-weight: 400; letter-spacing: -.3px; }
.head .sub { color: var(--text-muted); font-size: 13px; }
.head .spacer { flex: 1; }

.crumb {
  display: inline-flex; align-items: center; gap: 6px; margin-bottom: var(--s-3);
  color: var(--text-muted); font-size: 13px; text-decoration: none; padding: 4px 8px 4px 4px;
  border-radius: var(--r-sm);
}
.crumb:hover { background: var(--surface-hover); color: var(--text); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 16px; border-radius: var(--r-md); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap;
  font-size: 14px; font-weight: 500; text-decoration: none;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn:hover { background: var(--surface-hover); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: var(--shadow-1); }
[data-theme="dark"] .btn-primary { color: #10233f; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:disabled { opacity: .5; cursor: default; box-shadow: none; }
.btn-quiet { border-color: transparent; background: transparent; color: var(--text-muted); }
.btn-quiet:hover { background: var(--surface-hover); color: var(--text); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-danger:hover { color: var(--danger); }
a.btn:hover { text-decoration: none; }
.btn-sm svg { opacity: .7; }

/* ---------- Cards (dashboard) ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); gap: var(--s-4); }
.card {
  display: block; text-decoration: none; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-4);
  transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.card:hover { box-shadow: var(--shadow-2); border-color: var(--border-strong); }
.card:active { transform: translateY(1px); }
.card h3 { margin: 0 0 var(--s-3); font-size: 16px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .meta { display: flex; align-items: baseline; gap: 8px; color: var(--text-muted); font-size: 12px; }
.card .count { font-family: var(--mono); font-size: 20px; color: var(--text); font-weight: 500; }
.card.new {
  display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  border-style: dashed; color: var(--text-muted); background: transparent; min-height: 104px; font-weight: 500;
}
.card.new:hover { color: var(--accent); border-color: var(--accent); box-shadow: none; }

/* ---------- Paste bar (moment of truth) ---------- */
.paste {
  display: flex; align-items: center; gap: var(--s-2);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-full);
  padding: 6px 6px 6px 16px; box-shadow: var(--shadow-1); margin-bottom: var(--s-4);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.paste:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.paste svg { color: var(--text-faint); flex: none; }
.paste input { flex: 1; border: 0; background: transparent; height: 36px; min-width: 0; }
.paste input:focus { outline: none; }
.paste input::placeholder { color: var(--text-faint); }
.paste .btn-primary { border-radius: var(--r-full); height: 36px; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-3); flex-wrap: wrap; }
.search {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); min-width: 200px;
}
.search:focus-within { border-color: var(--accent); }
.search input { border: 0; background: transparent; width: 100%; }
.search input:focus { outline: none; }
.search svg { color: var(--text-faint); flex: none; }
.toolbar .spacer { flex: 1; }

/* ---------- Table ---------- */
.tablecard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 11px; font-weight: 500; letter-spacing: .8px; text-transform: uppercase;
  color: var(--text-muted); padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap;
  background: var(--surface);
}
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--text); }
thead th .arrow { font-family: var(--mono); margin-left: 4px; opacity: .8; }
tbody tr { border-bottom: 1px solid var(--border); transition: background var(--dur) var(--ease); }
tbody tr:last-child { border-bottom: 0; }
tbody tr:hover { background: var(--surface-hover); }
tbody tr.flash { background: var(--accent-quiet); }
tbody tr.pending { opacity: .72; }
td { padding: 10px 16px; vertical-align: middle; }

.col-seq { width: 68px; font-family: var(--mono); font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.col-when { width: 190px; }
.col-act { width: 132px; text-align: right; white-space: nowrap; }

.linkcell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.fav { width: 20px; height: 20px; flex: none; border-radius: var(--r-sm); background: var(--bg-sunken); object-fit: contain; }
.fav-fb { display: grid; place-items: center; font-size: 11px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; }
.linkmeta { min-width: 0; }
.linktitle {
  display: block; font-size: 14px; color: var(--text); text-decoration: none; font-weight: 400;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 460px;
}
.linktitle:hover { color: var(--accent); text-decoration: underline; }
.linkurl { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 460px; }
.when { font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.when small { display: block; font-size: 11px; color: var(--text-faint); }

.rowact { display: inline-flex; gap: 2px; opacity: 0; transition: opacity var(--dur) var(--ease); }
tr:hover .rowact, tr:focus-within .rowact { opacity: 1; }
.iconbtn {
  width: 32px; height: 32px; display: grid; place-items: center; border: 0; background: transparent;
  border-radius: var(--r-full); color: var(--text-muted); cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.iconbtn:hover { background: var(--accent-quiet); color: var(--accent); }
.iconbtn.danger:hover { background: transparent; color: var(--danger); }

.skel { display: inline-block; height: 12px; width: 160px; border-radius: var(--r-sm); background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--surface-hover) 50%, var(--bg-sunken) 75%); background-size: 200% 100%; animation: shimmer 1.1s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Pagination ---------- */
.pager {
  display: flex; align-items: center; gap: var(--s-3); padding: 10px 16px;
  border-top: 1px solid var(--border); color: var(--text-muted); font-size: 13px; flex-wrap: wrap;
}
.pager .spacer { flex: 1; }
.pager .range { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.perpage { display: flex; align-items: center; gap: 8px; }
.perpage select {
  height: 32px; border: 1px solid var(--border); background: var(--surface); border-radius: var(--r-md);
  padding: 0 8px; cursor: pointer; font-size: 13px; font-family: var(--mono);
}
.pagebtns { display: flex; gap: 2px; }
.pagebtns button:disabled { opacity: .35; cursor: default; }
.pagebtns button:disabled:hover { background: transparent; color: var(--text-muted); }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: var(--s-7) var(--s-4); color: var(--text-muted); }
.empty h2 { margin: 0 0 var(--s-2); font-size: 18px; font-weight: 500; color: var(--text); }
.empty p { margin: 0 auto var(--s-4); max-width: 380px; }
.kbd { font-family: var(--mono); font-size: 12px; background: var(--bg-sunken); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: var(--r-sm); padding: 1px 6px; }

/* ---------- Title editor + save hint ---------- */
.titlefield {
  border: 1px solid transparent; background: transparent; font: 400 28px/1.2 var(--font);
  letter-spacing: -.3px; padding: 4px 8px; margin: -4px -8px; border-radius: var(--r-md);
  max-width: 100%; min-width: 120px;
}
.titlefield:hover { border-color: var(--border); }
.titlefield:focus { border-color: var(--accent); outline: none; background: var(--surface); }
.savehint { font-size: 12px; color: var(--ok); opacity: 0; transition: opacity var(--dur) var(--ease); }
.savehint.on { opacity: 1; }

/* ---------- Snackbar ---------- */
.snackbar {
  position: fixed; left: 24px; bottom: 24px; z-index: 40;
  display: flex; align-items: center; gap: var(--s-4);
  background: #323232; color: #fff; padding: 12px 12px 12px 16px; border-radius: var(--r-sm);
  box-shadow: var(--shadow-2); font-size: 14px; max-width: min(560px, calc(100vw - 48px));
  animation: rise 180ms var(--ease);
}
[data-theme="dark"] .snackbar { background: #e8eaed; color: #202124; }
.snackbar button {
  border: 0; background: transparent; color: #8ab4f8; font-weight: 500; cursor: pointer;
  padding: 6px 8px; border-radius: var(--r-sm); text-transform: uppercase; font-size: 13px; letter-spacing: .4px;
}
[data-theme="dark"] .snackbar button { color: #1a73e8; }
.snackbar button:hover { background: rgba(138,180,248,.12); }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Dialog ---------- */
dialog { border: 0; padding: 0; border-radius: var(--r-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow-2); width: min(400px, calc(100vw - 32px)); }
dialog::backdrop { background: var(--scrim); }
.dialog-body { padding: var(--s-5); }
.dialog-body h2 { margin: 0 0 var(--s-4); font-size: 20px; font-weight: 400; }
.field { width: 100%; height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--bg); }
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.dialog-act { display: flex; justify-content: flex-end; gap: var(--s-2); padding: 0 var(--s-5) var(--s-5); }

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  .wrap { padding: var(--s-4) var(--s-3) 96px; }
  .head h1, .titlefield { font-size: 24px; }
  .titlefield { width: 100%; margin: -4px 0; }
  .paste { flex-wrap: wrap; border-radius: var(--r-lg); padding: 8px; gap: 8px; }
  .paste input { flex: 1 1 100%; padding: 0 4px; }
  .paste svg { display: none; }
  .paste .btn-primary { flex: 1; }
  .search { flex: 1 1 100%; }
  .toolbar .spacer { display: none; }
  .when small { white-space: nowrap; }
  .appbar { padding: 0 var(--s-3); }
  .col-when { width: auto; }
  thead .col-when, thead .col-act { display: none; }
  .col-seq { width: 44px; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tbody tr { position: relative; padding: 12px 12px 12px 44px; }
  td { padding: 0; }
  .col-seq { position: absolute; left: 12px; top: 14px; width: auto; }
  .col-when { margin-top: 6px; }
  .when { font-size: 12px; }
  .when small { display: inline; margin-left: 6px; }
  .col-act { text-align: left; margin-top: 8px; }
  .rowact { opacity: 1; }
  .linktitle, .linkurl { max-width: calc(100vw - 110px); }
  .snackbar { left: 12px; right: 12px; bottom: 12px; }
}

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