/* OLEADING Knowledge — brand foundation.
 * Fonts: Quicksand (display / logo feel) + DM Sans (body). Both self-hosted
 * variable fonts. Ink colour #0D1118 sampled from the logo wordmark. */

@font-face {
  font-family: 'DM Sans';
  src: url('/fonts/DMSans-Variable.ttf') format('truetype-variations');
  font-weight: 100 1000;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Quicksand';
  src: url('/fonts/Quicksand-Variable.ttf') format('truetype-variations');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light dark;

  --font-sans: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Quicksand', var(--font-sans);

  --ink: #0d1118;

  /* Light theme (default) */
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --border: #e5e7eb;
  --text: #14161d;
  --muted: #6b7280;
  --accent: #0d1118;
  --accent-contrast: #ffffff;
  /* Destructive / dismissive actions (logout, cancel, and any close/decline). */
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-contrast: #ffffff;
  --shadow: 0 8px 30px rgba(13, 17, 24, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0f;
    --surface: #16161c;
    --surface-2: #1c1c23;
    --border: #292932;
    --text: #e8e8ec;
    --muted: #a1a1aa;
    --accent: #ffffff;
    --accent-contrast: #14161d;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 0.4rem;
}

a { color: inherit; }

/* ---------- App shell ---------- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 0.75rem; }
.brand .logo { height: 26px; width: auto; display: block; }

.nav { display: flex; gap: 0.25rem; }
.nav a {
  text-decoration: none;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.95rem;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current='page'] { color: var(--text); background: var(--surface-2); }

.user-menu { display: flex; align-items: center; gap: 0.75rem; }
.user-menu .who { text-align: right; line-height: 1.2; }
.user-menu .who .name { font-weight: 600; font-size: 0.9rem; }
.user-menu .who .email { color: var(--muted); font-size: 0.78rem; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-contrast);
  font-family: var(--font-display); font-weight: 600; font-size: 0.9rem;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.55rem 0.95rem; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font-family: var(--font-sans); font-size: 0.9rem; font-weight: 600;
  text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
/* Keep the accent pairing on hover — otherwise .btn:hover swaps in a surface
 * background under accent-contrast text and the label goes unreadable (dark-on-
 * dark in dark mode, light-on-light in light mode). */
.btn-primary:hover { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); opacity: 0.9; }
.btn-ghost { background: transparent; }
/* Red destructive/dismissive buttons: logout, cancel, close, decline. */
.btn-danger { background: var(--danger); color: var(--danger-contrast); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-hover); color: var(--danger-contrast); border-color: var(--danger-hover); }

/* ---------- Layout / page ---------- */

.page { padding: 2rem 1.5rem; max-width: 1040px; margin: 0 auto; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.muted { color: var(--muted); }
.sub { color: var(--muted); margin: 0 0 1.25rem; }

/* ---------- Centered auth screen ---------- */

.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card { width: min(92vw, 400px); text-align: left; }
.auth-card .logo { height: 30px; width: auto; margin-bottom: 1.25rem; }

/* ---------- Tables (admin) ---------- */

.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th, .table td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; }

/* ---------- Login language switcher (login-view.js) ---------- */
.btn.btn-full { width: 100%; }
.lang-switch { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.lang-switch-label { align-self: center; font-size: 11px; color: var(--muted); margin-right: 2px; }
.lang-btn {
  font: inherit; font-size: 12px; padding: 4px 10px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--border); background: transparent; color: inherit;
}
.lang-btn.is-active { background: var(--accent); color: var(--accent-contrast); }

@media (max-width: 560px) {
  .auth-screen {
    padding: 1rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }
  .auth-card { width: 100%; padding: 1.25rem; }
  .auth-card .logo { height: 26px; }
  .btn { min-height: 44px; padding: 0.7rem 1rem; }
  .lang-btn { min-height: 36px; padding: 6px 12px; }
  .app-header { padding: 0.65rem 1rem; flex-wrap: wrap; }
  .user-menu .who { display: none; }
  .page { padding: 1.25rem 1rem; }
  .table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
