@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Lato:wght@300;700&display=swap');

:root {
  --color-background: #5472fb;
  /* Simactis blue */
  --color-foreground: #4ef622;
  /* Simactis green */
  --font-title: 'Poppins', sans-serif;
  --font-paragraph: 'Lato', sans-serif;

  /* UI extras */
  --text: rgba(255, 255, 255, 0.96);
  --muted: rgba(255, 255, 255, 0.82);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  --radius: 16px;
}

html, body {
  height: 100%;
  margin: 0;
}

body.simactis-map {
  font-family: var(--font-paragraph), system-ui, sans-serif;
  background: var(--color-background);
  color: var(--text);
  overflow: hidden;
}

#map {
  position: fixed;
  inset: 0;
}

#map{ background: var(--color-background); }
#map .ol-viewport{ background: transparent; }

/* ===== Panel card ===== */
.panel-card {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 1000;

  width: min(280px, calc(100vw - 32px));
  /* narrower */
  border-radius: var(--radius);
  background: var(--color-background);
  /* SOLID = matches logo */
  border: none;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;

  padding: 18px 16px 14px;
  /* more breathing room */
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.panel-body {
  padding: 16px 16px 18px;
  /* more space from edges */
  line-height: 1.25;
  user-select: none;
}

#layerPanel {
  max-height: 65vh;
  display: flex;
  flex-direction: column;
}

#layerPanel .panel-header {
  flex: 0 0 auto;
}

#layerPanel .panel-body {
  flex: 1 1 auto;
  overflow: auto;
  scrollbar-gutter: stable;
  overflow-anchor: none;
  /* prevents weird jump-to-anchor behavior */
  overscroll-behavior: contain;
  /* stops scroll chaining to the map */
  -webkit-overflow-scrolling: touch;
  /* smoother iOS scrolling */
  touch-action: pan-y;
}

.brand {
  display: flex;
  gap: 16px;
  /* was smaller */
  align-items: center;
  min-width: 0;
}

.brand-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 14px;
  background: transparent;
  /* key fix */
  padding: 0;
  /* key fix */
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 6px;
}

.brand-title {
  font-family: var(--font-title);
  font-weight: 700;
  color: white;
  /* never green in panel */
  font-size: 16px;
  line-height: 1.1;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 0;
}

.panel-collapse-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.10);
  color: var(--text);
  border-radius: 12px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.panel-collapse-btn:hover {
  border-color: rgba(255, 255, 255, 0.55);
  background: rgba(0, 0, 0, 0.14);
}

.panel-collapse-btn .chev {
  font-size: 16px;
  transform: translateY(-1px);
}

/* Collapsed state */
.panel-card.is-collapsed .panel-body {
  display: none;
}

.panel-card.is-collapsed .panel-collapse-btn .chev {
  transform: rotate(-90deg);
}

/* Body */
.panel-body h3 {
  margin: 14px 0 10px;
  font-family: var(--font-title);
  font-size: 13px;
  letter-spacing: 0.2px;
  color: white;
}

.section {
  margin-bottom: 16px;
}

.section:last-child {
  margin-bottom: 0;
}

.indent {
  margin-left: 14px;
  padding-left: 12px;
  /* a touch more */
  border-left: 1px solid rgba(255, 255, 255, 0.20);
}

.hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

/* ===== Themed scrollbar (blue) for the layer panel ===== */
#layerPanel .panel-body{
  /* Firefox */
  scrollbar-width: thin;
  scrollbar-color: rgba(84,114,251,0.65) rgba(8,18,60,0.25);
}

/* Chrome / Edge / Safari */
#layerPanel .panel-body::-webkit-scrollbar{
  width: 10px;
}

#layerPanel .panel-body::-webkit-scrollbar-track{
  background: rgba(8,18,60,0.25);          /* deep navy */
  border-radius: 999px;
}

#layerPanel .panel-body::-webkit-scrollbar-thumb{
  background: rgba(84,114,251,0.70);       /* theme blue */
  border-radius: 999px;
  border: 2px solid rgba(8,18,60,0.25);    /* track-colored border */
}

#layerPanel .panel-body::-webkit-scrollbar-thumb:hover{
  background: rgba(84,114,251,0.88);
}

#layerPanel .panel-body::-webkit-scrollbar-corner{
  background: transparent;
}

/* ===== Collapsible layer groups ===== */
.layer-group__head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.group-collapse-btn{
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(8,18,60,0.25);
  color: rgba(255,255,255,0.9);
  cursor: pointer;
}

.group-collapse-btn:hover{
  background: rgba(84,114,251,0.18);
  border-color: rgba(84,114,251,0.35);
}

.layer-group.is-collapsed .indent{ display: none; }

.layer-group.is-collapsed .group-collapse-btn .chev{
  transform: rotate(-90deg);
}

.group-collapse-btn .chev{
  transition: transform 160ms ease;
}

/* ===== Pill switches ===== */
.pill-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
  font-size: 13px;
  color: white;
  position: relative;
  /* always white in panel */
}

.pill-row--group {
  font-weight: 700;
}

.pill-input {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;

  /* visually hidden but still focusable & accessible */
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.pill {
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.20);
  border: 1px solid rgba(255, 255, 255, 0.22);
  position: relative;
  flex: 0 0 auto;
}

.pill::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 3px;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  transition: left 140ms ease, background 140ms ease;
}

/* Checked: green toggle only */
.pill-input:checked+.pill {
  background: rgba(78, 246, 34, 0.40);
  border-color: rgba(78, 246, 34, 0.55);
}

.pill-input:checked+.pill::after {
  left: 21px;
  background: var(--color-foreground);
}

/* Keyboard focus */
.pill-row:focus-within .pill {
  outline: 2px solid rgba(78, 246, 34, 0.65);
  outline-offset: 2px;
}

/* Place sample card bottom-left */
.panel-card--sample {
  top: auto;
  left: 16px;
  bottom: 16px;
  width: min(280px, calc(100vw - 32px));
}

/* Form styling */
.sample-form {
  display: grid;
  gap: 10px;
}

.sample-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.9);
}

.sample-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.10);
  color: rgba(255, 255, 255, 0.96);
  font-family: var(--font-paragraph), system-ui, sans-serif;
  outline: none;
}

.sample-input::placeholder {
  color: rgba(255, 255, 255, 0.70);
}

.sample-input:focus {
  border-color: rgba(78, 246, 34, 0.65);
  box-shadow: 0 0 0 2px rgba(78, 246, 34, 0.25);
}

.sample-btn:hover {
  filter: brightness(0.95);
}

.sample-status {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.88);
  min-height: 16px;
}

/* Hide honeypot */
.hp {
  display: none;
}

/* compact header for sample card */
.panel-header--compact {
  padding: 14px 16px 12px;
}

/* stack title + subtitle vertically */
.brand--stack {
  width: 100%;
}

.sample-subtitle {
  margin: 0;
}

/* When collapsed: show only heading (hide subtitle + body) */
#sampleCard.is-collapsed .sample-subtitle {
  display: none;
}

#sampleCard.is-collapsed .panel-body {
  display: none;
}

/* rotate chevron when collapsed */
#sampleCard.is-collapsed .panel-collapse-btn .chev {
  transform: rotate(-90deg);
}

/* input + icon button row */
.sample-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* keep input full width */
.sample-input {
  flex: 1 1 auto;
}

/* icon send button */
.send-btn {
  width: 44px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.10);
  color: rgba(255, 255, 255, 0.95);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.send-btn:hover {
  border-color: rgba(78, 246, 34, 0.55);
  background: rgba(0, 0, 0, 0.14);
  color: var(--color-foreground);
}

.send-btn:focus {
  outline: 2px solid rgba(78, 246, 34, 0.65);
  outline-offset: 2px;
}

.panel-card--sample .brand-title{
  font-family: var(--font-paragraph), system-ui, sans-serif; /* match pill-row */
  font-size: 13px;                                          /* match pill-row */
  font-weight: 700;                                         /* match pill-row--group */
  letter-spacing: 0.2px;                                    /* optional: like your h3 */
  line-height: 1.15;
}


/* ===== Popup ===== */
.popup {
  background: rgba(8, 18, 60, 0.92);
  color: rgba(255, 255, 255, 0.96);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: var(--shadow);
  padding: 10px 12px;
  min-width: 260px;
  max-width: min(380px, calc(100vw - 28px));
  backdrop-filter: blur(10px);
  position: relative;
}

.popup-title {
  font-family: var(--font-title);
  font-size: 13px;
  margin: 0 0 6px 0;
  color: var(--color-foreground);
}

.popup pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.92);
}

.popup-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;

  border: 1px solid rgba(255, 255, 255, 0.20);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
  color: rgba(255, 255, 255, 0.95);

  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;

  font-size: 16px;
  line-height: 1;
}

.popup-close:hover {
  background: rgba(0, 0, 0, 0.28);
  border-color: rgba(255, 255, 255, 0.35);
}

.popup-close:focus {
  outline: 2px solid rgba(78, 246, 34, 0.65);
  outline-offset: 2px;
}

/* ===== OpenLayers controls ===== */
.ol-control button {
  background: rgba(8, 18, 60, 0.75) !important;
  color: rgba(255, 255, 255, 0.96) !important;
  border-radius: 12px !important;
  border: 1px solid rgba(255, 255, 255, 0.20) !important;
  box-shadow: none !important;
}

.ol-control button:hover {
  background: rgba(8, 18, 60, 0.92) !important;
  border-color: rgba(255, 255, 255, 0.35) !important;
}

.ol-zoom {
  top: 14px !important;
  right: 14px !important;
  left: auto !important;
}

/* Mobile */
@media (max-width: 600px) {
  .panel-card {
    width: calc(100vw - 28px);
  }

  #layerPanel {
    max-height: 60vh;
  }
}