/* ============================================================
   LinkCore — Estilos do painel
   Paleta: grafite frio + cobalto elétrico
   ============================================================ */

:root {
  --bg: #eef1f6;          /* fundo cinza-azulado frio */
  --surface: #ffffff;
  --ink: #131a26;          /* grafite profundo */
  --ink-soft: #5b6575;
  --line: #d8dee8;
  --accent: #2743e0;       /* cobalto */
  --accent-ink: #ffffff;
  --danger: #c92f3f;
  --ok: #1f9d63;
  --radius: 10px;
  --font-display: 'Sora', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; margin-bottom: 16px; }
h3 { font-size: 0.95rem; color: var(--ink-soft); margin-bottom: 12px; font-weight: 600; }

.view { min-height: 100vh; }
[hidden] { display: none !important; }

/* ---------- Marca ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1, .brand span:not(.brand-mark) { font-family: var(--font-display); font-weight: 600; font-size: 1.6rem; }
.brand strong { color: var(--accent); }
.brand-mark {
  font-family: var(--font-mono);
  background: var(--accent);
  color: var(--accent-ink);
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 8px;
  font-size: 1.3rem; font-weight: 600;
}
.brand-small h1, .brand-small span:not(.brand-mark) { font-size: 1.15rem; }
.brand-small .brand-mark { width: 28px; height: 28px; font-size: 1rem; }

/* ---------- Login ---------- */
#view-login { display: grid; place-items: center; padding: 24px; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%; max-width: 420px;
  display: flex; flex-direction: column; gap: 14px;
}
.login-hint { color: var(--ink-soft); font-size: 0.9rem; margin-bottom: 8px; }

/* ---------- Campos ---------- */
label { font-size: 0.8rem; font-weight: 600; color: var(--ink-soft); display: block; margin-bottom: 6px; }
.optional { font-weight: 400; opacity: 0.7; }
input, select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.field-error { color: var(--danger); font-size: 0.85rem; }

/* ---------- Botões ---------- */
.btn {
  font: inherit; font-weight: 600;
  padding: 11px 20px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.06s ease, background 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #1d35c4; }
.btn-dark { background: var(--ink); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: #f3f5f9; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: #fdf0f1; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.topbar-stat { font-size: 0.85rem; color: var(--ink-soft); }

.container { max-width: 980px; margin: 0 auto; padding: 32px 20px 80px; }

/* ---------- Painel de encurtar ---------- */
.shorten-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 32px;
}
.shorten-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: end;
}
.field-url { grid-column: 1 / -1; }
.slug-wrap { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.slug-wrap:focus-within { outline: 2px solid var(--accent); }
.slug-prefix {
  font-family: var(--font-mono); font-size: 0.78rem;
  padding: 0 0 0 12px; color: var(--ink-soft); white-space: nowrap;
}
.slug-wrap input { border: none; padding-left: 4px; font-family: var(--font-mono); }
.slug-wrap input:focus { outline: none; }
.btn-shorten { grid-column: 1 / -1; justify-self: start; }

/* ---------- Token de resultado (elemento assinatura) ---------- */
.result-token {
  margin-top: 24px;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 22px 24px;
  background: linear-gradient(180deg, #f6f8ff 0%, #fff 100%);
  animation: pop 0.25s ease;
}
@keyframes pop { from { transform: scale(0.98); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .result-token { animation: none; } }
.result-url {
  font-family: var(--font-mono);
  font-size: clamp(1.05rem, 3vw, 1.5rem);
  font-weight: 600;
  color: var(--accent);
  word-break: break-all;
  margin-bottom: 16px;
}
.result-actions { display: flex; gap: 10px; }
.qr-holder { margin-top: 18px; background: #fff; padding: 12px; width: fit-content; border: 1px solid var(--line); border-radius: 8px; }

/* ---------- Lista de links ---------- */
.links-panel { }
.links-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; }
.links-head h2 { margin: 0; }
.links-head input { max-width: 300px; }
.links-list { display: flex; flex-direction: column; gap: 10px; }

.link-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.link-row:hover { border-color: var(--accent); }
.link-row.inactive { opacity: 0.55; }
.link-code { font-family: var(--font-mono); font-weight: 600; color: var(--accent); font-size: 0.95rem; }
.link-title { font-weight: 600; }
.link-dest { color: var(--ink-soft); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 560px; }
.link-clicks { text-align: right; font-family: var(--font-mono); font-weight: 600; align-self: center; grid-row: 1 / span 3; }
.link-clicks small { display: block; font-family: var(--font-body); font-weight: 400; color: var(--ink-soft); }
.link-copy { justify-self: end; }

.empty-state { color: var(--ink-soft); text-align: center; padding: 40px 0; }

/* ---------- Estatísticas ---------- */
.stats-header {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 24px;
  margin-bottom: 16px;
}
.stats-short-url { font-family: var(--font-mono); color: var(--accent); font-weight: 600; text-decoration: none; }
.stats-short-url:hover { text-decoration: underline; }
.stats-dest { color: var(--ink-soft); font-size: 0.85rem; word-break: break-all; margin-top: 4px; }
.stats-total { text-align: right; }
.stats-total span { font-family: var(--font-display); font-size: 2.6rem; font-weight: 700; color: var(--accent); line-height: 1; }
.stats-total label { margin-top: 4px; }

.stats-manage { display: flex; gap: 10px; margin-bottom: 24px; flex-wrap: wrap; }

.chart-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.stats-grid .chart-panel { margin-bottom: 0; }

.rank-list { display: flex; flex-direction: column; gap: 8px; }
.rank-item { display: flex; justify-content: space-between; font-size: 0.88rem; gap: 12px; }
.rank-item span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-item span:last-child { font-family: var(--font-mono); font-weight: 600; }
.rank-bar { height: 4px; background: var(--accent); border-radius: 2px; opacity: 0.85; }

/* ---------- Responsivo ---------- */
@media (max-width: 720px) {
  .shorten-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .links-head { flex-direction: column; align-items: stretch; }
  .links-head input { max-width: none; }
  .stats-header { flex-direction: column; }
  .stats-total { text-align: left; }
  .link-dest { max-width: 100%; }
}
