/* superpfeif components — built on the tokens in tokens.css. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-ui);
  background: var(--bg-body);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom));
}

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

/* ---- Top bar ---------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  color: var(--nav-text);
  padding: 0.75rem 1rem;
  padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.topbar .brand {
  font-weight: 800;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
  min-width: 0;
}
.topbar-signout { display: inline-flex; margin: 0; }
.topbar .online-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--green); display: inline-block;
  box-shadow: 0 0 0 3px rgba(88, 204, 2, 0.25);
}

/* ---- Layout ----------------------------------------------------------- */
.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.25rem 1rem;
}
.page-title {
  font-weight: 800;
  font-size: 1.6rem;
  margin: 0.25rem 0 1.25rem;
}

/* ---- Cards ------------------------------------------------------------ */
.card {
  background: var(--bg-card);
  border: 2px solid var(--border-soft);
  border-radius: var(--radius-card);
  padding: 1.25rem;
}

/* ---- Site tiles ------------------------------------------------------- */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
}
.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--bg-card);
  border: 2px solid var(--border-soft);
  border-radius: var(--radius-card);
  padding: 1.5rem 1rem;
  min-height: 130px;
  color: var(--text);
  font-weight: 700;
  transition: transform var(--bounce-duration) var(--bounce-easing),
    box-shadow 0.15s ease;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-soft); }
.tile:active { transform: translateY(0); }
.tile .icon { font-size: 2.4rem; line-height: 1; }
.tile .label { font-size: 1rem; }

/* ---- Buttons (chunky 3D, Duolingo press-in) --------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-min);
  padding: 0.65rem 1.25rem;
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 1rem;
  color: var(--primary-text, #10210b);
  background: var(--green);
  border: none;
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-raised);
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.1s ease;
  width: 100%;
}
.btn:hover { filter: brightness(1.03); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--green-edge); }
.btn-secondary {
  background: var(--bg-input);
  color: var(--text);
  box-shadow: 0 4px 0 var(--edge-neutral);
}
.btn-secondary:active { box-shadow: 0 1px 0 var(--edge-neutral); }
.btn-danger {
  background: var(--red);
  color: #2b0808;
  box-shadow: 0 4px 0 var(--red-edge);
}
.btn-ghost {
  background: transparent; color: var(--nav-text);
  box-shadow: none; width: auto; min-height: auto; padding: 0.4rem 0.6rem;
}

/* ---- Forms ------------------------------------------------------------ */
.field { margin-bottom: 1rem; }
.field label {
  display: block; font-weight: 700; margin-bottom: 0.35rem; font-size: 0.95rem;
}
.field input {
  width: 100%;
  min-height: var(--touch-min);
  font-size: 16px;            /* prevents iOS zoom on focus */
  padding: 0.6rem 0.8rem;
  background: var(--bg-input);
  color: var(--text);
  border: 2px solid var(--border-soft);
  border-radius: var(--radius-control);
}
.field input:focus { outline: none; border-color: var(--blue); }

/* ---- Auth screens ----------------------------------------------------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.auth-card { width: 100%; max-width: 380px; }
.auth-logo {
  text-align: center; font-size: 2.5rem; margin-bottom: 0.5rem;
}
.auth-title { text-align: center; font-weight: 800; margin: 0 0 1.25rem; }
.auth-alt { text-align: center; margin-top: 1rem; font-size: 0.9rem; }

/* Forced-password-change page: visually distinct from the login card so a
   reset never reads as "stuck on the sign-in screen". */
.auth-card-reset { border-left: 4px solid var(--green, #58cc02); }
.auth-note {
  background: color-mix(in srgb, var(--green, #58cc02) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--green, #58cc02) 38%, transparent);
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
  margin-bottom: 1.1rem;
  font-size: 0.9rem;
  line-height: 1.4;
  text-align: left;
}
.auth-hint { font-size: 0.82rem; opacity: 0.7; margin: 0.1rem 0 0.9rem; }

/* Live password strength meter */
.pw-meter { margin: 0.45rem 0 0.2rem; }
.pw-meter-bar {
  height: 6px;
  border-radius: 3px;
  background: rgba(128, 128, 128, 0.25);
  overflow: hidden;
}
.pw-meter-bar span {
  display: block;
  height: 100%;
  width: 0;
  transition: width 0.2s ease, background 0.2s ease;
}
.pw-meter-label { font-size: 0.78rem; font-weight: 700; }

/* Requestable-app checkboxes on the signup page */
.app-choice {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.35rem 0;
  font-size: 0.95rem;
  cursor: pointer;
}
.app-choice input { width: auto; margin: 0; }

/* ---- Flash messages --------------------------------------------------- */
.flashes { margin-bottom: 1rem; }
.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-control);
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.flash-success { background: rgba(88, 204, 2, 0.15); color: var(--green-text); }
.flash-danger { background: rgba(255, 75, 75, 0.15); color: var(--red); }
.flash-warning { background: rgba(255, 200, 0, 0.18); color: var(--gold); }

/* ---- Bottom navigation (mobile) -------------------------------------- */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--bottom-nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg-card);
  border-top: 2px solid var(--border-soft);
  display: flex;
  z-index: 90;
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
}
.bottom-nav a.active { color: var(--green-text); }
.bottom-nav .ico { font-size: 1.4rem; }

@media (min-width: 992px) {
  .bottom-nav { display: none; }
  body { padding-bottom: 2rem; }
}

@media (max-width: 991.98px) {
  .topbar { gap: 0.75rem; }
  .topbar-secondary { display: none !important; }
  .topbar-signout .btn {
    min-height: var(--touch-min);
    padding: 0.45rem 0.65rem;
    white-space: nowrap;
  }
}

/* ---- Theme toggle ----------------------------------------------------- */
.theme-toggle {
  background: rgba(255, 255, 255, 0.18);
  border: none;
  color: var(--nav-text);
  border-radius: 999px;
  width: 40px; height: 40px;
  font-size: 1.1rem;
  cursor: pointer;
}

/* ---- Help ------------------------------------------------------------- */
.help-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: var(--nav-text);
  font-weight: 800;
  font-size: 1.1rem;
  text-decoration: none;
  margin-right: 0.35rem;
}
.help-card { margin-bottom: 1rem; }
.help-card h2 { font-size: 1.1rem; font-weight: 800; margin: 0 0 0.5rem; }
.help-card ul { margin: 0; padding-left: 1.2rem; }
.help-card li { margin-bottom: 0.35rem; }
.help-back { margin-top: 1rem; }

/* ---- Empty state + error ---------------------------------------------- */
.empty-state { text-align: center; padding: 2.5rem 1.5rem; }
.empty-state .empty-emoji { font-size: 3rem; line-height: 1; margin-bottom: 0.5rem; }
.empty-state h2 { font-weight: 800; margin: 0 0 0.5rem; }
.empty-state p { color: var(--text-muted); max-width: 38ch; margin: 0 auto 1.25rem; }
.empty-state .btn { width: auto; padding-left: 1.5rem; padding-right: 1.5rem; }
.error-message { color: var(--text-muted); margin: 0 0 1.25rem; }

/* ---- Admin UI --------------------------------------------------------- */
.admin-note { color: var(--text-muted); max-width: 60ch; margin: -0.5rem 0 1.25rem; }
.admin-user { margin-bottom: 1rem; }
.admin-user-head { margin-bottom: 0.6rem; }
.admin-username { font-weight: 800; font-size: 1.1rem; }
.admin-row { display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem; margin: 0.4rem 0; }
.admin-label { display: inline-block; min-width: 5.5rem; font-weight: 700; color: var(--text-muted); }
.visible-pw {
  min-width: 0; max-width: 100%; overflow-wrap: anywhere;
  background: var(--bg-input); padding: 0.2rem 0.5rem;
  border-radius: 6px; font-family: var(--font-mono);
}
.admin-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.admin-actions .btn { width: auto; padding: 0.5rem 0.9rem; min-height: 40px; }
.admin-actions input[type=text] {
  min-height: 40px; padding: 0.4rem 0.7rem; font-size: 16px;
  background: var(--bg-input); color: var(--text);
  border: 2px solid var(--border-soft); border-radius: var(--radius-control);
}
.inline-form { display: inline-flex; gap: 0.4rem; margin: 0; }
@media (max-width: 640px) {
  .admin-actions { display: grid; grid-template-columns: minmax(0, 1fr); }
  .admin-actions .inline-form { display: flex; flex-wrap: wrap; width: 100%; min-width: 0; }
  .admin-actions input[type=text] { flex: 1 1 100%; width: 100%; min-width: 0; }
  .admin-actions .btn { width: 100%; }
}
.abadge { font-size: 0.72rem; font-weight: 800; padding: 0.1rem 0.5rem; border-radius: 999px; margin-left: 0.3rem; }
.abadge-admin { background: var(--green); color: var(--green-ink, #10210b); }
.abadge-approved { background: rgba(88,204,2,0.18); color: var(--green-text); }
.abadge-pending { background: rgba(255,200,0,0.2); color: var(--gold); }
.abadge-rejected, .abadge-off { background: rgba(255,75,75,0.18); color: var(--red); }
.abadge-warn { background: rgba(255,200,0,0.2); color: var(--gold); }
.chip { border: 2px solid var(--border-soft); border-radius: 999px; padding: 0.2rem 0.7rem; font-weight: 700; cursor: pointer; font-size: 0.85rem; }
.chip-on { background: var(--green); color: var(--green-ink, #10210b); border-color: var(--green); }
.chip-off { background: transparent; color: var(--text-muted); }
.admin-email { font-size: 0.85rem; }

/* ---- Admin toolbar: search + status/role + per-app filters ------------ */
.admin-toolbar { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1.25rem; }
.admin-search {
  width: 100%; min-height: 44px; padding: 0.5rem 0.8rem; font-size: 16px;
  background: var(--bg-input); color: var(--text);
  border: 2px solid var(--border-soft); border-radius: var(--radius-control);
}
.admin-filter { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.filter-chip {
  border: 2px solid var(--border-soft); border-radius: 999px;
  padding: 0.3rem 0.8rem; font-weight: 700; font-size: 0.85rem; cursor: pointer;
  background: transparent; color: var(--text-muted); min-height: 36px;
}
.filter-chip-on { background: var(--green); color: var(--green-ink, #10210b); border-color: var(--green); }
.filter-count {
  display: inline-block; margin-left: 0.3rem; padding: 0 0.4rem;
  border-radius: 999px; font-size: 0.72rem; background: rgba(0, 0, 0, 0.15);
}
.filter-chip-on .filter-count { background: rgba(255, 255, 255, 0.25); }
.admin-empty { color: var(--text-muted); text-align: center; padding: 2rem 0; }
/* A filtered-out card must hide even though .card sets its own display. */
.admin-user[hidden] { display: none; }

/* ---- Accessibility: visible keyboard focus ---------------------------- */
.btn:focus-visible,
.field input:focus-visible,
.tile:focus-visible,
.help-link:focus-visible,
.theme-toggle:focus-visible,
.bottom-nav a:focus-visible,
a:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

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