/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f7f8fa;
  --surface:   #ffffff;
  --border:    #e2e5ea;
  --text:      #1a1d23;
  --muted:     #6b7280;
  --primary:   #2563eb;
  --primary-h: #1d4ed8;
  --danger:    #dc2626;
  --danger-h:  #b91c1c;
  --success:   #16a34a;
  --radius:    6px;
  --shadow:    0 1px 3px rgba(0,0,0,.08);
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navigation ──────────────────────────────────────────────────────────── */
.admin-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 0;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
  margin-right: 1.5rem;
  flex-shrink: 0;
}
.nav-brand:hover { text-decoration: none; }

.nav-links {
  display: flex;
  gap: 0;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  height: 52px;
  padding: 0 .9rem;
  font-size: .875rem;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.nav-link:hover { color: var(--text); text-decoration: none; }
.nav-link.active { color: var(--primary); border-bottom-color: var(--primary); }

.nav-right {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-left: auto;
}

.nav-user {
  font-size: .875rem;
  color: var(--muted);
}

.dev-badge {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  font-size: .7rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.btn-logout {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 10px;
  font-size: .8125rem;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

/* ── Main content ────────────────────────────────────────────────────────── */
.admin-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}
.page-header h1 { font-size: 1.375rem; font-weight: 700; }

.header-actions { display: flex; gap: .5rem; align-items: center; }

/* ── Card ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 1rem; font-weight: 600; margin-bottom: 1.25rem; }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .875rem;
}
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-danger  { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .375rem; margin-bottom: 1rem; }
.form-group label { font-size: .875rem; font-weight: 500; color: var(--text); }
.form-hint { font-size: .8rem; color: var(--muted); margin-top: .25rem; }

.form-control {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .9375rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--primary); }

textarea.form-control { resize: vertical; min-height: 80px; }

.checkbox-label { display: flex; align-items: center; gap: .5rem; cursor: pointer; font-weight: 400; }
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

.form-row-inline { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start; }
.form-row-inline .form-group { min-width: 180px; flex: 1; }

.form-actions { display: flex; gap: .5rem; margin-top: 1.25rem; }

.slug-input-wrap { display: flex; align-items: center; gap: 0; }
.slug-prefix {
  background: var(--bg);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  padding: .5rem .75rem;
  font-size: .875rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.slug-input { border-radius: 0 var(--radius) var(--radius) 0; flex: 1; }

.slug-display {
  font-size: .9375rem;
  color: var(--muted);
  padding: .375rem 0;
}
.slug-base { color: var(--muted); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .5rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}

.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); text-decoration: none; color: #fff; }

.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--bg); text-decoration: none; }

.btn-ghost { background: none; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg); text-decoration: none; }

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-h); border-color: var(--danger-h); text-decoration: none; color: #fff; }

.btn-sm { padding: .3rem .7rem; font-size: .8125rem; }

/* ── Table ───────────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.data-table th {
  text-align: left;
  padding: .5rem .75rem;
  border-bottom: 2px solid var(--border);
  font-size: .8125rem;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}
.data-table td {
  padding: .625rem .75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg); }
.data-table tbody tr.row-inactive td { opacity: .5; }

.text-center { text-align: center; }
.text-muted  { color: var(--muted); }
.text-sm     { font-size: .8125rem; }

.actions { display: flex; gap: .25rem; align-items: center; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: none;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, color .15s, border-color .15s;
  flex-shrink: 0;
  padding: 0;
  font-family: inherit;
}
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn:hover { background: var(--bg); color: var(--text); border-color: #c8cdd5; text-decoration: none; }
.icon-btn-danger:hover { background: #fef2f2; color: var(--danger); border-color: #fecaca; }

.url-cell { max-width: 320px; }
.dest-link {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  color: var(--muted);
  font-size: .8125rem;
}
.dest-link:hover { color: var(--primary); }

.slug-link { font-weight: 600; font-family: 'SF Mono', 'Fira Code', monospace; font-size: .875rem; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-muted   { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
  font-size: .9375rem;
}

/* ── QR page ─────────────────────────────────────────────────────────────── */
.qr-page { display: flex; justify-content: center; padding: 1rem 0; }
.qr-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  max-width: 480px;
  width: 100%;
}
.qr-image { max-width: 280px; width: 100%; border: 1px solid var(--border); border-radius: var(--radius); }
.qr-url-display {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem 1rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: .875rem;
  width: 100%;
  justify-content: space-between;
}
.qr-actions { display: flex; gap: .75rem; flex-wrap: wrap; justify-content: center; }

/* ── Settings logo ───────────────────────────────────────────────────────── */
.logo-preview { display: flex; align-items: center; gap: 1rem; margin-bottom: .5rem; }
.logo-thumb { width: 80px; height: 80px; object-fit: contain; border: 1px solid var(--border); border-radius: var(--radius); background: #f3f4f6; padding: 4px; }

/* ── Public pages ────────────────────────────────────────────────────────── */
.public-card {
  max-width: 720px;
  margin: 3rem auto;
  padding: 0 1.5rem;
}
.public-card-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 2.25rem;
  box-shadow: var(--shadow);
  font-size: 1rem;
  line-height: 1.75;
}
.public-card-body h2 { font-size: 1.4rem; font-weight: 700; margin-bottom: .75rem; margin-top: 1.5rem; }
.public-card-body h2:first-child { margin-top: 0; }
.public-card-body h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: .5rem; margin-top: 1.25rem; }
.public-card-body p  { margin-bottom: .75rem; }
.public-card-body ul, .public-card-body ol { margin: 0 0 .75rem 1.5rem; }
.public-card-body strong { font-weight: 600; }

.not-found-box {
  text-align: center;
  padding: 4rem 1.5rem;
  max-width: 480px;
  margin: 0 auto;
}
.not-found-code {
  font-size: 5rem;
  font-weight: 800;
  color: var(--border);
  line-height: 1;
  margin-bottom: .5rem;
}
.not-found-message { font-size: 1.125rem; color: var(--muted); }

/* ── Login page ──────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}
.login-box h1 { font-size: 1.25rem; font-weight: 700; margin-bottom: 1.5rem; text-align: center; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.75rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
}
.modal-box h3 { font-size: 1rem; font-weight: 600; margin-bottom: 1.25rem; }
.modal-actions { display: flex; gap: .5rem; margin-top: 1rem; }

/* ── Breadcrumb ──────────────────────────────────────────────────────────── */
.breadcrumb {
  display: inline-block;
  font-size: .8125rem;
  color: var(--muted);
  margin-bottom: .25rem;
}
.breadcrumb:hover { color: var(--primary); }

/* ── Quill editor overrides ──────────────────────────────────────────────── */
.ql-toolbar { border-color: var(--border) !important; border-radius: var(--radius) var(--radius) 0 0; }
.ql-container { border-color: var(--border) !important; border-radius: 0 0 var(--radius) var(--radius); font-size: .9375rem; }
.ql-editor { min-height: 160px; }

/* ── Required star ───────────────────────────────────────────────────────── */
.required { color: var(--danger); }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .admin-main { padding: 1.25rem 1rem; }
  .data-table th:nth-child(4),
  .data-table td:nth-child(4) { display: none; }
}
