/* ==========================================================================
   SAR Watch — feuille de style
   ========================================================================== */

/* --- Palette et variables ------------------------------------------------ */
:root {
  --bg: #081b36;
  --panel: #0B2545;
  --panel-edge: #1e4380;
  --accent: #35e0a1;
  --accent-dim: #1c7a56;
  --amber: #FF6B00;
  --amber-dim: #b34e00;
  --text: #d7e4e8;
  --muted: #7d96b8;
}

/* --- Reset et base -------------------------------------------------------- */
* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.mono {
  font-family: "SF Mono", "Courier New", monospace;
}

#app {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* --- En-tête (mobile uniquement — masqué par défaut, voir media query) ---- */
header {
  display: none;
  position: relative;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 64px;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: var(--panel);
  border-bottom: 1px solid var(--panel-edge);
  z-index: 1000;
}

.header-title {
  display: flex;
  align-items: center;
}

/* --- Logo flottant (bureau) : sans conteneur, au-dessus de la carte ------- */
.brand-floating {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 1000;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.header-title .brand {
  flex-direction: row;
  gap: 10px;
}

.brand-floating .brand {
  flex-direction: column;
  gap: 6px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.logo-img {
  flex-shrink: 0;
  border-radius: 50%;
}

.header-title .logo-img {
  width: 44px;
  height: 44px;
}

.brand-floating .logo-img {
  width: 110px;
  height: 110px;
}

.brand-word {
  display: block;
  line-height: 1;
  color: #ffffff;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.header-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  row-gap: 6px;
  min-width: 0;
}

/* --- Indicateur de statut -------------------------------------------------- */
.status {
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--panel-edge);
  color: var(--muted);
  font-size: clamp(0.62rem, 2.2vw, 0.72rem);
  white-space: nowrap;
  flex-shrink: 1;
}

.status.live {
  color: var(--accent);
  border-color: var(--accent-dim);
}

.status.live::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.25; }
}

/* --- Boutons d'en-tête (langue, bascule missions) -------------------------- */
.lang-switch,
#toggleSidebar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-height: 32px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--panel-edge);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 0.78rem;
  text-decoration: none;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.lang-switch:hover,
#toggleSidebar:hover,
#toggleSidebar:active {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: rgba(53, 224, 161, 0.08);
}

#notifyToggle.alerts-on {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: rgba(53, 224, 161, 0.12);
}

#notifyToggle.alerts-off {
  color: #ff6b6b;
  border-color: #a13d3d;
  background: rgba(255, 107, 107, 0.1);
}

/* --- Mise en page principale (carte + barre latérale) ---------------------- */
#main {
  flex: 1;
  display: flex;
  min-height: 0;
}

#map {
  flex: 1;
  background: #060d16;
}

#sidebar {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--panel-edge);
}

.sidebar-top {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px;
  padding-top: max(14px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--panel-edge);
}

.sidebar-header {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 6px;
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-tabs {
  display: flex;
  flex-shrink: 0;
  gap: 6px;
  padding: 10px 14px 0;
}

.sidebar-tab {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
}

.sidebar-tab.active {
  color: var(--text);
  border-color: var(--accent-dim);
  background: rgba(53, 224, 161, 0.1);
}

.ships-filters {
  flex-shrink: 0;
  padding: 10px 14px;
}

#shipSearch {
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 8px;
  border: 1px solid var(--panel-edge);
  border-radius: 6px;
  background: #081019;
  color: var(--text);
  font-size: 0.82rem;
}

.filter-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  padding: 5px 10px;
  border: 1px solid var(--panel-edge);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  cursor: pointer;
}

.chip.active {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: rgba(53, 224, 161, 0.1);
}

#missionList {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

#closeSidebar {
  display: none;
  padding: 4px 8px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

/* --- Liste des missions ----------------------------------------------------- */
.mission-item {
  padding: 10px 14px;
  border-bottom: 1px solid #12202c;
  cursor: pointer;
}

.mission-item:hover {
  background: #10202f;
}

.mission-item .name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
}

.mission-item .badge {
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--amber-dim);
  color: var(--amber);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mission-item .badge.closed {
  color: var(--muted);
  border-color: var(--panel-edge);
}

.mission-item .meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.5;
}

.mission-item .meta b {
  color: var(--text);
  font-weight: 500;
}

.mission-item .reason-warning {
  color: var(--amber);
  font-style: italic;
}

.empty {
  padding: 24px 16px;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.sidebar-footer {
  display: flex;
  flex-shrink: 0;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--panel-edge);
  color: var(--muted);
  font-size: 0.68rem;
}

.sidebar-footer a {
  color: var(--muted);
  text-decoration: none;
}

.sidebar-footer a:hover {
  color: var(--accent);
}

.brittany-flag {
  width: 18px;
  height: 12px;
  border-radius: 2px;
  vertical-align: middle;
}

/* --- Marqueurs et popups Leaflet -------------------------------------------- */
.sar-marker {
  width: 12px;
  height: 12px;
  border: 2px solid #06231a;
  border-radius: 50%;
  background: var(--accent);
}

.sar-marker.on-mission {
  background: var(--amber);
}

.sar-arrow {
  fill: var(--accent);
  stroke: #06231a;
  stroke-width: 1;
}

.sar-arrow.on-mission {
  fill: var(--amber);
}

.leaflet-popup-content-wrapper {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--panel-edge);
}

.leaflet-popup-tip {
  background: var(--panel);
}

.leaflet-popup-content {
  margin: 10px 12px;
  font-size: 0.8rem;
}

.leaflet-popup-content b {
  color: var(--accent);
}

/* --- Pages annexes (mentions légales, confidentialité) ---------------------- */
.legal-body {
  overflow: auto;
  height: auto;
  min-height: 100%;
}

.legal-page {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
  padding: 60px 20px 80px;
}

.legal-back {
  display: inline-block;
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: none;
}

.legal-back:hover {
  color: var(--accent);
}

.legal-lang {
  position: absolute;
  top: 20px;
  right: 20px;
}

.legal-page h1 {
  font-size: 1.6rem;
  font-weight: 600;
  color: #ffffff;
  margin: 0 0 28px;
}

.legal-page h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  margin: 28px 0 8px;
}

.legal-page p {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text);
  margin: 0 0 6px;
}

.legal-page a {
  color: var(--accent);
}

/* --- Légende de la carte ----------------------------------------------------- */
.map-legend {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.72rem;
  color: var(--text);
  line-height: 1.9;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.legend-dot-green { background: var(--accent); }
.legend-dot-amber { background: var(--amber); }

.legend-line {
  display: inline-block;
  width: 16px;
  height: 2px;
  margin-right: 6px;
  vertical-align: middle;
}

.legend-line-amber { background: #FF6B00; }
.legend-line-grey { background: #5c7a86; }

/* --- Mobile (< 640px) -------------------------------------------------------- */
@media (max-width: 640px) {
  header {
    display: flex;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }

  .brand-floating {
    display: none;
  }

  /* la barre latérale devient un panneau plein écran, glissé depuis le bas */
  #sidebar {
    position: fixed;
    inset: 0;
    z-index: 1500;
    width: 100%;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    transform: translateY(100%);
    transition: transform 0.25s ease;
  }

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

  #toggleSidebar,
  #closeSidebar {
    display: inline-flex !important;
  }

  .mission-item {
    padding: 12px 16px; /* cible tactile plus large */
  }

  .leaflet-control-zoom {
    margin-bottom: max(10px, env(safe-area-inset-bottom)) !important;
  }
}
