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

/* ── Tokens ─────────────────────────────────────────────── */
:root {
  --bg:           #f0f2f1;
  --surface:      #ffffff;
  --surface-2:    #f6f7f6;
  --primary:      #4e7c6f;
  --primary-dk:   #3a5f55;
  --primary-lt:   #d6e8e4;
  --primary-xlt:  #edf5f3;
  --text:         #2a302d;
  --muted:        #6b7b74;
  --border:       #dce3e0;
  --danger:       #c0392b;
  --danger-lt:    #fdf0ef;
  --success:      #27866a;
  --success-lt:   #e8f7f2;
  --warning-lt:   #fef9ec;
  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 1px 6px rgba(0,0,0,.07);
  --shadow-md:    0 4px 24px rgba(0,0,0,.10);
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Nunito', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ── Site wrapper ───────────────────────────────────────── */
.site-wrap { flex: 1; }

/* ── Header ─────────────────────────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.65rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text);
}

.header-brand img {
  height: 38px;
  width: auto;
  object-fit: contain;
}

.header-brand span {
  font-size: 1rem;
  font-weight: 800;
  color: var(--primary-dk);
  letter-spacing: -0.01em;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex-wrap: wrap;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.87rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  transition: background .15s, color .15s;
}

.site-nav a:hover { background: var(--primary-xlt); color: var(--primary-dk); }
.site-nav a.active { background: var(--primary-lt); color: var(--primary-dk); }
.site-nav a.nav-logout { color: var(--danger); }
.site-nav a.nav-logout:hover { background: var(--danger-lt); }

/* ── Hero ───────────────────────────────────────────────── */
.hero {
  background: linear-gradient(140deg, var(--primary-dk) 0%, var(--primary) 100%);
  color: white;
  padding: 2.5rem 1.5rem;
  text-align: center;
}
.hero-logo-wrap {
  display: inline-block;
  background: white;
  border-radius: 12px;
  padding: 8px 14px;
  margin-bottom: 1rem;
  box-shadow: 0 2px 12px rgba(0,0,0,.15);
}
.hero-logo-wrap img { height: 52px; display: block; }
.hero h2 { font-size: 1.8rem; font-weight: 800; letter-spacing: -0.02em; }
.hero p  { font-size: 0.97rem; opacity: 0.85; margin-top: 0.3rem; }

/* ── Page layout ────────────────────────────────────────── */
.page { max-width: 860px; margin: 2rem auto; padding: 0 1.25rem; }
.page-wide { max-width: 1000px; margin: 2rem auto; padding: 0 1.25rem; }

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

/* ── Section heading ────────────────────────────────────── */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.section-head h2 {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.52rem 1.15rem;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--primary-dk); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-full { width: 100%; justify-content: center; padding: 0.75rem; font-size: 0.97rem; }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #a93226; }
.btn-secondary { background: #5b6a7a; }
.btn-secondary:hover { background: #4a5768; }
.btn-sm { padding: 0.28rem 0.7rem; font-size: 0.81rem; }

/* ── Table ──────────────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
th {
  background: var(--surface-2);
  text-align: left;
  padding: 0.65rem 1rem;
  font-size: 0.77rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
td { padding: 0.72rem 1rem; border-top: 1px solid var(--border); font-size: 0.9rem; }
tr:first-child td { border-top: none; }
tbody tr:hover td { background: var(--primary-xlt); }
.td-empty { text-align: center; color: var(--muted); padding: 2.5rem; font-style: italic; }

/* Klickbart namn i tabell */
.name-link {
  cursor: pointer;
  font-weight: 700;
  color: var(--primary-dk);
  border-bottom: 1px dashed var(--primary-lt);
  transition: color .15s;
}
.name-link:hover { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.18rem 0.58rem;
  border-radius: 20px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.badge-YOUTH { background: var(--primary-lt); color: var(--primary-dk); }
.badge-STAFF { background: #ddf4eb; color: #1a6647; }
.badge-ADMIN { background: #fef3cd; color: #7a5200; }

/* ── Form elements ──────────────────────────────────────── */
.field { margin-bottom: 1.05rem; }
label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 0.28rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
input, select, textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.82rem;
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(78,124,111,.14);
}
input[type="file"] {
  padding: 0.45rem 0.6rem;
  font-size: 0.85rem;
  background: var(--surface-2);
}
textarea { resize: vertical; min-height: 110px; }

/* ── Alerts ─────────────────────────────────────────────── */
.alert {
  border-radius: var(--radius-sm);
  padding: 0.72rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  display: none;
}
.alert-error { background: var(--danger-lt); color: var(--danger); border: 1px solid #f5c6c2; }
.alert-success { background: var(--success-lt); color: var(--success); border: 1px solid #b2e8d8; }
.alert.show { display: block; }

/* ── Modal / Overlay ────────────────────────────────────── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.32);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(2px);
}
.overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  max-height: 90vh;
  overflow-y: auto;
}
.modal h3 { font-size: 1.1rem; font-weight: 800; margin-bottom: 1.25rem; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.5rem; }

/* ── Profilkort ─────────────────────────────────────────── */
.profile-modal { max-width: 420px; }
.profile-name {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 0.2rem;
}
.profile-username {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
}
.profile-section {
  margin-bottom: 1rem;
}
.profile-section h4 {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin-bottom: 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}
.profile-row {
  display: flex;
  gap: 0.5rem;
  font-size: 0.9rem;
  padding: 0.3rem 0;
}
.profile-row .lbl {
  color: var(--muted);
  font-weight: 600;
  min-width: 120px;
  flex-shrink: 0;
}
.profile-row .val { color: var(--text); word-break: break-word; }
.profile-row .val a { color: var(--primary); text-decoration: none; }
.profile-row .val.none { color: var(--muted); font-style: italic; }

/* ── Stats grid ─────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.75rem; }
.stat { background: var(--surface); border-radius: var(--radius); padding: 1.2rem 1.4rem; box-shadow: var(--shadow); border: 1px solid var(--border); }
.stat .value { font-size: 2.5rem; font-weight: 800; color: var(--primary); line-height: 1; }
.stat .label { font-size: 0.81rem; font-weight: 600; color: var(--muted); margin-top: 0.25rem; text-transform: uppercase; letter-spacing: .04em; }

/* ── Toast ──────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--text);
  color: white;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.15rem;
  font-size: 0.88rem;
  font-weight: 600;
  display: none;
  z-index: 999;
  box-shadow: var(--shadow-md);
}

/* ── Info-block (startsidan) ────────────────────────────── */
.info-block {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.4rem 1.6rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.info-block h3 {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--primary-dk);
  margin-bottom: 0.5rem;
}
.info-block p, .info-block pre {
  font-size: 0.93rem;
  line-height: 1.65;
  white-space: pre-wrap;
  color: var(--text);
}
.info-block img {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-top: 0.75rem;
}
.block-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; }

/* ── Image upload preview ───────────────────────────────── */
.img-preview {
  margin-top: 0.5rem;
  border-radius: var(--radius-sm);
  max-height: 160px;
  max-width: 100%;
  object-fit: contain;
  display: none;
  border: 1px solid var(--border);
}

/* ── Footer ─────────────────────────────────────────────── */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 1.1rem 1.5rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
}
.site-footer strong { color: var(--text); font-weight: 700; }
.site-footer a { color: var(--primary); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* ── Login page ─────────────────────────────────────────── */
.login-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: var(--bg);
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}
.login-card .logo-wrap {
  text-align: center;
  margin-bottom: 1.5rem;
}
.login-card .logo-wrap img { height: 56px; }
.login-card h1 {
  font-size: 1.4rem;
  font-weight: 800;
  text-align: center;
  color: var(--primary-dk);
  margin-bottom: 0.2rem;
}
.login-card .subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 1.75rem;
}

/* ── Checkin page ───────────────────────────────────────── */
.checkin-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.checkin-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  text-align: center;
}
.checkin-card .center-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.checkin-card h1 { font-size: 1.4rem; font-weight: 800; color: var(--primary-dk); margin-bottom: 0.2rem; }
.checkin-card .center-sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.5rem; }
.user-box {
  background: var(--primary-xlt);
  border: 1px solid var(--primary-lt);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 1.25rem;
}
.user-box .uname { font-weight: 800; font-size: 1.1rem; }
.user-box .usince { font-size: 0.84rem; color: var(--muted); margin-top: 0.2rem; }
.btn-checkin { background: var(--primary); color: white; width: 100%; border: none; border-radius: var(--radius-sm); padding: 0.85rem; font-family: inherit; font-size: 1rem; font-weight: 700; cursor: pointer; transition: background .15s; }
.btn-checkin:hover { background: var(--primary-dk); }
.btn-checkin:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-checkout { background: var(--danger); }
.btn-checkout:hover { background: #a93226; }
.checkin-links { margin-top: 1.25rem; font-size: 0.84rem; }
.checkin-links a { color: var(--primary); text-decoration: none; }
.checkin-links a:hover { text-decoration: underline; }

/* ── Kiosk page ─────────────────────────────────────────── */
.kiosk-body {
  background: linear-gradient(150deg, var(--primary-dk) 0%, var(--primary) 60%, #6aab9c 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: white;
  text-align: center;
}
.kiosk-logo-wrap {
  display: inline-block;
  background: white;
  border-radius: 12px;
  padding: 8px 16px;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 16px rgba(0,0,0,.2);
}
.kiosk-logo-wrap img { height: 52px; display: block; }
.kiosk-title { font-size: 2rem; font-weight: 800; margin-bottom: 0.4rem; letter-spacing: -0.02em; }
.kiosk-sub { font-size: 1.1rem; opacity: 0.85; margin-bottom: 2rem; }
.kiosk-qr-wrap {
  background: white;
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: 0 8px 40px rgba(0,0,0,.25);
  display: inline-block;
  margin-bottom: 1.5rem;
}
.kiosk-qr-wrap img { display: block; width: 280px; height: 280px; }
.kiosk-url {
  font-size: 0.85rem;
  opacity: 0.7;
  font-family: monospace;
  background: rgba(255,255,255,.1);
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  display: inline-block;
  margin-bottom: 1.5rem;
  word-break: break-all;
}
.kiosk-instruction {
  font-size: 1rem;
  opacity: 0.9;
  max-width: 340px;
  line-height: 1.6;
}
.kiosk-open-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.2rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
  margin-top: 0.5rem;
}
.kiosk-open-btn:hover { background: var(--primary-dk); }

/* ── Misc ───────────────────────────────────────────────── */
code { font-family: monospace; font-size: 0.9em; background: var(--surface-2); padding: 0.1em 0.4em; border-radius: 4px; }
.loading { text-align: center; color: var(--muted); padding: 2.5rem; font-style: italic; }
.empty-msg { text-align: center; color: var(--muted); padding: 2.5rem; font-style: italic; }
