/* ===== Grundfärger ===== */
:root {
  --green: #1f5130;
  --green-light: #e6f0e8;
  --orange: #e8660c;
  --blue: #1f6fd1;
  --red: #c62828;
  --text: #1a1a1a;
  --muted: #5f6368;
  --border: #c9ccd1;
  --bg: #f4f5f2;
  --white: #fff;
  --radius: 12px;
  --topbar-h: 52px;
  --tabbar-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Source Sans 3", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
  color: var(--text);
  background: var(--bg);
}

[hidden] { display: none !important; }

h1, h2 { margin: 0 0 12px; }

label {
  display: block;
  font-weight: 600;
  margin: 14px 0 6px;
}

input, select, textarea {
  width: 100%;
  font: inherit;
  padding: 12px;
  min-height: 52px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--text);
}
textarea { min-height: 0; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green);
}

/* ===== Knappar ===== */
.btn {
  font: inherit;
  font-weight: 600;
  min-height: 52px;
  padding: 0 20px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  touch-action: manipulation;
}
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn-primary { background: var(--green); color: var(--white); width: 100%; margin-top: 12px; }
.btn-secondary { background: var(--green-light); color: var(--green); }
.btn-danger { background: #fdecea; color: var(--red); }
.btn-link { background: none; color: var(--green); width: 100%; text-decoration: underline; }
.btn-small { min-height: 40px; padding: 0 14px; font-size: 16px; background: rgba(255,255,255,0.15); color: var(--white); }

.message { color: var(--red); min-height: 1.2em; margin: 10px 0 0; font-size: 16px; }
.message.ok { color: var(--green); }
.hint { color: var(--muted); font-size: 15px; margin: 4px 0 8px; }

/* ===== Inloggning (design från Claude Design) ===== */
.auth-view {
  min-height: 100%;
  display: flex;
  justify-content: center;
  background: #101218;
  font-family: "Source Sans 3", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.auth-col {
  position: relative;
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.hero {
  position: relative;
  height: 440px;
  flex: none;
  background: linear-gradient(180deg, #1b2040 0%, #4a3558 40%, #b8603f 78%, #e39a5a 100%);
}
.hero-img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hero-scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(16,18,24,.55) 0%, rgba(16,18,24,0) 32%);
}
.hero-title {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(44px + env(safe-area-inset-top));
  margin: 0;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
  font-weight: 500;
  text-shadow: 0 2px 14px rgba(0,0,0,.55);
}
.hero-title .t1 { font: 500 44px/1 "EB Garamond", Georgia, serif; color: #f6dfae; letter-spacing: .3px; }
.hero-title .t2 { font: italic 500 25px/1.2 "EB Garamond", Georgia, serif; color: #f0a86e; }
.hero-title .t3 { font: 500 40px/1 "EB Garamond", Georgia, serif; color: #fbf3e4; }

.auth-card {
  position: relative;
  z-index: 2;
  margin: -44px 16px 0;
  background: #fbfaf7;
  border-radius: 18px;
  padding: 28px 22px 24px;
  box-shadow: 0 12px 40px rgba(0,0,0,.45);
  color: #17181c;
}
.auth-spacer { flex: 1; min-height: 28px; }

.auth-panel, #forgot-form { display: flex; flex-direction: column; gap: 18px; }
.auth-panel[hidden] { display: none; }
.field { display: flex; flex-direction: column; gap: 8px; }
.auth-card label { margin: 0; font: 700 17px/1.2 "Source Sans 3", sans-serif; color: #17181c; }
.auth-card input {
  height: 52px;
  min-height: 0;
  padding: 0 14px;
  font: 400 17px "Source Sans 3", sans-serif;
  color: #17181c;
  background: #fff;
  border: 2px solid #cfccc4;
  border-radius: 12px;
  outline: none;
}
.auth-card input::placeholder { color: #9a9a93; }
.auth-card input:focus { border-color: #c8603d; box-shadow: 0 0 0 3px rgba(200,96,61,.18); }
.auth-card input.invalid { border-color: #b3261e; }
.field-error { font: 400 14px/1.3 "Source Sans 3", sans-serif; color: #b3261e; }

.pw-wrap { position: relative; display: flex; }
.pw-wrap input { flex: 1; min-width: 0; padding-right: 64px; }
.pw-toggle {
  position: absolute;
  right: 6px;
  top: 6px;
  height: 40px;
  min-width: 52px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  font: 600 14px "Source Sans 3", sans-serif;
  color: #5d5f66;
  cursor: pointer;
  border-radius: 8px;
}
.pw-toggle:hover { background: #f0eee9; }

.form-error { padding: 12px 14px; border-radius: 10px; background: #fbe9e6; font: 400 15px/1.35 "Source Sans 3", sans-serif; color: #8c1d16; }
.form-ok { padding: 14px; border-radius: 10px; background: #e5efe8; font: 400 16px/1.4 "Source Sans 3", sans-serif; color: #163f2a; }

.auth-primary {
  margin-top: 6px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 12px;
  background: #c8603d;
  color: #fff;
  font: 700 18px "Source Sans 3", sans-serif;
  cursor: pointer;
  transition: background .15s;
}
.auth-primary:hover { background: #b3532f; }
.auth-primary:active { background: #9e4828; }
.auth-primary:disabled { cursor: wait; opacity: .85; }
.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.auth-center { display: flex; justify-content: center; }
.auth-link {
  border: 0;
  background: none;
  padding: 10px 8px;
  font: 700 17px "Source Sans 3", sans-serif;
  color: #1f5b3c;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.auth-link:hover { color: #163f2a; }
.auth-help { margin: 0; font: 400 15px/1.45 "Source Sans 3", sans-serif; color: #5d5f66; text-align: center; }
.auth-secondary {
  height: 50px;
  border: 2px solid #cfccc4;
  border-radius: 12px;
  background: transparent;
  color: #17181c;
  font: 700 17px "Source Sans 3", sans-serif;
  cursor: pointer;
}
.auth-secondary:hover { background: #f0eee9; }
.auth-heading { display: flex; flex-direction: column; gap: 6px; }
.auth-heading h2 { margin: 0; font: 600 26px/1.15 "EB Garamond", Georgia, serif; color: #17181c; text-align: left; }
.auth-heading p { margin: 0; font: 400 16px/1.45 "Source Sans 3", sans-serif; color: #5d5f66; }

/* ===== Appens ramverk ===== */
#app-view {
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  padding-top: env(safe-area-inset-top);
  box-sizing: content-box;
  background: var(--green);
  color: var(--white);
}
.topbar-title {
  flex: 1;
  min-width: 0;
  font-family: "EB Garamond", Georgia, serif;
  font-weight: 600;
  font-size: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar .btn-small { font-size: 22px; min-width: 48px; }

/* Filterrad under toppen (gäller både karta och lista) */
.filter-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  min-width: 0;
}
.filter-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  padding: 0 14px;
  border: 2px solid var(--green);
  border-radius: 999px;
  background: var(--white);
  color: var(--green);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.filter-btn.active { background: var(--green); color: var(--white); }
.filter-badge {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--orange);
  color: var(--white);
  font-size: 13px;
  line-height: 22px;
  text-align: center;
}
.filter-bar { flex-wrap: wrap; }
.filter-chips {
  order: 3;
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.filter-chips:empty { display: none; }
.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 36px;
  padding: 0 4px 0 12px;
  border: none;
  border-radius: 999px;
  background: var(--green-light);
  color: var(--green);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.chip .x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 16px;
}
.chip:hover .x { background: rgba(0,0,0,0.08); }
.result-count { margin-left: auto; flex: none; color: var(--muted); font-size: 14px; white-space: nowrap; }

/* Knappar bredvid varandra (snabbval för datum) */
.segmented { display: flex; gap: 6px; }
.segmented button {
  flex: 1;
  min-height: 46px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.segmented button.selected { border-color: var(--green); background: var(--green); color: var(--white); }
#filter-sheet { max-height: 85vh; }
#filter-sheet .filter-row label { font-size: 15px; }
.suggestions .kind { font-weight: 700; }
.suggestions .sub { color: var(--muted); font-size: 14px; margin-left: 4px; }

.banner { background: #fff3cd; color: #6b4e00; padding: 8px 12px; font-size: 15px; text-align: center; }

main { flex: 1; position: relative; overflow: hidden; }
.view { position: absolute; inset: 0; }

.tabbar {
  flex: none;
  display: flex;
  height: var(--tabbar-h);
  padding-bottom: env(safe-area-inset-bottom);
  box-sizing: content-box;
  background: var(--white);
  border-top: 1px solid var(--border);
}
.tab {
  flex: 1;
  font: inherit;
  font-weight: 600;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.tab.active { color: var(--green); box-shadow: inset 0 4px 0 var(--green); }

/* ===== Karta ===== */
#map { position: absolute; inset: 0; }

.map-hint {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  max-width: calc(100% - 120px);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 15px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.map-hint { top: 12px; background: rgba(255,255,255,0.95); pointer-events: none; }

.leaflet-control-layers-toggle { width: 48px !important; height: 48px !important; }
.leaflet-control-layers label { font-weight: 400; margin: 0; font-size: 17px; }
.leaflet-control-layers label > span,
.leaflet-control-layers label > div { display: flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; }
.leaflet-control-layers input {
  width: 22px;
  height: 22px;
  min-height: 0;
  margin: 0;
  padding: 0;
  flex: none;
  accent-color: var(--green);
}
.leaflet-control-layers-expanded { padding: 8px 14px; }
.leaflet-control-layers-separator { margin: 6px -14px; }
.leaflet-control-zoom a { width: 44px !important; height: 44px !important; line-height: 44px !important; font-size: 22px !important; }

/* Varningstriangel för olycka och birdstrike */
.tri {
  position: relative;
  display: inline-block;
  width: var(--tri-size, 40px);
  height: calc(var(--tri-size, 40px) * 0.9);
  vertical-align: middle;
}
.tri svg { position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 2px 3px rgba(0,0,0,0.45)); }
.tri .tri-emoji {
  position: absolute;
  z-index: 1;  /* ovanpå triangeln (kartbiblioteket lägger annars svg:n överst) */
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  left: 0;
  right: 0;
  bottom: 12%;
  text-align: center;
  font-size: calc(var(--tri-size, 40px) * 0.42);
  line-height: 1;
}
.tri .tri-dot {
  position: absolute;
  z-index: 1;
  right: -3px;
  bottom: -2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid #fff;
}
.tri-wrap { background: none; border: none; }

/* Val av rapporttyp i formuläret */
.type-picker { display: flex; gap: 8px; }
.type-picker button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 76px;
  padding: 8px 4px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.type-picker .type-icon { font-size: 26px; line-height: 1; --tri-size: 32px; }
.type-picker button.selected { border-color: var(--green); background: var(--green-light); box-shadow: inset 0 0 0 1px var(--green); }
.type-picker button[data-type="olycka"].selected,
.type-picker button[data-type="birdstrike"].selected { border-color: #d32f2f; background: #fdecea; box-shadow: inset 0 0 0 1px #d32f2f; }
#filter-type { --tri-size: 20px; }
#filter-type button { font-size: 14px; padding: 0 2px; }
.type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fdecea;
  color: #b3261e;
  font-size: 13px;
  font-weight: 700;
  --tri-size: 22px;
}

/* Namn på områden (GPX) */
.leaflet-tooltip.area-label {
  background: rgba(255,255,255,0.85);
  border: none;
  border-radius: 6px;
  box-shadow: none;
  padding: 1px 6px;
  color: #7a3d00;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.leaflet-tooltip.area-label::before { display: none; }
.leaflet-tooltip.area-label-forbidden { color: #b3261e; }
.hide-area-labels .area-label { display: none; }

/* Nålar på kartan: användarens färg + djurikon */
.pin-wrap { background: none; border: none; }
.pin {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0,0,0,0.45);
}
/* Växer när man håller musen över eller har ikonen öppen */
.pin, .tri-wrap .tri { transition: transform .15s ease-out; transform-origin: center; }
.leaflet-marker-icon:hover .pin,
.marker-active .pin,
.leaflet-marker-icon:hover .tri,
.marker-active .tri { transform: scale(1.45); }

/* Informationsrutan vid musen */
.leaflet-tooltip.report-tip {
  padding: 8px 10px;
  border: none;
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
  font-family: inherit;
  white-space: normal;
  width: max-content;
  max-width: 240px;
}
.tip { display: flex; flex-direction: column; gap: 2px; font-size: 14px; color: var(--text); }
.tip strong { font-size: 15px; }
.tip .type-badge { align-self: flex-start; margin-bottom: 2px; }
.tip-comment { color: var(--muted); }
.tip-hint { color: var(--muted); font-size: 12px; margin-top: 2px; }

.popup h3 { margin: 0 0 6px; font-size: 18px; }
.popup p { margin: 3px 0; font-size: 15px; }
.popup .actions { display: flex; gap: 8px; margin-top: 10px; }
.popup .btn { min-height: 44px; padding: 0 14px; font-size: 15px; }

/* ===== Lista ===== */
#list-view { overflow-y: auto; padding: 12px 12px 24px; }

.filters {
  background: var(--white);
  border-radius: var(--radius);
  padding: 4px 12px 12px;
}
.filter-row { display: flex; gap: 10px; align-items: flex-end; }
.filter-row > * { flex: 1; min-width: 0; }
.filter-row label { font-size: 15px; margin-top: 10px; }
.filter-row input, .filter-row select { margin-top: 4px; font-weight: 400; }

.list-count { color: var(--muted); font-size: 15px; margin: 12px 4px 8px; }

.report-list { list-style: none; margin: 0; padding: 0; }
.report-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  border-left: 6px solid var(--blue);
}
.report-card.own { border-left-color: var(--orange); }
.report-card h3 { margin: 0 0 4px; font-size: 19px; display: flex; align-items: center; gap: 8px; }
.card-icon {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.report-card p { margin: 3px 0; font-size: 15px; color: var(--muted); }
.report-card .comment { color: var(--text); }
.report-card .actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.report-card .actions .btn { flex: 1 1 auto; min-height: 46px; padding: 0 12px; font-size: 15px; white-space: nowrap; }

/* ===== Formulär (glider upp) ===== */
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  max-height: 62vh;
  overflow-y: auto;
  background: var(--white);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.25);
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}
.sheet h2 { font-size: 22px; margin-bottom: 0; }
.sheet label:first-of-type { margin-top: 8px; }

.stepper { display: flex; gap: 8px; }
.stepper .btn { width: 64px; font-size: 26px; padding: 0; }
.stepper input { text-align: center; }

.sheet-buttons { display: flex; gap: 10px; margin-top: 14px; }
.sheet-buttons .btn { flex: 1; margin-top: 0; }

/* Admin i inställningar */
#settings-sheet { max-height: 85vh; }
.admin-title { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 20px; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; min-width: 0; }
.admin-list { list-style: none; margin: 0; padding: 0; }
.admin-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #eee;
  font-size: 15px;
}
.admin-list li span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.admin-list .btn { min-height: 40px; padding: 0 12px; font-size: 14px; }

/* Ny art */
.new-species {
  background: #fff4e5;
  border-radius: var(--radius);
  padding: 2px 12px 8px;
  margin-top: 10px;
}

/* Färgväljare */
.color-picker { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px var(--border);
  cursor: pointer;
}
.swatch.selected { box-shadow: 0 0 0 4px var(--text); }

/* Förslag på djurslag */
.autocomplete { position: relative; }
.suggestions {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 10;
  list-style: none;
  margin: 4px 0 0;
  padding: 4px 0;
  background: var(--white);
  border: 2px solid var(--green);
  border-radius: var(--radius);
  box-shadow: 0 6px 16px rgba(0,0,0,0.15);
  max-height: 240px;
  overflow-y: auto;
}
.suggestions li {
  padding: 12px 14px;
  cursor: pointer;
}
.suggestions li.active, .suggestions li:hover { background: var(--green-light); }

/* ===== Kort meddelande ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 24px);
  transform: translateX(-50%);
  z-index: 2000;
  background: #222;
  color: var(--white);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 16px;
  max-width: calc(100% - 32px);
  text-align: center;
}

/* Större skärm: formuläret som en panel till höger */
@media (min-width: 800px) {
  .sheet {
    left: auto;
    right: 16px;
    bottom: calc(var(--tabbar-h) + 16px);
    width: 400px;
    max-height: calc(100vh - 160px);
    border-radius: 18px;
  }
  #list-view { max-width: 800px; margin: 0 auto; }
}
