*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  font-size: 14px;
  color: #1a1a2e;
}

/* Ilman ?admin=1: ei sivupaneelia (piirtotyökalut, tallennus, merkinnät) */
body.map-public #sidebar {
  display: none !important;
}

#map {
  position: absolute;
  inset: 0;
  z-index: 0;
}

/* ── Sidebar ── */
.sidebar {
  position: absolute;
  top: 0;
  right: 0;
  width: 360px;
  height: 100%;
  z-index: 1000;
  transition: transform 0.3s ease;
  display: flex;
}

.sidebar.closed {
  transform: translateX(360px);
}

.sidebar-toggle {
  position: absolute;
  left: -44px;
  top: 10px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px 0 0 8px;
  background: #fff;
  box-shadow: -2px 2px 8px rgba(0,0,0,0.15);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1a1a2e;
  transition: background 0.2s;
}

.sidebar-toggle:hover {
  background: #e8eaf6;
}

.sidebar-content {
  flex: 1;
  background: #fff;
  box-shadow: -2px 0 12px rgba(0,0,0,0.12);
  overflow-y: auto;
  padding: 20px;
}

.sidebar-content h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  color: #0d47a1;
}

.sidebar-section {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e0e0e0;
}

.sidebar-section:last-child {
  border-bottom: none;
}

.sidebar-section h3 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #546e7a;
  margin-bottom: 8px;
}

.hint {
  font-size: 12px;
  color: #78909c;
  line-height: 1.5;
}

/* ── Form ── */
.form-group {
  margin-bottom: 10px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #455a64;
  margin-bottom: 4px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #cfd8dc;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #1976d2;
  box-shadow: 0 0 0 2px rgba(25,118,210,0.15);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border: 1px solid #cfd8dc;
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:hover {
  background: #f5f5f5;
}

.btn-primary {
  background: #1976d2;
  color: #fff;
  border-color: #1976d2;
}

.btn-primary:hover {
  background: #1565c0;
}

.btn-primary.active {
  background: #e65100;
  border-color: #e65100;
}

.btn-success {
  background: #2e7d32;
  color: #fff;
  border-color: #2e7d32;
}

.btn-success:hover {
  background: #1b5e20;
}

.btn-danger {
  background: #c62828;
  color: #fff;
  border-color: #c62828;
  padding: 4px 8px;
  font-size: 11px;
}

.btn-danger:hover {
  background: #b71c1c;
}

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Features list ── */
.features-list {
  max-height: 200px;
  overflow-y: auto;
}

.feature-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 6px;
  margin-bottom: 4px;
  transition: background 0.15s;
}

.feature-item:hover {
  background: #e3f2fd;
}

.feature-item-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  flex: 1;
  min-width: 0;
}

.feature-item-label span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feature-icon {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

/* ── Popup styling ── */
.custom-popup .leaflet-popup-content-wrapper {
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.custom-popup .leaflet-popup-content {
  margin: 12px 16px;
  font-size: 13px;
  line-height: 1.6;
}

.popup-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 6px;
  color: #0d47a1;
}

.popup-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #1976d2;
  text-decoration: none;
  font-weight: 500;
}

.popup-link:hover {
  text-decoration: underline;
}

.popup-info-table {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.6;
}

/* Kuva overlay (keskellä ruutua) */
.image-overlay-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-overlay-img {
  display: block;
  max-width: min(96vw, 1200px);
  max-height: min(86vh, 900px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

.image-overlay-top-right {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  max-width: calc(100% - 24px);
  text-align: right;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9), 0 0 14px rgba(0, 0, 0, 0.55);
  line-height: 1.35;
  pointer-events: none;
}

/* ── Custom marker icons ── */
.marker-icon-image,
.marker-icon-video,
.marker-icon-info {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #fff;
  font-size: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  border: 2px solid #fff;
}

.marker-icon-image { background: #43a047; }
.marker-icon-video { background: #e53935; }
.marker-icon-info  { background: #1e88e5; }

/* Pienoiskuva kartalla (L.Icon) */
.leaflet-marker-icon.marker-thumbnail-icon {
  border-radius: 8px;
  border: 2px solid #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

/* ── Drawn shapes style popup ── */
.shape-popup-form label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 3px;
  color: #455a64;
}

.shape-popup-form input,
.shape-popup-form textarea {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #cfd8dc;
  border-radius: 4px;
  font-size: 12px;
  margin-bottom: 8px;
}

.shape-popup-form .btn {
  font-size: 12px;
  padding: 5px 10px;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .sidebar {
    width: 100%;
  }
  .sidebar.closed {
    transform: translateX(100%);
  }
}

/* ── Video overlay (kokoruutu) ── */
.video-overlay {
  position: fixed;
  inset: 0;
  z-index: 8000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-top: 56px;
  background: rgba(0, 0, 0, 0.88);
  cursor: default;
}

.video-overlay-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.video-overlay-close:hover {
  background: rgba(255, 255, 255, 0.22);
}

.video-overlay-title {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 64px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.video-overlay-stage {
  max-width: min(96vw, 1200px);
  max-height: min(88vh, 800px);
  width: 100%;
}

.video-overlay-player {
  width: 100%;
  max-height: min(88vh, 800px);
  border-radius: 8px;
  background: #000;
  vertical-align: middle;
}

/* Videon tilapäinen teksti (nuoli + otsikko), esim. Alue 4 */
.video-overlay-badge {
  position: absolute;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  max-width: min(42vw, 340px);
  text-align: right;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9), 0 0 14px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.video-overlay-badge--hide {
  opacity: 0;
}

.video-overlay-badge-arrow {
  font-size: 28px;
  line-height: 1;
  font-weight: 700;
}

.video-overlay-badge-text {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
}
