/* Gartha — globale stiler. Dark/light via CSS custom properties. */

:root {
  --bg: #f5f7f9;
  --bg-elev: #ffffff;
  --card: #ffffff;
  --text: #1b2733;
  --muted: #5f7180;
  --line: #dde5ec;
  --accent: #2f7d6b;
  --accent-text: #ffffff;
  --danger: #c0392b;
  --shadow: 0 1px 3px rgba(16, 34, 48, 0.08), 0 1px 2px rgba(16, 34, 48, 0.06);
  --radius: 12px;
}

:root[data-theme='dark'] {
  --bg: #10171e;
  --bg-elev: #172029;
  --card: #172029;
  --text: #e7edf2;
  --muted: #9aa8b4;
  --line: #26323d;
  --accent: #4db6a1;
  --accent-text: #06120f;
  --danger: #e57368;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
}

a { color: var(--accent); }

/* --- Topbar --- */
.gth-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
}
.gth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--accent);
  text-decoration: none;
}
.gth-logo {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 1rem;
}
.gth-topActions { display: flex; gap: 8px; }
.gth-btnTheme, .gth-btnIcon {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  width: 42px;
  height: 42px;
  font-size: 1.1rem;
  cursor: pointer;
}
.gth-btnTheme:hover, .gth-btnIcon:hover { background: var(--bg); }

/* --- Meny --- */
.gth-menuOverlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(9, 16, 22, 0.45);
  display: none;
}
.gth-menuOverlay.open { display: block; }
.gth-menuPanel {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(320px, 84vw);
  background: var(--bg-elev);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  animation: gth-slide 0.18s ease;
}
@keyframes gth-slide { from { transform: translateX(20px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.gth-menuHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.gth-menuHeader h3 { margin: 0; font-size: 1rem; }
.gth-closeBtn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
}
.gth-menuList { padding: 8px; overflow-y: auto; }
.gth-menuItem {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.98rem;
}
.gth-menuItem:hover { background: var(--bg); }
.gth-menuItem--active { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); font-weight: 600; }
.gth-menuItem__icon { width: 24px; text-align: center; }

/* --- Layout --- */
.gth-main { padding: 20px 16px 60px; }
.gth-container { max-width: 900px; margin: 0 auto; }
.gth-pageHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.gth-pageHeader h1 { margin: 0; font-size: 1.5rem; }

/* --- Kort --- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card__title { margin: 0 0 4px; font-size: 1.1rem; }
.card__meta { color: var(--muted); font-size: 0.85rem; margin-bottom: 8px; }
.card__body { }
.card--pinned { border-color: var(--accent); }

.grid { display: grid; gap: 14px; }
@media (min-width: 640px) { .grid--2 { grid-template-columns: 1fr 1fr; } }

/* --- Knapper --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--bg); }
.btn--primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn--primary:hover { filter: brightness(1.05); }
.btn--danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.btn--sm { padding: 5px 10px; font-size: 0.85rem; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* --- Skjema --- */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 0.9rem; margin-bottom: 5px; color: var(--muted); }
input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
input:focus, textarea:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); border-color: var(--accent); }
textarea { min-height: 120px; resize: vertical; }
.field-row { display: flex; gap: 10px; flex-wrap: wrap; }
.field-row > * { flex: 1; min-width: 140px; }

/* --- Modal --- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(9, 16, 22, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal[hidden] { display: none; }
.modal__content {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  width: min(560px, 100%);
  max-height: 90vh;
  overflow-y: auto;
}
.modal__header, .modal__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
}
.modal__header { border-bottom: 1px solid var(--line); }
.modal__footer { border-top: 1px solid var(--line); justify-content: flex-end; }
.modal__header h3 { margin: 0; font-size: 1.05rem; }
.modal__body { padding: 16px; }

/* --- Diverse --- */
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty__icon { font-size: 2rem; display: block; margin-bottom: 8px; }
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
}
.pill { display: inline-block; padding: 2px 8px; border: 1px solid var(--line); border-radius: 999px; font-size: 0.75rem; color: var(--muted); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack > * + * { margin-top: 8px; }
.msg { padding: 10px 12px; border-radius: 10px; margin-top: 10px; font-size: 0.9rem; }
.msg--error { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.msg--ok { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }

/* --- Tabell --- */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
th { color: var(--muted); font-weight: 600; }

/* --- Loader --- */
.loader { position: fixed; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 70%, transparent); z-index: 70; }
.loader[hidden] { display: none; }
.loader__spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: gth-spin 0.8s linear infinite; }
@keyframes gth-spin { to { transform: rotate(360deg); } }

/* --- Kommentarer --- */
.comment-list { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.comment { padding: 8px 0; border-bottom: 1px solid var(--line); }
.comment:last-child { border-bottom: none; }
.comment__meta { font-size: 0.8rem; color: var(--muted); }

/* --- Markdown --- */
.md-body h1, .md-body h2, .md-body h3, .md-body h4 { line-height: 1.25; margin: 0.6em 0 0.3em; }
.md-body p { margin: 0.5em 0; }
.md-body ul { padding-left: 1.3em; margin: 0.5em 0; }
.md-body blockquote { border-left: 3px solid var(--accent); margin: 0.6em 0; padding: 0.2em 0.9em; color: var(--muted); }
.md-body pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow-x: auto; }
.md-body code { background: var(--bg); padding: 1px 5px; border-radius: 5px; font-size: 0.9em; }
.md-body pre code { background: none; padding: 0; }
.md-img, .md-body img { max-width: 100%; border-radius: 10px; margin: 6px 0; }

/* --- Markdown-editor --- */
.md-toolbar { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }
.md-toolbar__btn {
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 8px;
  min-width: 34px;
  height: 34px;
  cursor: pointer;
  font-weight: 600;
}
.md-toolbar__btn:hover { background: var(--bg); }

/* --- Oppdateringsbanner --- */
#sw-update-banner {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 10px 14px;
  border-radius: 12px;
}
#sw-update-banner button { border: none; background: var(--accent); color: var(--accent-text); border-radius: 8px; padding: 6px 12px; cursor: pointer; }

/* --- Innlogging --- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; width: min(420px, 100%); }
.login-card h1 { margin: 0 0 4px; color: var(--accent); }
.login-card p.sub { margin: 0 0 20px; color: var(--muted); }

/* Avgifts-merker i medlemsregisteret */
.fee-cell { white-space: nowrap; }
.fee-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; margin-right: 3px; border-radius: 5px;
  font-size: 0.72rem; font-weight: 700; line-height: 1;
}
.fee-badge--yes { background: var(--accent); color: var(--accent-text); }
.fee-badge--no  { background: var(--line); color: var(--muted); }
.fee-fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px 12px; margin: 4px 0; }
.fee-fieldset legend { padding: 0 6px; color: var(--muted); font-size: 0.85rem; }
.fee-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.fee-check { display: flex; align-items: center; gap: 6px; font-size: 0.92rem; }
.fee-check input { width: auto; }

/* Medlemskart (Leaflet) */
.member-map { height: 380px; width: 100%; border-radius: 10px; margin-top: 8px; z-index: 0; }
.leaflet-container { background: var(--bg); font: inherit; }
.gth-pin { font-size: 22px; line-height: 28px; text-align: center; filter: drop-shadow(0 1px 1px rgba(0,0,0,.4)); }

/* Filarkiv: filterlinje + fil-rader */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 10px 12px; }
.filter-search { flex: 1; min-width: 180px; }
.filter-bar select { width: auto; }
.file-row { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.file-row:last-child { border-bottom: 0; }
.file-icon { font-size: 1.4rem; line-height: 1.4; flex: 0 0 auto; }
.file-main { flex: 1; min-width: 0; }
.file-desc { font-size: 0.86rem; margin: 2px 0; }
.file-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 0.8rem; margin-top: 2px; }
.tag--soft { background: transparent; border: 1px solid var(--line); color: var(--muted); }
