/* System: EV Overview
   Filename: styles.css
   Version: V15
   Brief description: Base UI + planner helpers with scoped gallery styles; auth page tweaks (header-row, option buttons, wide email confirm). V14 ensures .gallery-modal always fullscreen overlay.
   Change log:
- v14 — 2025-09-06 — Ensure .gallery-modal is always fullscreen overlay when open, no matter parent context.
- v13 — 2025-09-06 — Add flex gap for .actions button groups (trips, waypoints, etc).
- v12 — 2025-09-06 — Scoped auth fixes ONLY: keep title beside logo without widening card; keep options buttons on one row; widen reset-email field; stack create inputs per line. No global changes.
- v11 — 2025-09-05 — Ensure .alert and .alert.error are visibly styled on auth page; add .auth-logo.
- v10 — 2025-09-05 — Add .auth-logo styling for logo on auth page.
- v9 — 2025-09-04 — Add open-state rules for slideshow modal (.gallery-modal.is-open) and ensure full-screen overlay visibility.
- v8 — 2025-09-01 — Restored full stylesheet and appended scoped gallery rules; inputs slightly darker; top-nav links white.
- v7 — 2025-08-31 — (superseded) Partial CSS inadvertently replaced full file.
   Original "Updated:" notes retained below.
*/

/* Project: EV Overview
   File: styles.css
   Description: Base UI + planner layout helpers.
   Updated: 2025-08-10 — top-align Distance/OSM, prevent OSM box overflow,
            tidy OR chip spacing, hide wait message by default, and ensure
            leader-green overrides charging tints.
   Updated: 2025-08-18 - added stuff for displaying image/thumbnail correctly
   Updated: 2025-08-20 - auth page layout & alerts (CSP-safe)
*/

:root {
  --bg: #0b1020;
  --card: #121a33;
  --text: #f5f7ff;
  --muted: #a8b0c9;
  --primary: #6ea8fe;
  --primary-2: #4b86f7;
  --accent: #aaf0d1;
  --border: #223053;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Inter, Arial;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
  position: sticky; top: 0; z-index: 100;
  display: grid; grid-template-columns: 180px 1fr auto; gap: 1rem;
  align-items: center; padding: .75rem 1rem;
  background: rgba(9,14,29,.8); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; letter-spacing: .5px; }
.top-nav a { margin: 0 .5rem; padding: .4rem .6rem; border-radius: 10px; }
.top-nav a.active, .top-nav a:hover { background: var(--primary-2); color: white; text-decoration: none; }
.userbox { display:flex; gap:.5rem; align-items:center; }
.btn { border: 1px solid var(--primary); padding:.4rem .7rem; border-radius:10px; color:var(--text); background:transparent; }
.btn:hover { background: var(--primary-2); border-color: var(--primary-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color:#041023; font-weight:600; }
.btn.small { padding:.25rem .5rem; font-size:.9rem; }

.page { padding: 2rem 1rem; max-width: 1100px; margin: 0 auto; }
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 1.25rem; box-shadow: 0 10px 30px rgba(0,0,0,.2);
  overflow: hidden;
}
.grid { display:grid; grid-template-columns: repeat(auto-fit,minmax(280px,1fr)); gap:1rem; }
.tile { display:block; padding:1rem; background:#0f1630; border:1px solid var(--border); border-radius:14px; }
.table-responsive { overflow-x:auto; margin-top:.75rem; }
.table { width:100%; border-collapse: collapse; }
.table th, .table td { border-bottom: 1px solid var(--border); padding:.6rem .5rem; text-align:left; }
.table thead th { color: var(--muted); font-weight:600; }
.form-grid { display:grid; grid-template-columns: repeat(auto-fit,minmax(220px,1fr)); gap: .75rem; margin:.75rem 0; }
.form-grid label { display:flex; flex-direction:column; gap:.25rem; color: var(--muted); }
input, select, button, textarea { font: inherit; }
input, select, textarea {
  background:#0f1630; color:var(--text); border:1px solid var(--border); border-radius:10px; padding:.55rem .6rem;
  min-width: 0;
}
textarea { resize: vertical; }
button { cursor:pointer; }
.inline { display:inline; }
.muted { color: var(--muted); }
.kv { display:grid; grid-template-columns: repeat(auto-fit,minmax(220px,1fr)); gap:.5rem .75rem; margin:.75rem 0; }
.results { margin-top:1rem; }
.site-footer {
  margin: 2rem auto; max-width:1100px; color: var(--muted); padding:1rem;
  border-top:1px solid var(--border);
}

/* --- Planner layout additions --- */
.group-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .9rem;
  background:#0f1630;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
.group-title {
  margin: 0 0 .6rem 0;
  font-weight: 600;
  color: #d7defa;
  font-size: .98rem;
}
.group-grid { display:grid; grid-template-columns: repeat(auto-fit,minmax(220px,1fr)); gap:.75rem; }

/* NEW: wrapper row so Speed can be narrower and From/To wider without touching the rest */
.planner-row {
  display:grid;
  grid-template-columns: 0.85fr 1.15fr;
  gap:.75rem;
  align-items: start;
}
@media (max-width: 980px){
  .planner-row { grid-template-columns: 1fr; }
}

.or-row {
  display:grid;
  grid-template-columns: 0.75fr auto 1.25fr;
  gap:.75rem;
  align-items: start;
}
.or-chip {
  align-self: start;
  justify-self: center;
  border:1px dashed var(--border);
  color: var(--muted);
  padding:.25rem .6rem;
  border-radius: 999px;
  font-weight:600;
  letter-spacing:.4px;
  background:#0b132a;
  white-space: nowrap;
  margin-top:.25rem;
}

/* Helper text */
.help { font-size:.85rem; color: var(--muted); margin-top:.25rem; }

/* Buttons row */
.btn-row { display:flex; gap:.5rem; align-items:center; flex-wrap:wrap; }

/* Wait message hidden by default */
#waitMsg { display:none; }

/* --- Simulation helpers (leader stays green even if charging) --- */
.car-img { width:22px; height:14px; display:block; }
.car.is-leader .car-img { filter: hue-rotate(90deg) saturate(2) brightness(1.25) !important; }
.car.charging.is-leader .car-img { filter: hue-rotate(90deg) saturate(2) brightness(1.25) !important; }

/* --- Garage thumbnails --- */
.table td img.car-thumb {
  width: 120px;
  height: 80px;
  object-fit: cover;
  display: block;
  border-radius: 8px;
}
img.car-large {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 10px;
}

/* Dropdown styles for EV Overview */
select {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 8px;
  margin: 4px 0;
}
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 5px var(--primary);
}

/* =========================
   Auth pages (CSP friendly)
   ========================= */
.auth-page { min-height: 100dvh; display: grid; place-items: center; }
.auth-wrap { width: 100%; padding: 2rem 1rem; }
.auth-card { max-width: 420px; margin: 0 auto; }
.auth-title { margin: 0 0 .25rem 0; }
.auth-grid { display: grid; gap: .75rem; margin-top: .75rem; }
.auth-grid label { display:flex; flex-direction:column; gap:.25rem; color: var(--muted); }
.auth-actions { display:flex; gap:.75rem; align-items:center; justify-content:space-between; margin-top:.25rem; }
.auth-switch { white-space: nowrap; }
.alert {
  border: 1px solid #3a4b7a;
  background: #0f1630;
  color: #e0e6ff;
  padding: .6rem .75rem;
  border-radius: 10px;
  margin: .75rem 0;
}
.alert.error {
  border-color: #ff6b6b;
  background: #2a0f17;
  color: #ffd7d7;
}

/* --- Admin image & hotspots --- */
.image-box {
  position: relative;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #0f1630;
  overflow: hidden;
}

.car-admin-img {
  width: 100%;
  height: auto;
  display: block;
}

.hotspot {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid red;
  background: rgba(255,0,0,0.4);
  box-shadow: 0 0 6px rgba(0,0,0,0.7);
  cursor: grab;
  transform: translate(-50%, -50%);
}

.hotspot:hover {
  background: rgba(255,0,0,0.7);
}

.hotspot-menu {
  position: absolute;
  top: 22px;
  left: 22px;
  background: #121a33;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .4rem;
  z-index: 10;
}

.hotspot-menu .menu-btn {
  display: block;
  width: 100%;
  padding: .3rem .5rem;
  background: transparent;
  border: none;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.hotspot-menu .menu-btn:hover {
  background: var(--primary-2);
}

/* ===== v8 additions (scoped/overrides) ===== */

/* Make top-nav items white by default */
.top-nav a { color: var(--text) !important; }

/* Slightly darker inputs than earlier theme */
input, select, textarea { background: #0b132a !important; }

/* Gallery page (scoped) */
.gallery-page .bar { display:flex; align-items:center; gap:.5rem; flex-wrap:wrap; }
.gallery-page .bar h1 { margin:0; margin-right:auto; }
.gallery-page .bar label { display:flex; align-items:center; gap:.4rem; }
.gallery-page #exportForm { display:inline-flex; }
.gallery-page #slideInterval { width:90px; }

.gallery-page .gallery-grid { display:grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.gallery-page .gallery-item { background:#0f1630; border:1px solid var(--border); border-radius:10px; overflow:hidden; padding:8px; }
.gallery-page .gallery-thumb { width:100%; height:280px; object-fit:contain; background:#0b132a; cursor:pointer; display:block; }
.gallery-page .item-controls { display:flex; gap:6px; margin-top:8px; }
.gallery-page .caption { font-size:12px; color: var(--muted); margin-top:6px; text-overflow:ellipsis; white-space:nowrap; overflow:hidden; }

.gallery-page .gallery-modal { display:none; position:fixed; z-index:10000; inset:0; background:rgba(0,0,0,0.95); align-items:center; justify-content:center; flex-direction:column; }
.gallery-page .modal-topbar { width:100%; display:flex; align-items:center; padding:12px 18px; box-sizing:border-box; background: rgba(0,0,0,0.3); position:fixed; top:0; left:0; }
.gallery-page .modal-body { display:flex; align-items:center; justify-content:center; width:100%; height: calc(100% - 80px); padding:40px 20px; box-sizing:border-box; }
.gallery-page .modal-body img { max-width:95%; max-height:85vh; display:block; margin:auto; }
.gallery-page .nav-left, .gallery-page .nav-right { position:fixed; top:50%; transform:translateY(-50%); background:transparent; color:#fff; border:none; font-size:36px; padding:8px; cursor:pointer; z-index:10001; }
.gallery-page .nav-left { left:12px; } .gallery-page .nav-right { right:12px; }
.gallery-page .waypoint-label { position:absolute; bottom:28px; left:28px; background: rgba(0,0,0,0.55); color:#fff; padding:8px 12px; border-radius:6px; font-size:14px; }

@media (max-width: 768px) {
  .gallery-page .gallery-grid { grid-template-columns: 1fr; }
  .gallery-page .gallery-thumb { height: 220px; }
}
/* === v9 modal visibility rules === */
.gallery-page .gallery-modal.is-open,
.gallery-page .gallery-modal[aria-hidden="false"] {
  display: flex !important;
  position: fixed;
  inset: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}


/* =========================
   V12 additions (scoped)
   ========================= */
/* Keep the title next to the logo, but let the description wrap below without widening the card */
.auth-card .auth-header-row {
  display: grid;
  grid-template-columns: 192px 1fr;
  column-gap: 12px;
  align-items: center;
}
/* Turn the inner wrapper into layout-only so its children (h1, p) participate in the grid */
.auth-card .auth-header-row > div { display: contents; }
/* Place the title in column 2 (beside the logo) */
.auth-card .auth-header-row .auth-title { grid-column: 2; margin: 0 0 .2rem 0; }
/* Place the following description across full width (below the row) */
.auth-card .auth-header-row .muted { grid-column: 1 / -1; margin-top: .25rem; }
/* Ensure the logo doesn't force overflow and keeps to intended 4× size */
.auth-card .auth-logo { width: 192px; height: 192px; object-fit: contain; display: block; }

/* Keep the three option buttons on a single row within the option panel */
.auth-card .option-panel .btn-row { display: flex; flex-wrap: nowrap; gap: .5rem; overflow-x: auto; }
.auth-card .option-panel .btn-row form { flex: 0 0 auto; margin: 0; }

/* Widen confirm-email field in Reset view without affecting other inputs */
.auth-card .wide-field input { width: 100%; max-width: 100%; }

/* Stack create-account fields one per line in that section */
.auth-card .stack { display: grid; grid-template-columns: 1fr; gap: .75rem; }

/* =========================
   V13 additions (GLOBAL)
   ========================= */
td.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
td.actions form { margin: 0; }

/* =========================
   V14: Gallery modal always fullscreen overlay!
   ========================= */
.gallery-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  background: rgba(0,0,0,0.95);
}
.gallery-modal.is-open,
.gallery-modal[aria-hidden="false"] {
  display: flex !important;
}
/* === V15 Additions: Planner grid, help icon, hide OSM === */
.grid-2lines { margin-bottom: 1.2em; }
.grid-2lines .row1,
.grid-2lines .row2 {
  display: flex;
  gap: 2.2em;
  margin-bottom: .85em;
  flex-wrap: wrap;
}
.grid-2lines .row1 label,
.grid-2lines .row2 label {
  margin-bottom: 0;
  flex: 1 1 220px;
}
.grid-speed-distance {
  display: flex;
  gap: 2.2em;
  margin-bottom: 1.2em;
  flex-wrap: wrap;
}
.grid-speed-distance > div {
  flex: 1 1 220px;
}
.grid-sortby { margin-bottom: 1.1em; }
.or-row[style*="display:none"],
.or-row.hide-osm { display:none !important; }

.help-icon {
  display: inline-block;
  width: 1.2em;
  height: 1.2em;
  vertical-align: middle;
  margin-left: 6px;
  margin-right: 0;
  color: #91b5ea;
  background: #1b2545;
  border-radius: 50%;
  text-align: center;
  font-size: .95em;
  font-family: inherit;
  border: 1px solid #3d4c77;
  user-select: none;
  line-height: 1.18em;
  cursor: help;
  position: relative;
  top: 1px;
}
label > input + .help-icon,
label > select + .help-icon {
  margin-left: 8px;
}
label .help-icon:first-child { margin-left: 0; }
@media (max-width: 800px) {
  .grid-2lines .row1,
  .grid-2lines .row2,
  .grid-speed-distance {
    flex-direction: column;
    gap: 1em;
  }
}
