@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,600;0,9..40,700;1,9..40,400&family=IBM+Plex+Mono:wght@400;500&display=swap");

:root {
  color-scheme: dark;
  --bg0: #0b1014;
  --bg1: #121a21;
  --panel: #162029;
  --text: #e8eef4;
  --muted: #8b9aab;
  --line: #2a3846;
  --accent: #3ecf8e;
  --accent-dim: #1f6b4a;
  --alarm: #ff5c5c;
  --warn: #e6b35a;
  --map-ink: #9ad7ff;
  --font: "DM Sans", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, #1a2e28 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #1a2433 0%, transparent 50%),
    var(--bg0);
  color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.portal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 16, 20, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { text-decoration: none; color: var(--accent); }
.portal-header nav {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  flex-wrap: wrap;
}
.portal-header nav a {
  color: var(--muted);
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
}
.portal-header nav a:hover { color: var(--text); background: var(--bg1); text-decoration: none; }
.portal-header nav a.nav-active:not(.nav-alarm) {
  color: var(--bg0);
  background: var(--accent);
}
/* Vol en cours : toujours rouge (même sur la page Vol active). */
.portal-header nav a.nav-alarm {
  color: #fff;
  background: var(--alarm);
  box-shadow: none;
}
.portal-header nav a.nav-alarm:hover {
  color: #fff;
  background: #ff7070;
  text-decoration: none;
}

.layout-activity {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  min-height: calc(100vh - 60px);
}
.side {
  border-right: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 60px);
  overflow: hidden;
}
.side-top {
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--line);
}
.side-top label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.side-top input[type="date"] {
  width: 100%;
  font: inherit;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg0);
  color: var(--text);
}
.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-top: 0.85rem;
}
.summary div {
  background: var(--bg0);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.45rem;
  text-align: center;
}
.summary strong {
  display: block;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}
.summary span {
  font-size: 0.72rem;
  color: var(--muted);
}
.trip-list {
  overflow: auto;
  flex: 1;
  padding: 0.5rem;
}
.trip-item {
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.7rem 0.75rem;
  cursor: pointer;
  margin-bottom: 0.35rem;
}
.trip-item:hover { background: var(--bg1); }
.trip-item.active {
  background: rgba(62, 207, 142, 0.12);
  border-color: var(--accent-dim);
}
.trip-item .when {
  font-family: var(--mono);
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}
.trip-item .meta {
  color: var(--muted);
  font-size: 0.82rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}
.map-pane {
  position: relative;
  min-height: 420px;
}
#map, #alarm-map {
  position: absolute;
  inset: 0;
  background: #0e151c;
}
.map-stats {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 0.75rem;
  z-index: 500;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  pointer-events: none;
}
.map-stats .chip {
  pointer-events: none;
  background: rgba(11, 16, 20, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
  font-size: 0.85rem;
}
.map-stats .chip b { font-family: var(--mono); font-weight: 500; }
.empty-side {
  color: var(--muted);
  padding: 1.25rem;
  line-height: 1.45;
}

.alarm-shell {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  min-height: calc(100vh - 60px);
}
.theft-banner {
  display: block;
  background: var(--alarm);
  color: #fff;
  text-align: center;
  font-size: clamp(1.05rem, 3.2vw, 1.65rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  padding: 0.85rem 1rem;
  animation: theft-pulse 1.2s ease-in-out infinite;
}
a.theft-banner-link {
  color: #fff;
  text-decoration: none;
}
a.theft-banner-link:hover {
  color: #fff;
  text-decoration: underline;
  filter: brightness(1.08);
}
.theft-banner[hidden] { display: none !important; }
@keyframes theft-pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.15); }
}
body.is-theft .portal-header {
  border-bottom-color: var(--alarm);
}
.alarm-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.alarm-bar .status-live {
  color: var(--alarm);
  font-weight: 700;
  letter-spacing: 0.02em;
}
.alarm-bar .status-calm {
  color: var(--accent);
  font-weight: 700;
}
.alarm-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.alarm-meta b {
  color: var(--text);
  font-family: var(--mono);
  font-weight: 500;
}
.alarm-map-wrap { position: relative; min-height: 60vh; }
.alarm-calm-msg {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 400;
  background: rgba(11, 16, 20, 0.55);
  text-align: center;
  padding: 1.5rem;
}
body.is-theft .alarm-calm-msg,
.alarm-calm-msg.is-hidden {
  display: none !important;
}
.alarm-calm-msg h2 { margin: 0 0 0.5rem; font-size: 1.5rem; }
.alarm-calm-msg p { margin: 0; color: var(--muted); }
.btn-dismiss {
  font: inherit;
  font-weight: 700;
  border: 0;
  border-radius: 10px;
  padding: 0.65rem 1rem;
  cursor: pointer;
  background: var(--accent);
  color: var(--bg0);
}
.btn-dismiss:hover { filter: brightness(1.06); }
.btn-dismiss:disabled {
  opacity: 0.55;
  cursor: default;
}
.alarm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg1);
}
.alarm-actions[hidden] { display: none !important; }
.alarm-actions .hint { color: var(--muted); font-size: 0.88rem; }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(800px 400px at 50% 0%, #1f3a30 0%, transparent 60%),
    var(--bg0);
}
.login-card {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.75rem;
  display: grid;
  gap: 0.7rem;
}
.login-card h1 {
  margin: 0;
  font-size: 2rem;
  letter-spacing: -0.03em;
}
.login-card .tagline {
  margin: 0 0 0.5rem;
  color: var(--muted);
}
.login-card label {
  font-size: 0.85rem;
  color: var(--muted);
}
.login-card input, .login-card button {
  font: inherit;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.login-card input {
  background: var(--bg0);
  color: var(--text);
}
.login-card button {
  background: var(--accent);
  color: var(--bg0);
  border: 0;
  font-weight: 700;
  cursor: pointer;
  margin-top: 0.35rem;
}
.login-card button:hover { filter: brightness(1.05); }
.error { color: var(--alarm); margin: 0; }

.ml-theme { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.ml-theme button {
  border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 0.78rem; font-weight: 600;
  padding: 0.35rem 0.65rem; cursor: pointer;
}
.ml-theme button[aria-pressed="true"] { background: var(--accent); color: var(--bg0); }
.login-body .ml-theme { margin-top: 1rem; justify-content: center; }

html[data-theme="light"] {
  color-scheme: light;
  --bg0: #f4f7f8;
  --bg1: #e7eef2;
  --panel: #ffffff;
  --text: #14202b;
  --muted: #5c6b7a;
  --line: #d5dee6;
  --accent: #0f7a4a;
  --accent-dim: #b7e4cd;
  --alarm: #c24141;
  --warn: #9a6b12;
  --map-ink: #0b6ea8;
}
html[data-theme="light"] body { background: var(--bg0); }
html[data-theme="light"] .portal-header { background: rgba(244, 247, 248, 0.92); }
html[data-theme="light"] .portal-header nav a.nav-active:not(.nav-alarm) { color: #fff; }

@media (max-width: 860px) {
  .layout-activity { grid-template-columns: 1fr; }
  .side {
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .map-pane { min-height: 55vh; height: 55vh; }
  .alarm-map-wrap { min-height: 70vh; }
}
