/* ============================================================
   URL Shortener MVP — Dashboard
   Tema: dark slate + aksen oranye Cloudflare (#f6821f)
   ============================================================ */

:root {
  --bg: #0b1120;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-2: rgba(255, 255, 255, 0.06);
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.3);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #f6821f;
  --accent-strong: #ff9a3d;
  --accent-ink: #1a1207;
  --success: #34d399;
  --danger: #f87171;
  --radius: 14px;
  --radius-sm: 9px;
  --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Glow oranye lembut di bagian atas halaman */
.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(600px 320px at 82% -60px, rgba(246, 130, 31, 0.16), transparent 70%),
    radial-gradient(500px 300px at 8% -80px, rgba(56, 189, 248, 0.07), transparent 70%);
  z-index: 0;
}

.container {
  width: min(1120px, 100% - 2.5rem);
  margin-inline: auto;
}

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

.hidden { display: none !important; }

/* ---------- Header ---------- */
.site-header {
  position: relative;
  z-index: 1;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 17, 32, 0.75);
  backdrop-filter: blur(8px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 0.75rem; }

.brand-mark { width: 40px; height: 40px; flex: none; }

.brand-text { display: flex; flex-direction: column; }

.brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.brand-name em {
  font-style: normal;
  color: var(--accent);
  font-size: 0.72em;
  vertical-align: 0.18em;
  margin-left: 0.3rem;
  border: 1px solid rgba(246, 130, 31, 0.45);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
}

.brand-sub { font-size: 0.74rem; color: var(--muted); }

.header-badges { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.chip {
  font-size: 0.74rem;
  color: var(--muted);
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  white-space: nowrap;
}

.chip-orange {
  color: var(--accent-strong);
  border-color: rgba(246, 130, 31, 0.4);
  background: rgba(246, 130, 31, 0.08);
}

/* ---------- Layout utama ---------- */
.main-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: 1.25rem;
  padding: 1.75rem 0 2rem;
  flex: 1 0 auto;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: 0 10px 30px rgba(2, 6, 17, 0.35);
}

.card h2 { margin: 0 0 0.2rem; font-size: 1.12rem; }

.card-desc { margin: 0 0 1.1rem; color: var(--muted); font-size: 0.86rem; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}
.card-head h2 { margin: 0; }

.card-head-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.form-card { align-self: start; }

.list-card, .analytics-card { grid-column: 1 / -1; }

/* ---------- Form ---------- */
.field { margin-bottom: 1rem; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
}

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.req { color: var(--accent); }
.opt { color: var(--muted); font-weight: 400; }

input, select {
  width: 100%;
  background: rgba(2, 6, 17, 0.55);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.62rem 0.8rem;
  font-size: 0.92rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder { color: #5b6b82; }

input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(246, 130, 31, 0.18);
}

.field-hint { margin: 0.3rem 0 0; font-size: 0.72rem; color: #64748b; }

.ttl-custom { margin-top: 0.45rem; }

/* ---------- Tombol ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  padding: 0.62rem 1.1rem;
  cursor: pointer;
  text-decoration: none;
  transition: filter 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  min-height: 44px;
}

.btn-primary {
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  color: var(--accent-ink);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { filter: grayscale(0.4) brightness(0.8); cursor: wait; }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-ghost:hover { background: var(--surface-2); border-color: var(--accent); color: var(--accent-strong); }

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; min-height: 36px; }

.btn-block { width: 100%; }

.spinner {
  width: 15px; height: 15px;
  border: 2.5px solid rgba(26, 18, 7, 0.35);
  border-top-color: var(--accent-ink);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .spinner { animation-duration: 1.4s; }
}

/* ---------- Alert & hasil ---------- */
.alert {
  margin-top: 0.9rem;
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
  font-size: 0.85rem;
}

.alert-error {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #fca5a5;
}

.result-box {
  margin-top: 1.1rem;
  border: 1px solid rgba(52, 211, 153, 0.35);
  background: rgba(52, 211, 153, 0.07);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
}

.result-label { margin: 0 0 0.55rem; font-size: 0.8rem; color: var(--success); font-weight: 700; }

.result-url-row { display: flex; margin-bottom: 0.7rem; }

.result-url {
  font-family: var(--mono);
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--accent-strong);
  word-break: break-all;
}
.result-url:hover { text-decoration: underline; }

.result-actions { display: flex; gap: 0.55rem; flex-wrap: wrap; }

.result-meta { margin: 0.75rem 0 0; font-size: 0.75rem; color: var(--muted); word-break: break-all; }

/* ---------- Kartu arsitektur ---------- */
.arch-card { align-self: start; }

.flow-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.85rem; }

.flow-list li { display: flex; gap: 0.8rem; align-items: flex-start; }

.flow-num {
  flex: none;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(246, 130, 31, 0.14);
  border: 1px solid rgba(246, 130, 31, 0.45);
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 700;
  margin-top: 2px;
}

.flow-list strong { display: block; font-size: 0.88rem; }
.flow-list span { font-size: 0.78rem; color: var(--muted); }
.flow-list code {
  font-family: var(--mono);
  font-size: 0.72rem;
  background: rgba(148, 163, 184, 0.12);
  border-radius: 4px;
  padding: 0.05rem 0.3rem;
}

.arch-foot { margin-top: 1.1rem; }

/* ---------- Tabel daftar tautan ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 26rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.35) transparent;
}

table { width: 100%; border-collapse: collapse; min-width: 720px; }

#btn-load-more { margin-top: 0.9rem; }

thead th {
  position: sticky;
  top: 0;
  background: #101a30;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border-strong);
  z-index: 2;
}

tbody td {
  padding: 0.62rem 0.85rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  vertical-align: middle;
}

tbody tr:hover { background: rgba(148, 163, 184, 0.05); }
tbody tr:last-child td { border-bottom: none; }

.empty-row td { text-align: center; color: var(--muted); padding: 2rem 1rem; }

.num { text-align: right; font-variant-numeric: tabular-nums; }
.col-actions { width: 1%; white-space: nowrap; }

.code-cell {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--accent-strong);
  white-space: nowrap;
}

.badge {
  display: inline-block;
  font-size: 0.66rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
  margin-left: 0.45rem;
  vertical-align: 0.1em;
}
.badge-custom { background: rgba(246, 130, 31, 0.14); color: var(--accent-strong); border: 1px solid rgba(246, 130, 31, 0.4); }

.badge-status {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.16rem 0.6rem;
}
.badge-active { background: rgba(52, 211, 153, 0.12); color: var(--success); border: 1px solid rgba(52, 211, 153, 0.4); }
.badge-expired { background: rgba(248, 113, 113, 0.1); color: var(--danger); border: 1px solid rgba(248, 113, 113, 0.4); }

.long-url-cell {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.row-actions { display: flex; gap: 0.4rem; }

/* ---------- Panel analitik ---------- */
.stat-chips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1.4rem;
}

.stat {
  border: 1px solid var(--border);
  background: rgba(2, 6, 17, 0.45);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.stat-value { font-size: 1.45rem; font-weight: 800; color: var(--accent-strong); }
.stat-label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.sub-title { font-size: 0.9rem; margin: 0 0 0.7rem; }

.chart {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  height: 150px;
  padding: 0.6rem 0.7rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(2, 6, 17, 0.45);
  margin-bottom: 1.4rem;
}

.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  height: 100%;
}

.chart-bar {
  width: 100%;
  max-width: 46px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, var(--accent-strong), rgba(246, 130, 31, 0.55));
  min-height: 3px;
  transition: filter 0.15s ease;
}
.chart-bar.zero { background: rgba(148, 163, 184, 0.18); }
.chart-bar:hover { filter: brightness(1.2); }

.chart-val { font-size: 0.66rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.chart-day { font-size: 0.68rem; color: var(--muted); }

.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.2rem;
}

.breakdown { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.55rem; }

.breakdown li { font-size: 0.82rem; }

.bd-row {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.22rem;
}

.bd-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-count { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }

.bar-track {
  height: 7px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.14);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
}

.bd-empty { color: #64748b; font-size: 0.78rem; }

/* ---------- Footer ---------- */
.site-footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--border);
  padding: 1rem 0;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.76rem;
  color: var(--muted);
}

.footer-dim { color: #64748b; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.4rem;
  transform: translate(-50%, 160%);
  background: #1a2439;
  border: 1px solid rgba(52, 211, 153, 0.45);
  color: var(--text);
  font-size: 0.85rem;
  border-radius: 999px;
  padding: 0.6rem 1.2rem;
  box-shadow: 0 12px 30px rgba(2, 6, 17, 0.6);
  transition: transform 0.25s ease;
  z-index: 50;
  pointer-events: none;
}

.toast.show { transform: translate(-50%, 0); }

/* ---------- Responsif ---------- */
@media (max-width: 860px) {
  .main-grid { grid-template-columns: 1fr; padding-top: 1.25rem; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .hide-sm { display: none; }
  .long-url-cell { max-width: 180px; }
  .chart { gap: 0.35rem; }
}
