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

:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #242838;
  --border:    #2e3347;
  --text:      #e2e8f0;
  --muted:     #6b7280;
  --primary:   #3b82f6;
  --primary-h: #2563eb;
  --success:   #22c55e;
  --danger:    #ef4444;
  --warning:   #f59e0b;
  --approved:  #22c55e;
  --rejected:  #ef4444;
  --pending:   #f59e0b;
  --radius:    8px;
  --shadow:    0 2px 8px rgba(0,0,0,.4);
}

html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: monospace; font-size: .85em; background: var(--surface2); padding: 2px 6px; border-radius: 4px; }
.code-block { display: block; background: var(--surface2); padding: .75rem 1rem; border-radius: var(--radius); word-break: break-all; }

/* ── Navbar ──────────────────────────────────────────── */
.navbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: .75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.nav-brand { font-size: 1.1rem; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: .4rem; }
.logo-dhb  { background: var(--primary); color: #fff; padding: 2px 8px; border-radius: 4px; font-weight: 900; font-size: .95rem; }
.logo-sub  { color: var(--muted); font-size: .8rem; }
.nav-links { display: flex; gap: .25rem; list-style: none; flex: 1; }
.nav-links a {
  padding: .4rem .75rem;
  border-radius: 6px;
  color: var(--muted);
  font-size: .9rem;
  transition: background .15s, color .15s;
}
.nav-links a:hover, .nav-links a.active {
  background: var(--surface2);
  color: var(--text);
  text-decoration: none;
}

/* ── Layout ──────────────────────────────────────────── */
.main-content { max-width: 1400px; margin: 0 auto; padding: 1.5rem; }
.page-header  { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; flex: 1; display: flex; align-items: center; gap: .5rem; }
.section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.5rem; }
.section h2 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.site-footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 2rem; }
.muted { color: var(--muted); font-size: .85rem; }
.hint  { color: var(--muted); font-size: .9rem; }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .45rem 1rem;
  border-radius: 6px;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity .15s, background .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--primary);  color: #fff; }
.btn-primary:hover { background: var(--primary-h); text-decoration: none; }
.btn-secondary{ background: var(--surface2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { opacity: .8; text-decoration: none; }
.btn-success  { background: #16a34a; color: #fff; }
.btn-danger   { background: #dc2626; color: #fff; }
.btn-ghost    { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface2); text-decoration: none; }
.btn-sm  { padding: .3rem .65rem; font-size: .8rem; }
.btn-lg  { padding: .65rem 1.5rem; font-size: 1rem; }
.btn-full{ width: 100%; justify-content: center; }
.btn-icon{ padding: .3rem .55rem; font-size: 1rem; background: var(--surface2); border: 1px solid var(--border); border-radius: 5px; }
.btn-group { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ── Alerts ──────────────────────────────────────────── */
.alert { padding: .75rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: .9rem; }
.alert-success { background: #14532d44; border: 1px solid #22c55e66; color: #86efac; }
.alert-error   { background: #7f1d1d44; border: 1px solid #ef444466; color: #fca5a5; }
.alert-warn    { background: #78350f44; border: 1px solid #f59e0b66; color: #fcd34d; }

/* ── Forms ───────────────────────────────────────────── */
label { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; color: var(--muted); }
label small { color: var(--muted); font-size: .78rem; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=color],
select, textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: .45rem .75rem;
  font-size: .9rem;
  width: 100%;
  max-width: 420px;
}
input[type=color] { height: 38px; padding: 2px; cursor: pointer; }
input:focus, select:focus { outline: none; border-color: var(--primary); }
.form-inline { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.form-stack  { display: flex; flex-direction: column; gap: 1rem; max-width: 500px; }
.checkbox-label { flex-direction: row !important; align-items: center; gap: .5rem; cursor: pointer; color: var(--text) !important; }
.checkbox-label input { width: auto; }

/* ── Stats grid ──────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1rem;
  display: flex; flex-direction: column; gap: .25rem;
}
.stat-number { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-label  { font-size: .8rem; color: var(--muted); }
.stat-approved .stat-number { color: var(--approved); }
.stat-rejected .stat-number { color: var(--rejected); }
.stat-pending  .stat-number { color: var(--pending);  }
.stat-uploaded .stat-number { color: var(--primary);  }

/* ── Person cards ────────────────────────────────────── */
.person-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: 1rem; }
.person-card  { background: var(--surface2); border-radius: var(--radius); padding: 1rem; border-left: 4px solid var(--primary); }
.person-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.person-bar-wrap { margin: .5rem 0; }
.person-bar { height: 6px; border-radius: 3px; background: var(--border); display: flex; overflow: hidden; }
.bar-approved { background: var(--approved); }
.bar-rejected { background: var(--rejected); }
.bar-pending  { background: var(--pending);  }
.bar-uploaded { background: var(--primary);  }
.person-stats-row { display: flex; gap: .75rem; font-size: .78rem; flex-wrap: wrap; margin: .4rem 0; }
.person-card-actions { margin-top: .75rem; }
.dot.approved { color: var(--approved); }
.dot.rejected { color: var(--rejected); }
.dot.pending  { color: var(--pending);  }

/* ── Image grid ──────────────────────────────────────── */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .75rem;
}
.image-card {
  background: var(--surface2);
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid transparent;
  transition: border-color .15s;
}
.image-card.status-approved { border-color: #22c55e33; }
.image-card.status-rejected { border-color: #ef444433; }
.image-card.status-fb_uploaded { border-color: #3b82f633; }

.image-thumb-wrap { position: relative; aspect-ratio: 4/3; overflow: hidden; background: #000; }
.image-thumb-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; transition: opacity .2s; }
.image-thumb-wrap:hover img { opacity: .85; }

.image-status-badge { position: absolute; top: 6px; right: 6px; }
.person-stripe { position: absolute; bottom: 0; left: 0; right: 0; height: 3px; }

.image-info { padding: .4rem .5rem .2rem; font-size: .75rem; color: var(--muted); display: flex; justify-content: space-between; }
.image-filename { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; }
.blur-score { font-size: .7rem; }

.image-actions { display: flex; gap: .25rem; padding: .4rem .5rem; justify-content: flex-end; align-items: center; }

/* ── Gallery select ──────────────────────────────────── */
.gallery-card { cursor: pointer; user-select: none; }
.gallery-card:hover .image-thumb-wrap img { opacity: .75; }
.gallery-card.is-queued { border-color: var(--primary); }
.queue-overlay {
  position: absolute; inset: 0;
  background: rgba(59,130,246,.35);
  display: flex; align-items: center; justify-content: center;
}
.queue-check { font-size: 2rem; color: #fff; font-weight: 900; text-shadow: 0 1px 4px rgba(0,0,0,.6); }

.day-section .section { margin-bottom: 0; }
.day-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }
.day-header h2 { font-size: 1.1rem; color: var(--text); text-transform: none; letter-spacing: 0; }

/* ── Sticky bar ──────────────────────────────────────── */
.sticky-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: .75rem 1.5rem;
  display: flex; align-items: center; gap: 1rem;
  z-index: 200;
}

/* ── Progress bar ────────────────────────────────────── */
.progress-bar-wrap { height: 12px; background: var(--surface2); border-radius: 6px; overflow: hidden; margin-bottom: .5rem; }
.progress-bar-fill { height: 100%; background: var(--primary); border-radius: 6px; transition: width .3s; }

/* ── Table ───────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th { text-align: left; color: var(--muted); font-weight: 500; padding: .5rem .75rem; border-bottom: 1px solid var(--border); }
.table td { padding: .5rem .75rem; border-bottom: 1px solid var(--border)22; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table-sm th, .table-sm td { padding: .35rem .6rem; }
.row-inactive { opacity: .5; }
.actions { display: flex; gap: .4rem; }

/* ── Badges ──────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .72rem; font-weight: 600; }
.badge-green { background: #14532d; color: #86efac; }
.badge-red   { background: #7f1d1d; color: #fca5a5; }
.badge-blue  { background: #1e3a8a; color: #93c5fd; }
.badge-gray  { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }

/* ── Color dot ───────────────────────────────────────── */
.color-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; }
.color-dot.lg { width: 16px; height: 16px; }

/* ── Filter bar ──────────────────────────────────────── */
.filter-bar { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }
.filter-group { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.filter-label { color: var(--muted); font-size: .8rem; min-width: 70px; }
.filter-btn {
  padding: .25rem .65rem;
  border-radius: 99px;
  font-size: .8rem;
  border: 1px solid var(--border);
  color: var(--muted);
  transition: all .15s;
}
.filter-btn:hover, .filter-btn.active {
  background: var(--surface2);
  color: var(--text);
  text-decoration: none;
}

/* ── Text helpers ────────────────────────────────────── */
.text-approved { color: var(--approved); }
.text-rejected { color: var(--rejected); }
.text-pending  { color: var(--pending);  }
.text-error    { color: var(--danger);   }

/* ── Pagination ──────────────────────────────────────── */
.pagination { display: flex; gap: .3rem; margin-top: 1rem; flex-wrap: wrap; }
.page-btn { padding: .35rem .7rem; border-radius: 6px; border: 1px solid var(--border); font-size: .85rem; color: var(--muted); }
.page-btn.active, .page-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); text-decoration: none; }

/* ── Login ───────────────────────────────────────────── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
}
.login-logo { text-align: center; margin-bottom: 1.5rem; display: flex; flex-direction: column; align-items: center; gap: .3rem; }
.login-logo .logo-dhb { font-size: 1.5rem; padding: 6px 16px; }
.login-logo .logo-sub { color: var(--muted); font-size: .9rem; }
.login-card h2 { margin-bottom: 1rem; font-size: 1.1rem; }
.login-card form { display: flex; flex-direction: column; gap: .75rem; }
.login-card label input { max-width: 100%; }

/* ── Mobilvenlig ─────────────────────────────────────── */
@media (max-width: 768px) {
  /* Navbar */
  .navbar { flex-wrap: wrap; gap: .5rem; padding: .6rem 1rem; }
  .nav-links { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; gap: 0; padding-bottom: 2px; }
  .nav-links a { padding: .35rem .55rem; font-size: .8rem; white-space: nowrap; }
  .nav-brand { flex: 1; }

  /* Layout */
  .main-content { padding: .75rem; }
  .page-header { flex-direction: column; align-items: flex-start; gap: .5rem; }
  .page-header h1 { font-size: 1.2rem; }

  /* Stats grid — 2 kolonner på mobil */
  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  /* Person cards — 1 kolonne */
  .person-cards { grid-template-columns: 1fr; }

  /* Image grid — 2 kolonner */
  .image-grid { grid-template-columns: repeat(2, 1fr); gap: .5rem; }

  /* Filter bar */
  .filter-bar { gap: .4rem; }
  .filter-group { gap: .3rem; }
  .filter-btn { font-size: .75rem; padding: .2rem .5rem; }

  /* Forms */
  .form-inline { flex-direction: column; align-items: stretch; }
  input[type=text], input[type=password], input[type=number], input[type=date] { max-width: 100%; }

  /* Table — scroll horisontalt */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table { min-width: 500px; }

  /* Sticky bar */
  .sticky-bar { flex-wrap: wrap; padding: .6rem 1rem; gap: .5rem; font-size: .85rem; }

  /* Btn group */
  .btn-group { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .image-grid { grid-template-columns: repeat(2, 1fr); }
  .section { padding: .875rem; }
  .nav-links a { font-size: .75rem; padding: .3rem .45rem; }
}

/* ── Lightbox mobil + swipe ──────────────────────────── */
@media (max-width: 768px) {
  .lb-box { width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; }
  .lb-topbar { padding: .5rem .75rem; }
  .lb-filename { max-width: 120px; }
  .lb-toolbar { padding: .5rem .75rem; gap: .5rem; }
  .lb-toolbar::after { display: none; }
  .lb-toolbar-left .btn, .lb-toolbar-right .btn { padding: .4rem .6rem; font-size: .8rem; }
  .lb-nav { font-size: 1.2rem; padding: .75rem .5rem; }
  /* Større touch-target for rotation */
  .lb-toolbar-left { gap: .4rem; }
}
