/*
 * gogogpt.net portal shared styles.
 *
 * Design principles:
 *   - Light, clean, modern. No emoji anywhere (strict project rule).
 *   - Single accent color, generous whitespace, 580px max content width for
 *     auth forms, 960px for dashboard/landing.
 *   - Mobile-first, single font stack, minimal dependencies.
 *   - Canonical stylesheet for all portal pages.
 */

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --border: #e7e7e9;
  --border-strong: #d4d4d6;
  --text: #111216;
  --text-muted: #6b6f76;
  --text-dim: #9ca0a6;
  --accent: #0f172a;
  --accent-hover: #1e293b;
  --danger: #d84040;
  --warning: #c48200;
  --success: #147a36;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.06), 0 2px 4px rgba(16, 24, 40, 0.04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.55;
}

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

button {
  font: inherit;
  cursor: pointer;
  background: none;
  border: none;
  color: inherit;
}

input, textarea, select {
  font: inherit;
  color: inherit;
}

/* ---- top brand bar ---------------------------------------------------- */

.topbar {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.5px;
  color: var(--text);
}

.brand em {
  font-style: normal;
  color: var(--text-muted);
  font-weight: 500;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 14px;
}

.topbar-nav a { color: var(--text-muted); }
.topbar-nav a:hover { color: var(--text); text-decoration: none; }

/* ---- page layout ------------------------------------------------------ */

.page {
  padding: 48px 24px;
  min-height: calc(100vh - 56px);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.container-narrow {
  width: 100%;
  max-width: 420px;
}

.container-wide {
  width: 100%;
  max-width: 960px;
}

.page-title {
  font-size: 26px;
  font-weight: 700;
  margin: 0 0 6px;
  letter-spacing: -0.2px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 28px;
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 28px 24px;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 16px;
}

.card + .card { margin-top: 16px; }

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

.field { margin-bottom: 16px; }

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field-input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: #fff;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

.field-input::placeholder { color: var(--text-dim); }

.field-help {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.field-error {
  display: none;
  margin-top: 6px;
  color: var(--danger);
  font-size: 13px;
}

.field-error.visible { display: block; }

/* ---- otp slots -------------------------------------------------------- */

.otp-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  padding: 10px 0 6px;
}
.otp-slot {
  width: 44px;
  height: 56px;
  border: none;
  border-bottom: 2px solid var(--border-strong);
  background: transparent;
  font-family: inherit;
  font-size: 30px;
  font-weight: 500;
  text-align: center;
  color: var(--accent);
  padding: 0;
  outline: none;
  transition: border-color 0.2s ease, transform 0.12s ease;
}
.otp-slot::-webkit-outer-spin-button,
.otp-slot::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.otp-slot:focus {
  border-bottom-color: var(--accent);
}
.otp-slot.filled {
  border-bottom-color: var(--accent);
  animation: otp-pop 0.22s cubic-bezier(.2,.9,.3,1.2);
}
.otp-slot.shake {
  animation: otp-shake 0.32s ease;
}
@keyframes otp-pop {
  0%   { transform: translateY(6px) scale(0.85); opacity: 0.2; }
  60%  { transform: translateY(-1px) scale(1.05); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes otp-shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-4px); }
  75%      { transform: translateX(4px); }
}

a.link-disabled {
  pointer-events: none;
  color: var(--text-dim);
  cursor: default;
}

/* ---- buttons ---------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  padding: 0 20px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 14px;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border-strong);
  width: 100%;
}

.btn-secondary:hover { background: #f3f4f6; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 0 8px;
}

.btn-ghost:hover { color: var(--text); }

.btn[disabled],
.btn.loading {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-row {
  display: flex;
  gap: 12px;
}

/* ---- divider with text ------------------------------------------------ */

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-dim);
  font-size: 12px;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ---- alerts ----------------------------------------------------------- */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.alert-info {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
}

.alert-warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

.alert-danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--danger);
}

.alert-success {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: var(--success);
}

/* ---- footer links under card ----------------------------------------- */

.below-card {
  margin-top: 18px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.below-card a { color: var(--text); font-weight: 500; }

/* ---- dashboard specific ---------------------------------------------- */

.dash-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

@media (max-width: 720px) {
  .dash-grid { grid-template-columns: 1fr; }
}

.entitlement-panel {
  padding: 32px 28px;
}

.entitlement-tier {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  background: #f1f5f9;
  color: var(--text-muted);
}

.entitlement-tier.tier-free { background: #f1f5f9; color: #475569; }
.entitlement-tier.tier-basic { background: #dbeafe; color: #1e3a8a; }
.entitlement-tier.tier-plus { background: #fef3c7; color: #854d0e; }

.usage-number {
  font-size: 42px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin: 12px 0 2px;
}

.usage-total {
  font-size: 16px;
  color: var(--text-muted);
  font-weight: 500;
}

.usage-bar {
  height: 8px;
  background: #f1f5f9;
  border-radius: 999px;
  overflow: hidden;
  margin: 20px 0 12px;
}

.usage-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.3s;
}

.usage-reset {
  font-size: 12px;
  color: var(--text-muted);
}

.start-chat-btn {
  margin-top: 24px;
  width: 100%;
  height: 48px;
  font-size: 15px;
}

.dash-user {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.dash-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #e5e7eb;
  overflow: hidden;
  flex-shrink: 0;
}

.dash-avatar img { width: 100%; height: 100%; object-fit: cover; }

.dash-user-email {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
  word-break: break-all;
}

.dash-user-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---- legal static pages ---------------------------------------------- */

.legal-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 24px 64px;
}

.legal-page h1 {
  font-size: 26px;
  margin-bottom: 24px;
}

.legal-page h2 {
  font-size: 17px;
  margin-top: 28px;
  margin-bottom: 10px;
}

.legal-page p, .legal-page li {
  color: #333;
  font-size: 14px;
  line-height: 1.8;
}

.legal-updated {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 24px;
}

/* ---- spinner --------------------------------------------------------- */

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

.btn-secondary .spinner {
  border-color: rgba(15, 23, 42, 0.3);
  border-top-color: var(--accent);
}

@keyframes spin { to { transform: rotate(360deg); } }
