/* ============================================================
   SkillArbitrage — theme tokens
   ============================================================ */
:root {
  --bg: #eef1f8;
  --surface: #ffffff;
  --surface-2: #f5f7fb;
  --text: #12141c;
  --text-2: #3d4152;
  --muted: #6a7286;
  --border: #e4e8f1;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: rgba(37, 99, 235, 0.10);
  --ring: rgba(37, 99, 235, 0.28);
  --ok: #12b76a;
  --ok-soft: rgba(18, 183, 106, 0.12);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.12);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow: 0 4px 8px -2px rgba(16, 24, 40, 0.08), 0 20px 44px -12px rgba(16, 24, 40, 0.12);
  --header-bg: rgba(255, 255, 255, 0.72);
  --radius: 14px;
  --radius-sm: 10px;
}

:root[data-theme="dark"] {
  --bg: #0a0c11;
  --surface: #141824;
  --surface-2: #1a1f2d;
  --text: #eceef5;
  --text-2: #c3c8d6;
  --muted: #8b93a7;
  --border: #242a38;
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-soft: rgba(59, 130, 246, 0.16);
  --ring: rgba(59, 130, 246, 0.40);
  --ok: #1fd18a;
  --ok-soft: rgba(31, 209, 138, 0.14);
  --danger: #ff6b61;
  --danger-soft: rgba(255, 107, 97, 0.14);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 4px 10px -2px rgba(0, 0, 0, 0.5), 0 24px 50px -14px rgba(0, 0, 0, 0.6);
  --header-bg: rgba(14, 17, 24, 0.72);
}

/* ============================================================
   Base
   ============================================================ */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 22px; }
h3 { font-size: 15px; margin-bottom: 14px; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; font-weight: 400; }
.error { color: var(--danger); min-height: 1.2em; margin: 10px 0 0; font-size: 13px; }

/* ============================================================
   Logo / brand
   ============================================================ */
.brand-logo { height: 24px; width: auto; }
.auth-logo { height: 38px; width: auto; margin: 0 auto 6px; }

/* Show the right logo for the current theme */
.light-only { display: block; }
.dark-only { display: none; }
:root[data-theme="dark"] .light-only { display: none; }
:root[data-theme="dark"] .dark-only { display: block; }

/* ============================================================
   Screens / auth
   ============================================================ */
.screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-screen {
  position: relative;
  background: var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 38px 34px 34px;
  box-shadow: var(--shadow);
  text-align: center;
}
.auth-fields { text-align: left; margin-top: 24px; }
.auth-card .block { margin-top: 20px; }

/* ============================================================
   Spinner
   ============================================================ */
.spinner {
  width: 38px; height: 38px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Form controls
   ============================================================ */
label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  margin: 16px 0 7px;
  letter-spacing: 0.01em;
}
input, select, textarea {
  width: 100%;
  padding: 11px 13px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.7; }
textarea { resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 4px var(--ring);
}

/* Browser autofill (Safari/Chrome) paints its own gray background + light text
   over the field. Force it to match the current theme instead. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--surface-2) inset;
  box-shadow: 0 0 0 1000px var(--surface-2) inset;
  border-color: var(--border);
  transition: background-color 9999s ease-in-out 0s;
}
input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset, 0 0 0 4px var(--ring);
  box-shadow: 0 0 0 1000px var(--surface) inset, 0 0 0 4px var(--ring);
  border-color: var(--primary);
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236a7286' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='4 6 8 10 12 6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

/* Date fields: visible, clickable calendar icon in both themes */
input[type="date"] { cursor: pointer; }
input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.6;
  padding: 4px;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: 1; }
:root[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.9);
}

/* ============================================================
   Buttons
   ============================================================ */
button {
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  transition: transform 0.12s ease, box-shadow 0.15s ease, background-color 0.15s, border-color 0.15s, color 0.15s;
}
button:active { transform: translateY(1px); }

button.primary {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
}
button.primary:hover { background: var(--primary-hover); }
button.primary:disabled { opacity: 0.6; cursor: default; }
button.block { width: 100%; padding: 12px; }

button.ghost { background: var(--surface); color: var(--text-2); }
button.ghost:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

button.mini { padding: 6px 11px; font-size: 12px; border-radius: 8px; }
button.mini.danger { color: var(--danger); border-color: var(--danger-soft); background: var(--danger-soft); }
button.mini.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* Theme toggle */
.theme-toggle {
  width: 38px; height: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-2);
}
.theme-toggle:hover { color: var(--primary); border-color: var(--primary); }
.theme-toggle .icon { width: 18px; height: 18px; }
.theme-toggle.floating { position: absolute; top: 22px; right: 22px; }
.icon-sun { display: none; }
.icon-moon { display: block; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }

/* ============================================================
   Header
   ============================================================ */
header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 13px 26px;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand .brand-word { font-size: 17px; }

nav { display: flex; gap: 4px; margin-left: 8px; }
.tab {
  border: none;
  background: none;
  color: var(--muted);
  padding: 9px 14px;
  border-radius: 9px;
  font-weight: 600;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { background: var(--primary-soft); color: var(--primary); }

.header-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text-2); }
.role-pill {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 20px;
  background: var(--primary-soft);
  color: var(--primary);
}

/* ============================================================
   Main / pages / cards
   ============================================================ */
main { max-width: 1080px; margin: 30px auto; padding: 0 26px; }
.page-head { margin-bottom: 20px; }
.page-head p { margin: 5px 0 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin: 0 0 20px;
  box-shadow: var(--shadow-sm);
}

.row { display: flex; gap: 16px; align-items: flex-end; }
.row.wrap { flex-wrap: wrap; }
.row.actions { align-items: center; margin-top: 18px; }
.field { flex: 1; min-width: 0; }
.field label { margin-top: 0; }

/* ============================================================
   Results + tables
   ============================================================ */
.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.results-count { font-size: 15px; }
.results-count strong { color: var(--primary); font-size: 20px; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td {
  text-align: left;
  padding: 10px 13px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th {
  background: var(--surface-2);
  font-weight: 700;
  color: var(--text-2);
  position: sticky;
  top: 0;
  font-size: 12px;
  letter-spacing: 0.02em;
}
tbody tr { transition: background-color 0.12s; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
.actions-cell { white-space: nowrap; }
.actions-cell .mini { margin-right: 6px; }

.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  display: inline-block;
}
.badge.on { background: var(--ok-soft); color: var(--ok); }
.badge.off { background: var(--danger-soft); color: var(--danger); }

/* ============================================================
   Scrollbars
   ============================================================ */
.table-wrap::-webkit-scrollbar { height: 10px; width: 10px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 20px; }
.table-wrap::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 720px) {
  header { flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
  nav { order: 3; width: 100%; margin-left: 0; }
  .header-right { gap: 8px; }
  .user-chip #whoami-email { display: none; }
  main { padding: 0 16px; margin-top: 20px; }
  .row { flex-direction: column; align-items: stretch; }
}
