/* ============================================================
   style.css — GPX Terrain 3D
   Dark-mode premium design | Mountain palette
   ============================================================ */

/* ── Reset & base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-deep:      #080f1a;
  --bg-card:      #0d1b2a;
  --bg-card2:     #111e2e;
  --bg-input:     #0a1525;
  --bg-hover:     #162035;

  --accent:       #e07b39;
  --accent-light: #f4a261;
  --accent-glow:  rgba(224,123,57,.25);

  --green:        #2dc653;
  --red:          #e63946;
  --blue:         #4da6ff;

  --text-primary:   #e8edf5;
  --text-secondary: #8a9bb5;
  --text-muted:     #4a5b72;

  --border:       #1e3048;
  --border-light: #253d5c;

  --radius-sm:  6px;
  --radius-md:  12px;
  --radius-lg:  18px;

  --shadow-card: 0 4px 24px rgba(0,0,0,.45);
  --shadow-glow: 0 0 24px var(--accent-glow);

  --transition: .18s ease;
  --font-body: 'Inter', sans-serif;
  --font-head: 'Space Grotesk', sans-serif;
}

html { font-size: 14px; }

body {
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Animated gradient background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(224,123,57,.07) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 90%, rgba(77,166,255,.05) 0%, transparent 55%);
  pointer-events: none;
  z-index: 0;
}

/* ── Header ──────────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(8,15,26,.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.logo-icon { font-size: 1.8rem; line-height: 1; }
.logo-title {
  display: block;
  font-family: var(--font-head);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.01em;
}
.logo-sub {
  display: block;
  font-size: .7rem;
  color: var(--text-muted);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.header-nav { display: flex; gap: 1rem; }
.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: .82rem;
  transition: color var(--transition);
}
.nav-link:hover { color: var(--accent-light); }

/* ── Layout ──────────────────────────────────────────────────── */
.main-layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1.25rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem;
  flex: 1;
  align-items: start;
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent);
}

.section-title {
  font-family: var(--font-head);
  font-size: .92rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1rem;
}
.section-icon { font-size: 1rem; }

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: calc(60px + 1.25rem);
  max-height: calc(100vh - 60px - 2.5rem);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-light) transparent;
}

/* ── Upload Zone ─────────────────────────────────────────────── */
.upload-card { padding: 1rem; }

.drop-zone {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-glow);
  box-shadow: var(--shadow-glow);
}
.drop-icon { font-size: 2rem; margin-bottom: .5rem; }
.drop-primary {
  font-weight: 500;
  font-size: .88rem;
  color: var(--text-primary);
}
.drop-secondary {
  font-size: .76rem;
  color: var(--text-muted);
  margin-top: .25rem;
}
.file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.file-info {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-top: .75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .5rem .75rem;
}
.file-name {
  flex: 1;
  font-size: .8rem;
  color: var(--accent-light);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .9rem;
  padding: 0 .25rem;
  transition: color var(--transition);
}
.btn-clear:hover { color: var(--red); }

/* ── Parameters ──────────────────────────────────────────────── */
.params-card { padding: 1rem; }

.params-group {
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.params-group:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}
.params-group-title {
  font-size: .72rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: .75rem;
}

.param-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .65rem;
}
.param-row:last-child { margin-bottom: 0; }

.param-label {
  font-size: .8rem;
  color: var(--text-secondary);
  flex: 1;
  white-space: nowrap;
}
.param-unit {
  font-size: .7rem;
  color: var(--text-muted);
}

.param-controls {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex: 1.4;
}

.param-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 3px;
  background: var(--border-light);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.param-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-glow);
  transition: transform var(--transition);
}
.param-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }

.param-number {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: .8rem;
  padding: .3rem .5rem;
  width: 68px;
  text-align: right;
  transition: border-color var(--transition);
}
.param-number.full { width: 90px; }
.param-number:focus {
  outline: none;
  border-color: var(--accent);
}

/* Toggle */
.param-toggle { justify-content: space-between; }
.toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  cursor: pointer;
  transition: all var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  left: 2px; top: 50%;
  translate: 0 -50%;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: all var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--accent-glow); border-color: var(--accent); }
.toggle input:checked + .toggle-slider::before { left: 18px; background: var(--accent); }

.btn-reset {
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: .8rem;
  padding: .15rem .4rem;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-reset:hover { color: var(--accent-light); border-color: var(--accent); }

/* ── Process Button ──────────────────────────────────────────── */
.btn-process {
  width: 100%;
  padding: .9rem 1.5rem;
  background: linear-gradient(135deg, var(--accent), #c05e1e);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-family: var(--font-head);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  transition: all var(--transition);
  box-shadow: 0 4px 16px rgba(224,123,57,.3);
  position: relative;
  overflow: hidden;
}
.btn-process::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent, rgba(255,255,255,.08), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}
.btn-process:hover:not(:disabled)::after { opacity: 1; }
.btn-process:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(224,123,57,.4);
}
.btn-process:active:not(:disabled) { transform: translateY(0); }
.btn-process:disabled {
  background: var(--bg-card2);
  color: var(--text-muted);
  cursor: not-allowed;
  box-shadow: none;
}
.btn-process-icon { font-size: 1rem; }

/* ── Content Area ─────────────────────────────────────────────── */
.content-area {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ── Map ─────────────────────────────────────────────────────── */
.map-card { padding: 1rem; }
.map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
}
.map-info {
  font-size: .78rem;
  color: var(--text-muted);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .3rem .7rem;
}
.map-container {
  height: 420px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}

/* Leaflet dark overrides */
.leaflet-container { background: #080f1a; }
.leaflet-control-attribution {
  background: rgba(8,15,26,.8) !important;
  color: var(--text-muted) !important;
}
.leaflet-control-attribution a { color: var(--text-muted) !important; }

/* ── Progress ─────────────────────────────────────────────────── */
.progress-card { padding: 1.25rem; }

.progress-phases {
  display: flex;
  gap: .35rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.phase-dot {
  display: flex;
  align-items: center;
  gap: .3rem;
  font-size: .72rem;
  padding: .2rem .55rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--bg-input);
  transition: all .3s ease;
}
.phase-dot.active {
  border-color: var(--accent);
  color: var(--accent-light);
  background: var(--accent-glow);
  animation: pulse-glow 1.5s ease-in-out infinite;
}
.phase-dot.done {
  border-color: var(--green);
  color: var(--green);
  background: rgba(45,198,83,.08);
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 rgba(224,123,57,0); }
  50% { box-shadow: 0 0 10px var(--accent-glow); }
}

.progress-bar-wrap {
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: .75rem;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 3px;
  transition: width .4s ease;
  box-shadow: 0 0 8px var(--accent-glow);
}
.progress-message {
  font-size: .82rem;
  color: var(--text-secondary);
  min-height: 1.2em;
}

/* ── Result ───────────────────────────────────────────────────── */
.result-card { padding: 1.25rem; }
.result-body {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}
.preview-wrap {
  flex: 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-input);
}
.result-preview {
  width: 100%;
  display: block;
  border-radius: var(--radius-md);
}
.result-actions {
  flex: 0 0 200px;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.result-info {
  font-size: .8rem;
  color: var(--text-secondary);
  line-height: 1.6;
}
.btn-download {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  background: linear-gradient(135deg, #2dc653, #1a8a36);
  color: white;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: .92rem;
  padding: .8rem 1rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: all var(--transition);
  box-shadow: 0 4px 16px rgba(45,198,83,.25);
}
.btn-download:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(45,198,83,.35);
}
.result-hint {
  font-size: .75rem;
  color: var(--text-muted);
  line-height: 1.7;
}
.result-hint code {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 4px;
  font-size: .72rem;
  color: var(--accent-light);
}

/* ── Error ───────────────────────────────────────────────────── */
.error-card { border-color: rgba(230,57,70,.3); }
.error-message {
  background: rgba(230,57,70,.06);
  border: 1px solid rgba(230,57,70,.2);
  border-radius: var(--radius-sm);
  padding: 1rem;
  font-size: .8rem;
  color: #ff8a93;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 1rem;
  max-height: 200px;
  overflow-y: auto;
}
.btn-retry {
  background: none;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: .85rem;
  padding: .5rem 1rem;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-retry:hover { border-color: var(--accent); color: var(--accent-light); }

/* ── Leaflet popup dark theme ────────────────────────────────── */
.leaflet-popup-content-wrapper {
  background: var(--bg-card2) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border) !important;
  box-shadow: var(--shadow-card) !important;
}
.leaflet-popup-tip { background: var(--bg-card2) !important; }

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 960px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    max-height: none;
  }
  .result-body { flex-direction: column; }
  .result-actions { flex: auto; }
}
