@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --color-bg: #f4f6fb;
  --color-surface: #ffffff;
  --color-text: #1a1d23;
  --color-muted: #6b7280;
  --color-border: #e5e8f0;

  /* nex2link brand */
  --color-primary: #2554a6;
  --color-primary-hover: #1c4488;
  --color-primary-light: #eaf0fb;
  --color-accent: #fcb036;
  --color-accent-hover: #e89b1f;
  --color-accent-light: #fef3e0;

  --color-danger: #dc2626;
  --color-danger-light: #fee2e2;

  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(20, 30, 60, 0.06);
  --shadow-md: 0 4px 16px rgba(20, 30, 60, 0.08);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: 'Poppins', var(--font);

  /* app shell */
  --sidebar-width: 72px;
  --sidebar-width-expanded: 220px;
  --color-page-bg: var(--color-bg);

  /* avatar palette — decorative variety only, not brand tokens */
  --avatar-hue-1: var(--color-primary);
  --avatar-hue-2: var(--color-accent);
  --avatar-hue-3: #0d9488;
  --avatar-hue-4: #7c3aed;
  --avatar-hue-5: #db2777;
  --avatar-hue-6: #16a34a;
  --avatar-hue-7: #ea580c;
  --avatar-hue-8: #0891b2;
}

* { box-sizing: border-box; }

/* Stops iOS Safari inflating text in wide blocks when the phone is rotated. */
html { -webkit-text-size-adjust: 100%; }

/* Auth guard: page content stays hidden until requireAuthOrRedirect() confirms
   a valid session (or navigates away). Fails closed if JS errors/is blocked. */
html.auth-pending body { display: none; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
}

h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.01em; }

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

/* Every :hover in this app is gated on a real pointer. On a touchscreen the
   hovered state latches after a tap and stays lit until you tap something else,
   which reads as "the row/button is stuck selected". */
@media (hover: hover) {
  a:hover { text-decoration: underline; }
}

.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 28px 24px 48px;
}

/* Authenticated app shell: sidebar (prepended by renderNavbar) + content pane.
   The existing .container in every authenticated page becomes the content
   pane purely via this rule — no page markup/JS needs to move. */
body.app-shell {
  margin: 0;
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--color-page-bg);
}
body.app-shell > .container {
  flex: 1;
  min-width: 0;
  max-width: none;
  margin: 0;
  padding: 28px 32px 48px;
  overflow-x: hidden;
}

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

.centered-screen {
  min-height: 100vh;
  min-height: 100dvh; /* mobile browser chrome shrinks/grows the viewport as you scroll */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background:
    radial-gradient(circle at 15% 15%, rgba(37, 84, 166, 0.10), transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(252, 176, 54, 0.14), transparent 45%),
    var(--color-bg);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
}

.form-field label { font-size: 13px; font-weight: 600; color: var(--color-muted); }

input, select, textarea {
  font-family: var(--font);
  font-size: 14px;
  padding: 9px 11px;
  border: 1px solid var(--color-border);
  border-radius: 7px;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* File inputs render an OS-native "Choose File" button + filename label whose
   width ignores the parent container — cap it so it can't push a card wider
   than itself, especially on narrow screens. */
input[type="file"] { max-width: 100%; padding: 6px; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

button, .btn {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 7px;
  border: 1px solid var(--color-primary);
  background: var(--color-primary);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

/* :active still fires on touch, so a tap keeps its press feedback. */
button:active, .btn:active { transform: translateY(1px); }

/* .btn is for the <a> that has to sit in a row of buttons (a link out to a deal
   beside a real action). An anchor is an inline box with an underline, so it
   otherwise sits at the wrong height and is the one item in the row that looks
   like a link. */
a.btn { display: inline-block; text-decoration: none; }

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

button.accent {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #1a1d23;
}

button.danger {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: #fff;
}

@media (hover: hover) {
  button:hover, .btn:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }
  button.secondary:hover { background: var(--color-bg); border-color: var(--color-border); }
  button.accent:hover { background: var(--color-accent-hover); border-color: var(--color-accent-hover); }
  button.danger:hover { background: #b91c1c; border-color: #b91c1c; }
}

.error-text { color: var(--color-danger); font-size: 13px; min-height: 18px; }

.muted { color: var(--color-muted); font-size: 13px; }

/* ---------- mobile (<=640px) ----------
   Plain element rules live here rather than in components.css because the login
   and accept-invite pages load only this stylesheet — they're the first screens
   a phone ever sees, so they can't be the two that miss out. Component-specific
   mobile layout (and the selectors that have to out-specify these) is in
   components.css. */
@media (max-width: 640px) {
  /* iOS Safari zooms the whole page in whenever a focused field is under 16px,
     and never zooms back out — so every text field has to clear that bar. */
  input, select, textarea { font-size: 16px; }

  /* Comfortable touch targets. 40px rather than the usual 44 — enough to hit
     reliably without visibly inflating the buttons. */
  button, .btn { min-height: 40px; }
  input[type="checkbox"] { width: 20px; height: 20px; }

  /* The default h1 (2em) eats a phone's width on its own. */
  h1 { font-size: 24px; }
}
