/*
 * MarinSafe map view — hand-written CSS layered on top of the built
 * Tailwind stylesheet (tailwind.css). Only index.html.j2 links this file.
 */

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

/* Full-height layout: topbar + map fills the rest */
#layout {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#map {
  flex: 1;
  min-height: 0;
}

/* ── Bottom sheet ── */
#sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, .18);
  transform: translateY(100%);
  transition: transform .25s ease;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  max-height: 70vh;
}

#sheet.open {
  transform: translateY(0);
}

#sheet-handle {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px 0 6px;
  cursor: pointer;
  user-select: none;
}

#sheet-handle::before {
  content: '';
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: #cbd5e1;
}

#sheet-body {
  overflow-y: auto;
  overflow-x: auto;
  flex: 1;
}

/* ── Float button that opens the sheet ── */
#sheet-toggle {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  background: #1e3a8a;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .3);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: opacity .2s;
}

#sheet-toggle.hidden-btn {
  opacity: 0;
  pointer-events: none;
}

/* ── Left nav drawer ── */
#nav-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 220px;
  background: #f8fafc;
  box-shadow: 2px 0 16px rgba(0, 0, 0, .15);
  transform: translateX(-100%);
  transition: transform .2s ease;
  z-index: 1300;
  display: flex;
  flex-direction: column;
}

#nav-drawer.open {
  transform: translateX(0);
}

#nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .3);
  z-index: 1250;
  display: none;
}

#nav-overlay.open {
  display: block;
}

/* ── SOS banner ── */
@keyframes blink-sos {

  0%,
  100% {
    background: #ef4444;
    color: #fff;
  }

  50% {
    background: #fff;
    color: #ef4444;
  }
}

#sos-banner {
  position: fixed;
  top: 40px;
  left: 0;
  right: 0;
  z-index: 1050;
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
  padding: 6px;
  animation: blink-sos 1s linear infinite;
  display: none;
}

#sos-banner.visible {
  display: block;
}

/* ── Colour helpers ── */
.age-ok {
  background: #86efac;
}

.age-warn {
  background: #fdba74;
}

.age-danger {
  background: #fca5a5;
}

.bat-ok {
  background: #86efac;
}

.bat-warn {
  background: #fdba74;
}

.bat-danger {
  background: #fca5a5;
}

.sig-excellent {
  background: #4ade80;
}

.sig-good {
  background: #86efac;
}

.sig-reasonable {
  background: #fdba74;
}

.sig-bad {
  background: #fca5a5;
}

.snr-ok {
  background: #86efac;
}

.snr-warn {
  background: #fdba74;
}

.snr-danger {
  background: #fca5a5;
}

.rssi-ok {
  background: #86efac;
}

.rssi-warn {
  background: #fdba74;
}

.rssi-danger {
  background: #fca5a5;
}

.sos-row {
  animation: blink-sos 1s linear infinite;
}

thead th {
  position: sticky;
  top: 0;
  background: #eff6ff;
  z-index: 1;
  white-space: nowrap;
}

/* ── Connection badge (centred overlay) ── */
#conn-badge {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1500;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 36px;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .25);
  text-align: center;
  pointer-events: none;
  /* don't block map interaction */
  backdrop-filter: blur(4px);
}

#conn-badge.warn {
  display: flex;
  background: rgba(254, 243, 199, .95);
  border: 2px solid #d97706;
  color: #92400e;
}

#conn-badge.error {
  display: flex;
  background: rgba(254, 226, 226, .95);
  border: 2px solid #dc2626;
  color: #991b1b;
}

#conn-badge .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

#conn-badge.warn .dot {
  background: #d97706;
}

#conn-badge.error .dot {
  background: #dc2626;
  animation: blink-dot 1s linear infinite;
}

#conn-badge .badge-icon {
  font-size: 2rem;
  line-height: 1;
}

#conn-badge .badge-title {
  font-size: 1rem;
  font-weight: 700;
}

#conn-badge .badge-sub {
  font-size: 0.75rem;
  opacity: .8;
}

/* ── Leaflet tooltip overrides ── */
.leaflet-tooltip {
  padding: 10px 12px !important;
  border-radius: 10px !important;
  border: 1px solid #e2e8f0 !important;
  box-shadow: 0 4px 16px rgba(0,0,0,.12) !important;
  background: #fff !important;
}

@keyframes blink-dot {

  0%,
  100% {
    opacity: 1
  }

  50% {
    opacity: .2
  }
}
