/* ============================================================================
   app.css — logged-in shell + shortener views
   Dark, calm, generous whitespace. Targets the semantic .short-* classes
   that bvgeert renders for shortener-mode domains.
============================================================================ */

:root {
  --bg: #0b1220;
  --bg-elev: #111a2e;
  --bg-elev-2: #16213a;
  --surface: rgba(255, 255, 255, 0.03);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #e6edf7;
  --muted: #8a99b3;
  --muted-soft: #6b7a94;
  --accent: #22d3ee;
  --accent-2: #818cf8;
  --danger: #f87171;
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

/* ----------------------------------------------------------------------------
   Role-based visibility (template gating)
---------------------------------------------------------------------------- */

.user-empty { display: none; }

body[data-role="user"] .admin-only { display: none !important; }
body[data-role="user"] .user-empty { display: flex; }
body[data-role="user"] .app-header { border-bottom: none; }
body[data-role="user"] .app-main { padding-top: 0; }

/* ----------------------------------------------------------------------------
   App header (top bar)
---------------------------------------------------------------------------- */

.app-header {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 1rem 2rem;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
}

.app-brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.app-brand .brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  flex-shrink: 0;
  display: block;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.06);
}

.app-nav {
  display: flex;
  gap: 0.25rem;
  flex: 1;
}

.app-nav a {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}

.app-nav a:hover {
  background: var(--surface);
  color: var(--text);
}

/* ----------------------------------------------------------------------------
   User menu (right side of header)
---------------------------------------------------------------------------- */

.app-user { margin-left: auto; }

.app-user .bvg-user-menu {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.app-user .bvg-user-menu__email {
  font-size: 0.85rem;
  color: var(--muted);
}

.app-user .bvg-user-menu__logout {
  margin: 0;
  padding: 0;
}

.app-user .bvg-user-menu__logout button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.95rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  font-family: inherit;
}

.app-user .bvg-user-menu__logout button:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* ----------------------------------------------------------------------------
   Main + footer scaffolding
---------------------------------------------------------------------------- */

.app-main {
  flex: 1;
  width: 100%;
  max-width: 64rem;
  margin: 0 auto;
  padding: 3rem 2rem;
}

.app-flash:empty { display: none; }

.app-footer {
  padding: 1.75rem 2rem;
  text-align: center;
  color: var(--muted-soft);
  font-size: 0.78rem;
  border-top: 1px solid var(--line);
}

.app-footer a { color: var(--muted); }
.app-footer a:hover { color: var(--text); }

/* Quash the white-badge version tag in bvgeert footer */
.app-footer code,
.app-footer .badge,
.app-footer [class*="bg-white"],
.app-footer [class*="bg-zinc"] {
  background: var(--surface) !important;
  color: var(--muted) !important;
  border: 1px solid var(--line);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.7rem;
}

/* ----------------------------------------------------------------------------
   Empty state (non-admin)
---------------------------------------------------------------------------- */

.user-empty {
  flex: 1;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 4rem 1.5rem;
}

.empty-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 3rem;
  max-width: 30rem;
  text-align: center;
}

.empty-card h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
}

.empty-card p {
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 2rem;
}

.empty-actions { display: flex; justify-content: center; }

/* ============================================================================
   SHORTENER VIEWS
   Designed to live inside .app-main. No Tailwind to override.
============================================================================ */

.short-page {
  width: 100%;
  max-width: 36rem;
  margin: 0 auto;
}

.short-page--index {
  max-width: 56rem;
}

/* ---- Fullscreen "create a link" page ---- */
/* The new-page is the primary thing an admin does, so it claims the whole
   viewport: large inputs, generous typography, vertically centered. */

body:has(.short-page--new) .app-main {
  max-width: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 4.5rem - 4rem); /* minus header + footer */
}

.short-page--new {
  max-width: 48rem;
  padding: 3rem 2rem;
}

.short-page--new .short-form {
  gap: 2rem;
}

.short-page--new .short-label {
  font-size: 0.85rem;
}

.short-page--new .short-input {
  font-size: 1.25rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
}

.short-page--new .short-input-group {
  border-radius: var(--radius);
}

.short-page--new .short-input-prefix {
  font-size: 1.05rem;
  padding: 1rem 0.85rem 1rem 1.25rem;
}

.short-page--new .short-input--key {
  font-size: 1.25rem;
  padding: 1rem 1.25rem 1rem 0.85rem !important;
}

.short-page--new .short-actions {
  margin-top: 0.5rem;
  padding-top: 0;
}

.short-page--new .short-button--primary {
  padding: 0.95rem 2rem;
  font-size: 1rem;
  border-radius: var(--radius);
  width: 100%;
}

/* ---- Auto-copy feedback on show page ---- */

.short-copy[data-copy-auto-value="true"] .short-copy-status {
  font-size: 0.95rem;
  font-weight: 500;
  margin-top: 0.5rem;
}

.short-page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 2.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.short-page-header--slim {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 1.75rem;
  align-items: center;
}

.short-title {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text);
}

.short-page-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.short-page-meta {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.short-link-pill {
  display: inline-block;
  font-family: var(--mono);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--accent);
}

/* ---- Form ---- */

.short-form {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.short-errors {
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1.1rem;
  list-style: none;
  color: #fca5a5;
  font-size: 0.9rem;
}

.short-errors li + li { margin-top: 0.25rem; }

.short-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.short-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.short-input {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.short-input::placeholder {
  color: var(--muted-soft);
  opacity: 0.7;
}

.short-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.18);
}

.short-input--readonly {
  background: var(--bg);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.95rem;
}

.short-input-group {
  display: flex;
  align-items: stretch;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.short-input-group:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.18);
}

.short-input-prefix {
  padding: 0.75rem 0.85rem 0.75rem 1rem;
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
  border-right: 1px solid var(--line);
  white-space: nowrap;
}

.short-input--key {
  border: none !important;
  background: transparent !important;
  border-radius: 0 !important;
  font-family: var(--mono);
  padding-left: 0.85rem;
}

.short-input--key:focus {
  box-shadow: none !important;
}

.short-hint {
  font-size: 0.8rem;
  color: var(--muted-soft);
}

.short-hint:empty { display: none; }

/* ---- Actions ---- */

.short-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding-top: 1rem;
  margin-top: 0.5rem;
}

.short-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
  white-space: nowrap;
}

.short-button:active {
  transform: translateY(1px);
}

.short-button--small {
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
}

.short-button--primary {
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
}

.short-button--primary:hover {
  background: var(--accent);
  filter: brightness(1.1);
  color: var(--bg);
}

.short-button--ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

.short-button--ghost:hover {
  color: var(--text);
  border-color: var(--line-strong);
  background: var(--surface);
}

.short-button--danger:hover {
  color: var(--danger);
  border-color: var(--danger);
}

/* ---- Copy block (show page) ---- */

.short-copy {
  margin: 2rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.short-copy-row {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
}

.short-copy-row .short-input { flex: 1; }

.short-copy-status {
  font-size: 0.8rem;
  color: var(--accent);
  min-height: 1.2em;
}

/* ---- Detail block (show page) ---- */

.short-detail {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.short-target {
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--muted);
  word-break: break-all;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-sm);
}

.short-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.short-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--line);
}

.short-pill--info {
  color: var(--accent-2);
  border-color: rgba(129, 140, 248, 0.3);
}

.short-pill--warn {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.3);
}

/* ---- List (index page) ---- */

.short-list {
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-elev);
}

.short-list-item {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.5fr) auto auto;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  transition: background 0.15s;
}

.short-list-item:last-child { border-bottom: none; }

.short-list-item:hover {
  background: var(--bg-elev-2);
}

.short-list-key {
  font-family: var(--mono);
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: baseline;
  min-width: 0;
}

.short-list-key:hover .short-list-slug { color: var(--text); }

.short-list-host { color: var(--muted); }
.short-list-slug { color: var(--accent); font-weight: 500; }

.short-list-target {
  color: var(--muted);
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.short-list-hits {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.85rem;
  min-width: 3ch;
  text-align: right;
}

.short-list-actions {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

/* New icon-style action buttons inside the list. Keep them small on desktop;
   on mobile they collapse to icon-only via .short-list-action-label. */
.short-list-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
  font-family: inherit;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
}

.short-list-action:hover {
  color: var(--text);
  border-color: var(--line-strong);
  background: var(--surface);
}

.short-list-action--danger:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.short-list-action > [aria-hidden="true"] {
  font-size: 1rem;
  line-height: 1;
}

@media (max-width: 720px) {
  .short-list-item {
    grid-template-columns: 1fr auto;
    grid-template-areas: "key hits" "target actions";
    padding: 0.875rem 1rem;
    gap: 0.5rem 0.75rem;
  }
  .short-list-key    { grid-area: key; font-size: 1rem; }
  .short-list-target { grid-area: target; font-size: 0.78rem; }
  .short-list-hits   { grid-area: hits; }
  .short-list-actions { grid-area: actions; justify-content: flex-end; }

  /* On mobile drop the host prefix — every row has it, it's noise. The slug
     alone is what the user identifies links by. */
  .short-list-host { display: none; }
  .short-list-slug { font-size: 1rem; }

  /* Compact icon-only action buttons */
  .short-list-action {
    padding: 0.45rem 0.55rem;
    min-width: 2.2rem;
  }

  .short-list-action-label { display: none; }
  .short-list-action > [aria-hidden="true"] { font-size: 1.05rem; }
}

/* ---- Empty state ---- */

.short-empty {
  text-align: center;
  padding: 4rem 1rem;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.short-empty p { color: var(--muted); }

/* ---- Pagination ---- */

.short-pagination {
  margin-top: 1.5rem;
  display: flex;
  justify-content: center;
}

.short-pagination a,
.short-pagination span {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
  border-radius: var(--radius-sm);
}

.short-pagination a:hover {
  background: var(--surface);
  color: var(--text);
}

/* ============================================================================
   Settings page fallback
   The /admin/settings page still uses Tailwind components — keep mild
   re-skinning so it doesn't clash with the dark shell.
============================================================================ */

.admin-content {
  font-size: 0.95rem;
}

.admin-content h1 {
  font-size: 1.5rem !important;
  font-weight: 600 !important;
  letter-spacing: -0.02em;
  color: var(--text) !important;
  margin-bottom: 1.5rem;
}

.admin-content [class*="surface"],
.admin-content [class*="bg-white"],
.admin-content [class*="bg-zinc-50"],
.admin-content [class*="bg-zinc-100"] {
  background: var(--bg-elev) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}

.admin-content [class*="rounded-2xl"],
.admin-content [class*="rounded-xl"] {
  border-radius: var(--radius) !important;
}

.admin-content [class*="border-zinc"] { border-color: var(--line) !important; }

.admin-content [class*="text-muted"],
.admin-content [class*="text-zinc-5"],
.admin-content [class*="text-zinc-6"] {
  color: var(--muted) !important;
}

.admin-content input[type="text"],
.admin-content input[type="url"],
.admin-content input[type="email"],
.admin-content input[type="datetime-local"],
.admin-content textarea,
.admin-content select {
  background: var(--bg) !important;
  border: 1px solid var(--line) !important;
  color: var(--text) !important;
  border-radius: var(--radius-sm) !important;
  padding: 0.625rem 0.875rem !important;
  height: auto !important;
}

.admin-content input:focus,
.admin-content textarea:focus {
  border-color: var(--accent) !important;
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.18) !important;
}

.admin-content button[type="submit"] {
  background: var(--accent) !important;
  color: var(--bg) !important;
  border: none !important;
  border-radius: var(--radius-sm) !important;
  padding: 0.65rem 1.25rem !important;
  font-weight: 600 !important;
  display: inline-flex !important;
  align-items: center;
  gap: 0.5rem;
}

.admin-content button[type="submit"] svg {
  width: 14px;
  height: 14px;
  stroke: var(--bg);
}

/* ============================================================================
   MOBILE
   Two breakpoints: tablet-ish (<= 720px) and phone (<= 480px).
   The new-page is the most-used flow, so it gets dedicated phone tuning.
============================================================================ */

@media (max-width: 720px) {
  /* App header collapses to a flex-wrap layout with reduced padding. */
  .app-header {
    padding: 0.75rem 1rem;
    gap: 0.75rem;
    flex-wrap: wrap;
  }

  .app-brand {
    font-size: 0.95rem;
  }

  .app-nav {
    flex: 1 1 auto;
    justify-content: flex-start;
  }

  .app-nav a {
    padding: 0.45rem 0.65rem;
    font-size: 0.85rem;
  }

  .app-main {
    padding: 1.5rem 1rem;
  }

  .app-footer {
    padding: 1.25rem 1rem;
    font-size: 0.72rem;
  }

  /* Fullscreen new-page: tighten the padding so the inputs breathe. */
  .short-page--new {
    padding: 1.5rem 1rem;
  }

  .short-page--new .short-input,
  .short-page--new .short-input--key {
    font-size: 1rem !important;
    padding: 0.85rem 1rem !important;
  }

  .short-page--new .short-input-prefix {
    font-size: 0.9rem;
    padding: 0.85rem 0.65rem 0.85rem 1rem;
  }

  .short-page--new .short-form { gap: 1.5rem; }

  /* Show page: stack the copy row so all three buttons fit. */
  .short-copy-row {
    flex-direction: column;
    align-items: stretch;
  }

  .short-copy-row .short-button {
    width: 100%;
  }

  /* List items stack already (via the 720px rule above). */
  .short-list-item {
    padding: 0.875rem 1rem;
  }

  .short-page-header {
    margin-bottom: 1.5rem;
  }

  .short-title { font-size: 1.25rem; }
}

@media (max-width: 480px) {
  /* On phone widths, the user email crowds the layout. Hide it; the logout
     button is what people actually need. */
  .app-user .bvg-user-menu__email {
    display: none;
  }

  .app-user .bvg-user-menu__logout button {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
  }

  /* Brand keeps the logo — its job is to signal which domain you're on. */
  .app-header {
    gap: 0.5rem;
  }

  .app-brand .brand-logo {
    width: 24px;
    height: 24px;
  }

  /* Slug input + prefix: stop the prefix from squeezing the input on narrow
     screens by allowing it to wrap above. */
  .short-page--new .short-input-group {
    flex-direction: column;
    align-items: stretch;
  }

  .short-page--new .short-input-prefix {
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 0.6rem 1rem 0.5rem;
    text-align: left;
  }

  .short-page--new .short-input--key {
    padding-left: 1rem !important;
  }

  /* List: shrink fonts so it stays readable without horizontal scroll. */
  .short-list-key { font-size: 0.85rem; }
  .short-list-target { font-size: 0.75rem; }
  .short-list-actions .short-button { padding: 0.3rem 0.55rem; font-size: 0.75rem; }

  .empty-card { padding: 2rem 1.25rem; }
}

/* Prevent iOS Safari from auto-zooming on input focus by guaranteeing 16px+
   font-size on the input, which we already do on phone (16px = 1rem). */
