/*
 * ShareWiFiQR Portal: global styles.
 * Tokens and shared components recreated from the source app (see DESIGN.md).
 */

:root {
  --ink: #211d35;
  --muted: #6d6a80;
  --border: #e9e7f0;
  --canvas: #f8f8fc;
  --purple: #654ce0;
  --purple-dark: #533dc4;
  --white: #fff;
  /* stylelint-disable-next-line value-keyword-case -- the source's exact stack */
  --body-font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --gutter: clamp(18px, 4vw, 48px);

  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  display: none;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--body-font-family);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

body.appear {
  display: grid;
  grid-template-columns: 238px minmax(0, 1fr);
  grid-template-rows: auto auto 1fr auto;
  min-height: 100dvh;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button {
  color: inherit;
}

a {
  color: inherit;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(29px, 4vw, 37px);
  letter-spacing: -0.045em;
  line-height: 1.15;
}

h2 {
  font-size: 17px;
  letter-spacing: -0.025em;
  line-height: 1.35;
}

p {
  color: var(--muted);
  line-height: 1.55;
}

small {
  display: block;
}

[hidden] {
  display: none !important;
}

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

/* ---- shell placement: header (sidebar + topbar), main, footer ---- */

/* <header> is the top bar (column 2); the header block mounts the sidebar, fixed over column 1 */
header {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  background: #fff;
}

main {
  grid-column: 2;
  grid-row: 3;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 35px var(--gutter) 30px;
}

footer {
  grid-column: 2;
  grid-row: 4;
  margin: 0 var(--gutter);
}

header .header,
footer .footer {
  visibility: hidden;
}

header .header[data-block-status="loaded"],
footer .footer[data-block-status="loaded"] {
  visibility: visible;
}

/* ---- session check: only the status shows until the API confirms the session ---- */

body.session-pending.appear {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  place-items: center;
}

body.session-pending > :not(.session-status) {
  display: none !important;
}

.session-status {
  padding: 24px var(--gutter);
  font-size: 15px;
  text-align: center;
}

/* ---- entry template: the signed-out home page, without the app shell ---- */

body.entry.appear {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}

body.entry header,
body.entry footer {
  display: none;
}

body.entry main {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  align-content: center;
  max-width: none;
  padding: 64px var(--gutter);
}

main > .section > div + div {
  margin-top: 0;
}

/* ---- shared components ---- */

.icon {
  display: inline-block;
  height: 18px;
  width: 18px;
}

.icon img {
  height: 100%;
  width: 100%;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border-radius: 8px;
  padding: 8px 13px;
  font-weight: 680;
  white-space: nowrap;
  text-decoration: none;
  border: 1px solid transparent;
  line-height: 1.35;
}

.button.primary {
  background: var(--purple);
  color: white;
  border-color: var(--purple);
  box-shadow: 0 2px 4px #4a33af23;
}

.button.primary:hover {
  background: var(--purple-dark);
}

.button.secondary {
  background: #fff;
  border-color: #e4e1ed;
  color: #403951;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 0;
}

.button.secondary:hover,
.icon-button:hover {
  background: #f5f2fe;
  color: var(--purple-dark);
}

.card {
  border: 1px solid var(--border);
  border-radius: 13px;
  background: white;
  box-shadow: 0 2px 4px #27214b04;
}

.card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-heading p {
  font-size: 13px;
  margin-top: 3px;
}

.avatar,
.tile {
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 11px;
  font-weight: 750;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 12px;
  letter-spacing: 0.02em;
}

.tile {
  width: 40px;
  height: 40px;
}

.violet {
  background: #eee9ff;
  color: #6247d5;
}

.blue {
  background: #e8efff;
  color: #4667d7;
}

.mint {
  background: #e3f6ef;
  color: #247e65;
}

.peach {
  background: #fff0e5;
  color: #a55b26;
}

.rose {
  background: #fbe9f0;
  color: #a3446c;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 9px;
  background: #e9f8f0;
  color: #237755;
}

.badge i {
  width: 6px;
  height: 6px;
  background: currentcolor;
  border-radius: 50%;
}

.muted-badge {
  background: #f4edf0;
  color: #79536a;
}

.identity {
  display: flex;
  gap: 11px;
  align-items: center;
}

.identity small {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.identity .tile {
  width: 35px;
  height: 35px;
  border-radius: 9px;
}

/* tables */
.table-card {
  overflow: hidden;
}

.table-card .card-heading {
  padding: 18px 21px 16px;
  align-items: center;
}

.table-scroll {
  position: relative; /* contains the .sr-only header label (R-05) */
  overflow: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
  text-align: left;
  white-space: nowrap;
}

th,
td {
  padding: 12px 17px;
}

th {
  background: #faf9fd;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: #655f77;
  font-weight: 700;
}

td {
  border-bottom: 1px solid #f0eef5;
  color: #615b73;
  font-size: 13px;
}

th:first-child,
td:first-child {
  padding-left: 21px;
}

tr:last-child td {
  border-bottom: 0;
}

tr:has(.table-name) {
  cursor: pointer;
}

tr:has(.table-name):hover td {
  background: #fbfaff;
}

.numeric {
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  font-weight: 650;
}

.table-name {
  text-decoration: none;
  font-weight: 700;
  color: var(--ink);
  text-align: left;
}

.table-name:hover,
.back:hover {
  color: var(--purple);
  text-decoration: underline;
}

/* forms */
form {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

form label {
  display: grid;
  gap: 6px;
  color: #434057;
  font-weight: 650;
}

input,
form select {
  width: 100%;
  min-width: 0;
  border: 1px solid #e1deeb;
  border-radius: 8px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid #7963eb;
  outline-offset: 3px;
}

form > .button {
  justify-self: start;
}

.password-field {
  display: flex;
  align-items: center;
  position: relative;
}

.password-field input {
  padding-right: 43px;
}

.password-field button {
  position: absolute;
  right: 4px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 5px;
}

.empty {
  text-align: center;
  padding: 38px 18px;
  color: var(--muted);
}

.empty h1,
.empty h3,
.empty p,
.empty .button {
  margin-top: 8px;
}

.date-filters {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 21px 16px;
}

.date-filters label {
  display: grid;
  gap: 5px;
  font-size: 12px;
  font-weight: 650;
  color: #59546d;
}

.date-filters input {
  min-height: 38px;
}

/* stat cards (shared by the stats block) */
.stat {
  padding: 17px 19px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
}

.stat .tile {
  margin-bottom: 5px;
}

.stat-label {
  color: #59546d;
  font-size: 13px;
  font-weight: 600;
}

.stat strong {
  font-size: 29px;
  font-weight: 760;
  letter-spacing: -0.045em;
  line-height: 1.1;
}

.stat small {
  color: var(--muted);
  font-size: 12px;
}

.stat .badge {
  margin-left: 5px;
}

.stat .button {
  margin-top: 5px;
}

/* dialog + toast */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 5;
  background: #20163565;
  display: grid;
  place-items: center;
  padding: 16px;
}

.dialog {
  width: min(100%, 470px);
  max-height: 95dvh;
  overflow: auto;
  padding: 22px;
  box-shadow: 0 15px 80px #1c123245;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 6px 13px;
  background: #29213e;
  color: #fff;
  border-radius: 9px;
  box-shadow: 0 4px 16px #24153744;
}

.toast .icon-button {
  color: #fff;
}

@media (width <= 900px) {
  body.appear {
    grid-template-columns: 185px minmax(0, 1fr);
  }

  main {
    padding-inline: 22px;
  }
}

@media (width <= 700px) {
  /* one column: the workspace fills the viewport and the footer sits at its foot, like the source */
  body.appear {
    display: flex;
    flex-direction: column;
  }


  footer {
    margin-inline: 14px;
  }

  main {
    flex: 1;
    overflow-x: clip; /* source content that runs past 360px stays off the page scroll (R-06) */
    padding: 23px 14px;
  }

  .stat {
    padding: 11px 10px;
  }

  .stat-label {
    font-size: 12px;
  }

  .stat strong {
    font-size: 24px;
  }

  .stat small {
    font-size: 11px;
  }

  .card-heading,
  .table-card .card-heading {
    padding-inline: 13px;
  }

  .date-filters {
    padding-inline: 13px;
  }
}

/* ---- authored screens (help, terms, privacy): default content ---- */

main .section.content-card > .default-content-wrapper {
  max-width: 760px;
  padding: 23px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: white;
  box-shadow: 0 2px 4px #27214b04;
}

main > .section:first-child > .default-content-wrapper:first-child {
  margin-bottom: 24px;
}

main > .section:first-child > .default-content-wrapper:first-child h1 + p {
  margin-top: 7px;
}

main .section.content-card h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

main .section.content-card p + h2 {
  border-top: 1px solid var(--border);
  margin-top: 19px;
  padding-top: 19px;
}
