/*
Copyright (C) 2023-2026 QuantumNous

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.

For commercial licensing, please contact support@quantumnous.com
*/

/* Hand-written CSS: the site has no build step, so no Tailwind pipeline. */

:root {
  --background: #f6f7f9;
  --surface: #ffffff;
  --surface-muted: #f2f4f7;
  --border: #e3e6ea;
  --foreground: #14181f;
  --muted: #6b7480;
  --primary: #2563eb;
  --primary-foreground: #ffffff;
  --primary-soft: rgba(37, 99, 235, 0.1);
  --destructive: #c0392b;
  --destructive-soft: rgba(192, 57, 43, 0.06);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #0e1116;
    --surface: #161a21;
    --surface-muted: #1c2129;
    --border: #2a3039;
    --foreground: #e8eaee;
    --muted: #98a1ad;
    --primary: #5b8cff;
    --primary-foreground: #0b0e13;
    --primary-soft: rgba(91, 140, 255, 0.16);
    --destructive: #ff7b6b;
    --destructive-soft: rgba(255, 123, 107, 0.1);
  }
}

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

/* Sections are toggled with the `hidden` attribute. Display rules further down
   (`.note`, `.card`, ...) would otherwise win over the UA's `[hidden]` rule and
   leave a section on screen - the macOS-only hint did exactly that. */
[hidden] {
  display: none !important;
}

/* Inline icons are sized here rather than per-container: an unsized SVG with a
   viewBox stretches to the full width of its box. */
svg.icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.page {
  min-height: 100svh;
  padding: 32px 12px 48px;
}

.shell {
  margin: 0 auto;
  width: 100%;
  max-width: 768px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---------- masthead ---------- */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand-sub {
  margin-left: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 400;
}

.language-select {
  background: var(--surface);
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 8px;
  font: inherit;
  font-size: 13px;
}

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.card-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.icon-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-bottom: 4px;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
}

.icon-badge svg {
  width: 20px;
  height: 20px;
}

/* ---------- form controls ---------- */

.label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
}

.input {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--foreground);
  font: inherit;
  font-size: 14px;
}

.input:focus-visible,
.button:focus-visible,
.tab:focus-visible,
.language-select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: var(--surface-muted);
  color: var(--foreground);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.button.small {
  padding: 6px 11px;
  font-size: 13px;
}

.button.primary {
  background: var(--primary);
  color: var(--primary-foreground);
}

.button.outline {
  background: transparent;
  border-color: var(--border);
}

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

.button.full {
  width: 100%;
  margin-top: 4px;
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.button .icon {
  width: 16px;
  height: 16px;
}

/* ---------- layout helpers ---------- */

.stack {
  display: flex;
  flex-direction: column;
}

.row {
  display: flex;
  align-items: center;
}

.column {
  flex-direction: column;
}

.between {
  justify-content: space-between;
}

.wrap {
  flex-wrap: wrap;
}

.center {
  align-items: center;
  justify-content: center;
  text-align: center;
}

.gap-2 {
  gap: 8px;
}

.grow {
  flex: 1 1 auto;
}

.min-w-0 {
  min-width: 0;
}

.shrink {
  flex: 0 0 auto;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.break {
  word-break: break-all;
}

.small {
  font-size: 12.5px;
}

.muted {
  color: var(--muted);
}

.strong {
  font-weight: 600;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- messages ---------- */

.error {
  margin: 2px 0 0;
  color: var(--destructive);
  font-size: 13.5px;
}

.warning {
  margin: 0;
  padding: 9px 12px;
  border: 1px solid color-mix(in srgb, var(--destructive) 40%, transparent);
  border-radius: 9px;
  background: var(--destructive-soft);
  color: var(--destructive);
  font-size: 13.5px;
}

.note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 16px;
  padding: 11px 12px;
  border-radius: 9px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.note p {
  margin: 0;
}

.note.column {
  flex-direction: column;
  align-items: stretch;
  margin-top: 0;
}

.note .icon {
  margin-top: 2px;
}

.note.column .icon {
  margin-top: 0;
}

/* ---------- quota ---------- */

.quota-grid {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.quota-cell {
  padding: 12px;
  border-radius: 9px;
  background: var(--surface-muted);
}

.quota-cell dt {
  margin: 0;
}

.quota-cell dd {
  margin: 4px 0 0;
  font-size: 15px;
}

/* ---------- tabs ---------- */

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: var(--surface-muted);
}

.tab {
  padding: 7px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.tab.is-active {
  background: var(--surface);
  color: var(--foreground);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

.panel {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-muted);
}

.panel p {
  margin: 0;
}

/* ---------- model table ---------- */

.table {
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
}

.table-head,
.table-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 60px 60px 68px;
  align-items: center;
  gap: 4px;
  padding: 10px 12px;
}

.table-head {
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
}

.table-body {
  max-height: 320px;
  overflow-y: auto;
}

.table-row + .table-row {
  border-top: 1px solid var(--border);
}

.table-row .model-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 13px;
}

.table-row input[type='checkbox'] {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  accent-color: var(--primary);
}

.capability {
  display: flex;
  justify-content: center;
}

.capability .icon {
  width: 16px;
  height: 16px;
}

.capability .icon.yes {
  color: var(--primary);
}

.capability .icon.no {
  color: var(--muted);
}

.empty {
  margin: 0;
  padding: 32px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

@media (min-width: 640px) {
  .quota-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .card-body {
    padding: 24px;
  }

  .table-head,
  .table-row {
    grid-template-columns: minmax(0, 1fr) 92px 92px 100px;
    gap: 8px;
  }
}

/* ---------- endpoint, actions, callout ---------- */

.endpoint {
  display: grid;
  gap: 10px;
}

.endpoint p {
  margin: 0 0 4px;
}

@media (min-width: 640px) {
  .endpoint {
    grid-template-columns: minmax(0, 1fr) 220px;
    align-items: end;
  }
}

.actions {
  display: grid;
  gap: 8px;
}

@media (min-width: 640px) {
  .actions {
    grid-template-columns: 1fr 1fr;
  }
}

.callout {
  padding: 14px 16px;
  border-left: 4px solid var(--primary);
  border-radius: 9px;
  background: var(--surface-muted);
  font-size: 13.5px;
}

.callout > p {
  margin: 0;
}

.steps {
  margin: 8px 0 0;
  padding-left: 20px;
}

.steps li + li {
  margin-top: 6px;
}

.callout > p.small {
  margin-top: 12px;
}

.manual {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.manual p + p {
  margin-top: 4px;
}

/* ---------- support ---------- */

.qr {
  width: 160px;
  height: 160px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 8px;
}

#qs-key-suffix {
  margin: 0;
  letter-spacing: 0.08em;
}

.footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 8px;
}

.footer p {
  margin: 0;
}
