/* Whole page */
html, body { margin:0; padding:0; height:100%; width:100%; }

/* Reserve space so fixed bottom bar doesn't overlap content */
:root { --download-bar-height: 64px; }
body { padding-bottom: var(--download-bar-height); }

/* Toast (auto-added by JS) */
#toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--download-bar-height) + 12px);
  background: rgba(51,51,51,0.95);
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  font: 14px/1.25 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  box-shadow: 0 6px 16px rgba(0,0,0,0.35);
  z-index: 2000;          /* above canvas and the bottom bar */
  pointer-events: none;   /* clicks pass through */
  opacity: 0;
  transition: opacity .25s ease;
}
#toast.error { background: #b00020; }

/* Top Banner */
.banner {
  background: linear-gradient(135deg, #004e92, #000428);
  color: white;
  text-align: center;
  padding: 1.1rem 1rem 1rem;
  font-family: "Segoe UI", sans-serif;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  position: relative;
  z-index: 1000;
}

/* Dropdown bases (Settings & Account share styles) */
.banner details {
  position: absolute;
  top: 0.75rem;
  color: #fff;
  cursor: pointer;
}
.banner details summary {
  list-style: none;
  font-weight: 600;
  padding: 0.4rem 0.6rem;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 8px;
  user-select: none;
  background: rgba(255,255,255,0.06);
}
.banner details summary::-webkit-details-marker { display: none; }
.banner details[open] summary { background: rgba(255,255,255,0.12); }

.dropdown-panel {
  position: absolute;
  margin-top: 0.5rem;
  right: 1rem;                      /* default drop direction for Account */
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 10px;
  padding: 0.75rem;
  min-width: 280px;
  z-index: 1002;                 /* above map & banner */
}
.dropdown-panel label {
  display: grid; gap: 0.35rem; margin-bottom: 0.6rem; font-size: 0.9rem;
}
.dropdown-panel input[type="number"],
.dropdown-panel input[type="email"],
.dropdown-panel input[type="password"] {
  width: 100%; padding: 0.45rem 0.6rem; border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.12); color: #fff; outline: none;
}

/* Buttons inside the dropdown */
.button-row {
  display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.25rem;
}
.button-col {
  display: grid; gap: 0.5rem; grid-auto-rows: minmax(34px, auto);
}
.dropdown-panel button {
  padding: 0.45rem 0.8rem; border-radius: 8px; border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.1); color:#fff; cursor:pointer;
}
.dropdown-panel button:hover { background: rgba(255,255,255,0.18); }

/* Welcome tag (left, below Settings) */
.welcome {
  position: absolute; top: 0.75rem; left: 9.5rem;  /* leaves room for Settings summary */
  color:#fff; font-size: .95rem; opacity:.95;
  padding: .25rem .5rem; border-radius: 6px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.25);
  display: none;
}

/* Map */
#map {
  height: 600px;
  width: 100%;
  overscroll-behavior: contain;
  touch-action: none;
  z-index: 100;
}

/* Send to Server Button */
#sendButton {
  display: block;       /* makes it behave like a block element */
  width: 100%;          /* full width */
  padding: 1rem;        /* taller button */
  font-size: 1.1rem;    /* larger text */
  background: #004e92;  /* same gradient style as banner if you want */
  color: white;
  border: none;
  cursor: pointer;
}
#sendButton:hover {
  background: #006ad1;  /* hover effect */
}

/* For any element marked hidden */
[hidden] { display: none !important; }

/* Download bar – always visible at the bottom */
#downloadCurrentButton {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  width: 100%;
  padding: 1rem;
  font-size: 1.1rem;
  background: #004e92;
  color: #fff;
  border: none;
  cursor: pointer;
  z-index: 1500;                        /* above map/canvas */
  box-shadow: 0 -3px 12px rgba(0,0,0,0.35);
  border-top: 1px solid rgba(255,255,255,0.12);
}
#downloadCurrentButton:hover { background: #006ad1; }
#downloadCurrentButton:disabled { opacity: .5; cursor: not-allowed; }

/* Login and user buttons */
.auth-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 0.5rem;
}
.auth-controls input, .auth-controls button {
  padding: 0.4rem 0.6rem; border-radius:8px; border:1px solid rgba(255,255,255,0.25);
}

/* Modal for user Models */
.modal {
  position: fixed; inset: 0; display: none;
  z-index: 2000;  /* above banner/map */
}
.modal.is-open {
  display: block;
}
.modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(2px);
}
.modal__dialog {
  position: relative; margin: 5vh auto; max-width: 720px;
  background: #0f1115; color: #fff;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  overflow: hidden;
}
.modal__header, .modal__footer {
  padding: 0.9rem 1rem; background: rgba(255,255,255,0.04);
  display: flex; align-items: center; justify-content: space-between;
}
.modal__body { padding: 1rem; max-height: 60vh; overflow: auto; }
.modal__close {
  background: transparent; border: 0; color: #fff; font-size: 1.6rem; cursor: pointer;
}
.models-table {
  width: 100%; border-collapse: collapse; font-family: system-ui, Segoe UI, sans-serif;
}
.models-table th, .models-table td {
  padding: 0.6rem 0.5rem; border-bottom: 1px solid rgba(255,255,255,0.12);
  vertical-align: middle; font-size: 0.95rem;
}
.models-table th { text-align: left; opacity: 0.9; }
.models-actions a, .models-actions button {
  margin-right: 0.4rem; padding: 0.35rem 0.6rem; border-radius: 8px; border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.06); color: #fff; text-decoration: none; cursor: pointer;
}
.models-actions a:hover, .models-actions button:hover {
  background: rgba(255,255,255,0.12);
}

/* Optional generic button */
.btn {
  padding: 0.5rem 0.9rem; border-radius: 8px; border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.06); color: #fff; cursor: pointer;
}
.btn:hover { background: rgba(255,255,255,0.12); }

/* Place Account dropdown on the RIGHT */
.banner .account {
  position: absolute;
  top: 0.75rem;
  right: 1rem;   /* <- right edge */
  left: auto;
  z-index: 1001;
}
/* Account panel drops to the right edge of its summary */
.banner .account .dropdown-panel {
  right: 0;
  left: auto;
}

/* Ensure Model Settings is on the LEFT (summary) */
.banner .settings {
  position: absolute;
  top: 0.75rem;
  left: 1rem;    /* <- left edge */
  right: auto;
  z-index: 1001;
}
/* Settings panel aligns to the left of its summary and stacks vertically */
.banner .settings .dropdown-panel {
  left: 0;
  right: auto;
}

/* Make inputs full width in both dropdowns, for consistency */
.banner .dropdown-panel input[type="number"],
.banner .dropdown-panel input[type="email"],
.banner .dropdown-panel input[type="password"],
.banner .dropdown-panel input[type="text"] {
  width: 100%;
}

/* Right-align number inputs inside Model Settings panel */
.banner .settings .dropdown-panel label {
  display: flex;
  justify-content: space-between; /* push label text left, input right */
  align-items: center;           /* keep vertical alignment */
  gap: 0.5rem;
}

/* Inputs: consistent width and right aligned */
.banner .settings .dropdown-panel input[type="number"] {
  width: 6rem;                   /* fixed width for neat alignment */
  max-width: 100%;
  text-align: right;             /* numbers align nicely */
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.12);
  color: #fff;
  padding: 0.3rem 0.4rem;
}

/* Keep Account panel constrained and clip any bleed */
.banner .account .dropdown-panel {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: 320px;
  overflow: hidden;            /* <- prevents edges from overflowing */
}

/* ✅ Fix selector (remove stray space after .account .) and keep inputs inside */
.banner .account .dropdown-panel input[type="email"],
.banner .account .dropdown-panel input[type="password"] {
  width: 100%;
  box-sizing: border-box;       /* <- include padding/border in width */
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.12);
  color: #fff;
  padding: 0.45rem 0.6rem;
}

/* Right-justify the login/register/logout row */
.button-row {
  display: flex;
  justify-content: flex-end;  /* <- push buttons to right side */
  gap: 0.5rem;
  margin-top: 0.25rem;
}

/* Disabled-looking state for Save + My Models when logged out */
.btn-disabled {
  opacity: 0.25;
  cursor: not-allowed;
  pointer-events: none; /* stops clicks */
}

/* Scope your custom button styles to the banner only */
.banner .dropdown-panel button,
.banner .button-row button,
.banner .button-col button {
  /* your existing button styles here */
}

/* Guardrail: ensure Leaflet control buttons look right */
.leaflet-bar a,
.leaflet-bar a:hover {
  background: #fff;
  color: #000;
  display: block;
  width: 46px;
  height: 46px;
  line-height: 46px;
  text-align: center;
  text-decoration: none;
  border-bottom: 1px solid #ccc;
  box-shadow: none;
  border-radius: 0;
  font: bold 10px/40px "Lucida Grande", Arial, sans-serif;
}

/* Don’t let any global flex/grid rules squeeze the toolbar */
.leaflet-draw-toolbar,
.leaflet-draw-actions {
  all: initial;           /* reset accidental site-wide rules */
  font-family: inherit;   /* then allow default font */
}