/**
 * Portal shell stacking — keep the fixed topbar above page content (including Leaflet maps).
 */

body.has-topbar {
  padding-top: var(--topbar-height, 58px);
}

@media (max-width: 900px) {
  body.has-topbar {
    padding-top: calc(var(--topbar-height, 58px) + env(safe-area-inset-top, 0px));
  }
}

body.has-topbar > .topbar {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  z-index: 2147483000 !important;
  background: #0a0a0a !important;
  box-shadow: 0 1px 0 #0a0a0a;
  transform: translateZ(0) !important;
}

html[data-theme="light"] body.has-topbar > .topbar {
  background: #ffffff !important;
  box-shadow: 0 1px 0 #ffffff;
}

body.has-topbar > .layout {
  position: relative;
  z-index: 0;
}

@media (max-width: 900px) {
  /* Layout z-index:0 traps the drawer under the dim overlay, so taps never reach links. */
  body.has-topbar.nav-open > .layout {
    z-index: auto;
  }

  body.has-topbar .nav-backdrop {
    z-index: 2147482990 !important;
    pointer-events: auto;
  }

  body.has-topbar .sidebar {
    z-index: 2147482995 !important;
    pointer-events: auto;
  }
}

/* Leaflet GPU layers can paint over fixed headers unless capped inside an isolated wrapper */
body.has-topbar .booking-map-wrap,
body.has-topbar #bookingRouteMap {
  position: relative;
  z-index: 0;
  isolation: isolate;
}

body.has-topbar .booking-map-wrap .leaflet-container,
body.has-topbar #bookingRouteMap.leaflet-container {
  z-index: 0 !important;
}

body.has-topbar .booking-map-wrap .leaflet-tile-pane,
body.has-topbar #bookingRouteMap.leaflet-container .leaflet-tile-pane {
  z-index: 1 !important;
}

body.has-topbar .booking-map-wrap .leaflet-overlay-pane,
body.has-topbar .booking-map-wrap .leaflet-pane,
body.has-topbar #bookingRouteMap.leaflet-container .leaflet-overlay-pane,
body.has-topbar #bookingRouteMap.leaflet-container .leaflet-pane {
  z-index: 2 !important;
}

body.has-topbar .booking-map-wrap .leaflet-shadow-pane,
body.has-topbar #bookingRouteMap.leaflet-container .leaflet-shadow-pane {
  z-index: 3 !important;
}

body.has-topbar .booking-map-wrap .leaflet-marker-pane,
body.has-topbar #bookingRouteMap.leaflet-container .leaflet-marker-pane {
  z-index: 4 !important;
}

body.has-topbar .booking-map-wrap .leaflet-tooltip-pane,
body.has-topbar #bookingRouteMap.leaflet-container .leaflet-tooltip-pane {
  z-index: 5 !important;
}

body.has-topbar .booking-map-wrap .leaflet-popup-pane,
body.has-topbar #bookingRouteMap.leaflet-container .leaflet-popup-pane {
  z-index: 6 !important;
}

body.has-topbar .booking-map-wrap .leaflet-top,
body.has-topbar .booking-map-wrap .leaflet-bottom,
body.has-topbar .booking-map-wrap .leaflet-control,
body.has-topbar #bookingRouteMap.leaflet-container .leaflet-top,
body.has-topbar #bookingRouteMap.leaflet-container .leaflet-bottom,
body.has-topbar #bookingRouteMap.leaflet-container .leaflet-control {
  z-index: 7 !important;
}

/* Notifications bell (shared topbar) */
.topbar-notifications {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.notifications-bell-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border, #333);
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.notifications-bell-btn:hover,
.notifications-bell-btn[aria-expanded="true"] {
  border-color: var(--accent, #a16207);
  color: var(--accent, #a16207);
}

.notifications-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #e74c3c;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  pointer-events: none;
}

.notifications-badge[hidden] {
  display: none !important;
}

.notifications-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(360px, calc(100vw - 24px));
  max-height: min(420px, calc(100vh - 80px));
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border, #333);
  border-radius: 12px;
  background: var(--card, #111);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  z-index: 2147483001;
}

.notifications-panel[hidden] {
  display: none !important;
}

.notifications-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border, #333);
}

.notifications-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  overflow-y: auto;
}

.notifications-empty {
  padding: 16px 14px;
  text-align: center;
}

.notifications-item-btn {
  display: flex;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
}

a.notifications-item-btn:hover,
a.notifications-item-btn:focus {
  text-decoration: none;
  color: inherit;
}

.notifications-item-btn:hover {
  background: rgba(201, 162, 39, 0.08);
}

.notifications-item.is-unread .notifications-item-title {
  font-weight: 700;
}

.notifications-item.is-unread .notifications-item-btn::before {
  content: "";
  position: absolute;
  left: 6px;
  width: 6px;
  height: 6px;
  margin-top: 8px;
  border-radius: 50%;
  background: var(--accent, #c9a227);
}

.notifications-item {
  position: relative;
}

.notifications-item-icon {
  flex: 0 0 auto;
  font-size: 18px;
  line-height: 1.2;
}

.notifications-item-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.notifications-item-title {
  font-size: 14px;
  line-height: 1.35;
}

.notifications-item-meta {
  font-size: 12px;
  color: var(--muted, #888);
  line-height: 1.35;
}

.notifications-mark-all {
  white-space: nowrap;
}

.notifications-panel-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--border, #333);
  text-align: center;
}

.notifications-view-all {
  display: block;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  color: var(--accent, #a16207);
}

.notifications-view-all:hover,
.notifications-view-all:focus {
  text-decoration: underline;
}

.notifications-page-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.notifications-page-list .notifications-item-btn {
  border-radius: 8px;
}

.notifications-page-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 12px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html[data-theme="light"] .notifications-panel {
  background: #fff;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

@media (max-width: 720px) {
  .notifications-panel {
    position: fixed;
    top: calc(var(--topbar-height, 58px) + env(safe-area-inset-top, 0px) + 8px);
    left: 8px;
    right: 8px;
    width: auto;
    max-height: min(70vh, calc(100dvh - var(--topbar-height, 58px) - 24px));
  }

  .notifications-item-btn {
    min-height: 48px;
    padding: 12px 14px;
  }
}
