/* =========================
   Base / Global
========================= */
:root{
  --bg: #e5e5e5;
  --card: #ffffff;
  --text: #111;
  --muted: #555;

  --border: rgba(0,0,0,0.12);
  --shadow: 0 2px 12px rgba(0,0,0,0.06);

  --btn-bg: linear-gradient(180deg, #fff, #f3f3f3);
  --btn-bg-hover: linear-gradient(180deg, #fff, #e9e9e9);

  --primary-bg: linear-gradient(180deg, #111, #000);
  --primary-bg-hover: linear-gradient(180deg, #000, #000);

  --danger: #b00020;
  --danger-border: #e08a8a;

  --save-green: #1b7f3a;
}

* { box-sizing: border-box; }

body {
  font-family: "Inter", sans-serif;
  max-width: 800px;
  margin: 40px auto;
  padding: 0 16px;
  background-color: var(--bg);
  color: var(--text);
}

h1 { text-align: center; }

/* Simple list styles (used on other pages) */
.item {
  padding: 12px 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  margin-bottom: 10px;
}
.trail-name { font-weight: bold; font-size: 1.2rem; }
.usage { color: #444; margin-top: 4px; font-size: 0.95rem; }
.stat-line { font-size: 0.9rem; margin-top: 4px; }

/* =========================
   Navbar (responsive)
========================= */
.navbar {
  background: #ffffff;
  border-bottom: 1px solid #ddd;
  padding: 12px 0;
  margin-bottom: 30px;
  position: relative;
}

.nav-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.logo {
  font-weight: 600;
  text-decoration: none;
  color: #000;
  font-size: 1.1rem;

  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.logo-mark{ height: 26px; width: 26px; display: block; }
.logo-text{ line-height: 1; }

.nav-menu {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.nav-links a {
  text-decoration: none;
  color: #333;
  font-weight: 500;
  padding: 6px 8px;
  border-radius: 8px;
}
.nav-links a:hover { background: rgba(0,0,0,0.06); }

.nav-auth {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lang-switch{
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: white;
  padding: 0 8px;
  margin-left: 10px;
}

/* Navbar buttons */
.nav-btn {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--btn-bg);
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  line-height: 1;
  box-shadow: 0 1px 0 rgba(0,0,0,0.04);
}
.nav-btn:hover { background: var(--btn-bg-hover); }

.nav-btn-primary {
  background: var(--primary-bg);
  color: #fff;
  border-color: rgba(0,0,0,0.65);
}
.nav-btn-primary:hover { background: var(--primary-bg-hover); }

/* Hamburger controls */
.nav-toggle-checkbox { display: none; }

.nav-toggle {
  display: none;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--btn-bg);
  cursor: pointer;

  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-direction: column;
  user-select: none;
}
.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: #111;
  border-radius: 2px;
}

@media (max-width: 720px) {
  .nav-toggle { display: inline-flex; }

  .nav-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border-bottom: 1px solid #ddd;
    padding: 12px 16px;
    z-index: 1000;

    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .nav-toggle-checkbox:checked ~ .nav-menu { display: flex; }

  .nav-links {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .nav-links a { padding: 10px 10px; }

  .nav-auth {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .nav-btn {
    width: 100%;
    text-align: center;
    padding: 10px 12px;
  }

  #user-email {
    margin: 0 !important;
    padding: 6px 2px;
  }
}

.user-email{
  margin: 0 10px;
  font-size: 11px;
  font-weight: 500;
  opacity: 0.65;
  white-space: nowrap;
}

/* =========================
   Reusable Buttons
========================= */
.btn{
  display: inline-block;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--btn-bg);
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  color: #111;
  text-decoration: none;
}

.btn:hover { background: var(--btn-bg-hover); }

.btn.primary{
  background: var(--primary-bg);
  color: #fff;
  border-color: rgba(0,0,0,0.65);
}
.btn.primary:hover { background: var(--primary-bg-hover); }

.btn.small{
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1;
}

.btn.mini{
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 11px;
  line-height: 1;
}

.btn.ghost { background: #fff; }
.btn.ghost:hover { background: #f0f0f0; }

.btn.danger{
  border-color: var(--danger-border);
  color: var(--danger);
  background: #fff;
}
.btn.danger:hover{ background: rgba(176, 0, 32, 0.08); }

/* Save button "needs saving" state (works without hover) */
#save-btn.save-dirty{
  background: var(--save-green) !important;
  border-color: var(--save-green) !important;
  color: #fff !important;
}
#save-btn.save-dirty:hover,
#save-btn.save-dirty:focus{
  background: var(--save-green) !important;
  border-color: var(--save-green) !important;
  color: #fff !important;
}
#save-btn.save-clean{ opacity: 0.75; }

/* =========================
   Forms
========================= */
.field { margin: 10px 0; }
.field label { display:block; font-weight:600; margin-bottom:6px; }

.field input,
.field textarea,
.field select{
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
}

.field input[type="date"]{
  padding: 7px 10px;
  height: 36px;
  font-size: 13px;
  border-radius: 10px;
}

/* Analysis page compact dates */
.analysis-page .field input[type="date"]{
  height: 34px;
  padding: 6px 10px;
  font-size: 13px;
}
.analysis-page .field { margin: 8px 0; }

/* =========================
   Home page (kept)
========================= */
.home { max-width: 900px; margin: 0 auto; padding: 0 16px 40px; }

.hero { padding: 20px 0 10px; }
.hero h1 { margin: 0 0 10px; font-size: 2rem; }
.hero-sub { margin: 0 0 16px; color: #444; max-width: 60ch; }

.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.cards {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: #fff;
}
.card h2 { margin-top: 0; font-size: 1.1rem; }
.card p { color: #444; }
.card ul { margin: 10px 0 0; padding-left: 18px; color: #444; }

.faq { margin-top: 22px; }
.faq details {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  margin-bottom: 10px;
}
.faq summary { cursor: pointer; font-weight: 600; }

@media (max-width: 900px) {
  .cards { grid-template-columns: 1fr; }
}

/* Modern animated background */
.home-bg { position: relative; overflow: hidden; padding-top: 18px; }

.home-bg::before{
  content:"";
  position:absolute;
  inset:-40%;
  background:
    radial-gradient(circle at 20% 20%, rgba(0,0,0,0.08), transparent 35%),
    radial-gradient(circle at 80% 30%, rgba(0,120,255,0.10), transparent 40%),
    radial-gradient(circle at 40% 80%, rgba(255,0,120,0.08), transparent 40%),
    linear-gradient(120deg, rgba(0,0,0,0.04), rgba(0,0,0,0.00));
  filter: blur(30px);
  animation: bg-drift 18s ease-in-out infinite alternate;
  z-index:0;
}

@keyframes bg-drift {
  from { transform: translate3d(-2%, -2%, 0) scale(1.02); }
  to   { transform: translate3d(2%, 2%, 0) scale(1.06); }
}

.bg-blobs{
  position:absolute;
  inset:0;
  z-index:0;
  pointer-events:none;
}

.bg-blobs::before,
.bg-blobs::after{
  content:"";
  position:absolute;
  width:360px;
  height:360px;
  border-radius:999px;
  background: radial-gradient(circle at 30% 30%, rgba(0,120,255,0.18), transparent 60%);
  filter: blur(10px);
  opacity: 0.8;
  animation: blob-float 14s ease-in-out infinite;
}

.bg-blobs::before{ top:-120px; left:-120px; }
.bg-blobs::after{
  bottom:-140px; right:-140px;
  background: radial-gradient(circle at 30% 30%, rgba(255,0,120,0.14), transparent 60%);
  animation-duration: 18s;
}

@keyframes blob-float {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(30px, 20px) scale(1.06); }
  100% { transform: translate(0, 0) scale(1); }
}

.home-bg > *{ position: relative; z-index: 1; }

.card,
.faq details{
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

@media (prefers-reduced-motion: reduce) {
  .home-bg::before,
  .bg-blobs::before,
  .bg-blobs::after { animation: none; }
}

/* =========================
   Private page
========================= */
body.private-page{
  max-width: none;
  margin: 0;
  padding: 0;
  background-color: var(--bg);
}

.private-shell{
  max-width: 1800px;
  margin: 0 auto;
  padding: 16px;
}

.private-layout{
  display: grid;
  grid-template-columns: 340px 1fr minmax(360px, 480px);
  gap: 16px;
  align-items: start;
}

.panel{
  background: var(--card);
  border-radius: 12px;
  padding: 14px;
  box-shadow: var(--shadow);
}

#map{
  height: 70vh;
  border-radius: 12px;
  overflow: hidden;
}

.row{ display:flex; gap:10px; }
.row button{ flex: 1; }

.hint{
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
}

.list{
  margin-top: 12px;
  display:flex;
  flex-direction:column;
  gap:8px;
}

.point-item{
  border: 1px solid #eee;
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  background: #fff;
}
.point-item:hover{ background: #fafafa; }

.point-item .title{ font-weight: 700; }
.point-item .meta{ font-size: 12px; color:#666; margin-top:4px; }

.point-item.private{
  border-color: rgba(52, 152, 219, 0.45);
  background: rgba(52, 152, 219, 0.10);
}
.point-item.team{
  border-color: rgba(46, 204, 113, 0.45);
  background: rgba(46, 204, 113, 0.10);
}

.point-actions{
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.legend{
  display:flex;
  gap:12px;
  align-items:center;
  flex-wrap: wrap;
  margin: 6px 0 4px;
}

.legend-item{
  display:inline-flex;
  align-items:center;
  gap:8px;
  font-size: 13px;
  color:#444;
  padding: 6px 10px;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 999px;
  background: rgba(255,255,255,0.8);
}

.legend-dot{
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display:inline-block;
  border: 2px solid transparent;
}
.legend-dot.private{
  background: rgba(52, 152, 219, 0.20);
  border-color: rgba(52, 152, 219, 0.55);
}
.legend-dot.team{
  background: rgba(46, 204, 113, 0.20);
  border-color: rgba(46, 204, 113, 0.55);
}

/* Desktop: make the 3 panels nearly full-height */
@media (min-width: 901px) {
  .private-shell{
    min-height: calc(100vh - 80px); /* adjust 80px if your navbar is taller */
  }

  .private-layout{
    min-height: calc(100vh - 80px);
  }

  #map{
    height: calc(100vh - 120px);   /* adjust so it fits nicely */
    min-height: 650px;             /* optional safety */
  }

  .details-panel{
    max-height: calc(100vh - 120px);
  }
}



/* Details panel */
.details-panel{
  display:none;                 /* hidden until .open */
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  overflow-x: hidden;
}

/* IMPORTANT: allow children to shrink (prevents horizontal scroll) */
.details-panel,
.details-panel *{ min-width: 0; }

.details-panel.open{ display:block; }

.details-header{
  display:flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}

.details-kicker{ font-size: 12px; color:#666; }

.details-title{
  font-weight: 700;
  font-size: 18px;
  margin-top: 2px;
}

.details-notes{
  margin-top: 10px;
  white-space: pre-wrap;
  color:#333;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.details-actions{
  display:flex;
  gap:8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.details-section-title{
  font-weight: 700;
  margin-bottom: 8px;
}

.details-upload{
  display:flex;
  gap:8px;
  align-items:center;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
#photo-input{ max-width: 100%; }

/* Photo grid */
.photo-grid{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap:10px;
}
.photo-item{ position: relative; }
.photo-item img{
  width: 100%;
  height: auto;
  border-radius: 10px;
  display:block;
}
.photo-del{
  position:absolute;
  right: 8px;
  bottom: 8px;
  opacity: 0.95;
}

/* Sticky footer in details panel */
.details-footer{
  position: sticky;
  bottom: 0;
  background: #fff;
  padding-top: 10px;
  padding-bottom: 6px;
  margin-top: 12px;
  border-top: 1px solid #eee;
}

/* Private page compact fields */
.private-page #title{
  height: 34px;
  padding: 6px 10px;
  font-size: 13px;
}
.private-page #notes{
  padding: 6px 10px;
  font-size: 13px;
  min-height: 90px;
}

/* Mobile layout: keep some map visible behind the bottom sheet */
@media (max-width: 900px) {
  .private-layout { grid-template-columns: 1fr; }

  /* Use iOS-friendly viewport units */
  #map{
    height: 100svh;      /* full small-viewport height (better than vh on iOS) */
    min-height: 420px;   /* safety so it doesn't get too tiny */
  }

  .details-panel{
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    top: auto;

    max-height: 45svh;   /* IMPORTANT: keep it from covering the entire map */
    z-index: 9999;
    box-shadow: 0 10px 40px rgba(0,0,0,0.20);
  }
}
