/* DJI Tools — Styles */

:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --border: #2d3f56;
  --text: #e8edf4;
  --text-muted: #8b9cb3;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --success: #22c55e;
  --warning: #f59e0b;
  --section: #a855f7;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-self: start;
}

.header-center {
  text-align: center;
  justify-self: center;
  line-height: 1.25;
}

.company-name {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text);
}

.company-tagline {
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
  justify-self: end;
}

@media (max-width: 900px) {
  .header {
    grid-template-columns: 1fr;
    justify-items: stretch;
  }

  .header-brand {
    justify-self: start;
  }

  .header-center {
    order: -1;
    justify-self: center;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border);
    width: 100%;
  }

  .header-actions {
    justify-self: stretch;
    justify-content: flex-end;
  }
}

.logo {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.75rem;
  letter-spacing: -0.5px;
}

.header h1 {
  font-size: 1.15rem;
  font-weight: 600;
}

.subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 0.85rem 1.75rem;
  font-size: 1rem;
}

.empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.empty-card {
  text-align: center;
  max-width: 480px;
  padding: 3rem 2rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

.empty-icon {
  margin-bottom: 1rem;
}

.empty-logo {
  width: 120px;
  height: auto;
  display: block;
  margin: 0 auto;
  object-fit: contain;
}

.empty-card h2 {
  font-size: 1.35rem;
  margin-bottom: 0.75rem;
}

.empty-card p {
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.analysis-view {
  flex: 1;
  padding: 1rem 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.hidden {
  display: none !important;
}

.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  width: 100%;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  min-width: 0;
}

.stat-card.stat-danger {
  border-color: rgba(239, 68, 68, 0.4);
  background: var(--danger-bg);
}

.stat-card.stat-clearance-safe {
  border-color: rgba(34, 197, 94, 0.4);
  background: rgba(34, 197, 94, 0.12);
}

.stat-label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.05rem;
  font-weight: 600;
}

#stat-elev-source {
  font-size: 0.82rem;
  line-height: 1.3;
}

.stat-danger .stat-value {
  color: var(--danger);
}

.stat-clearance-safe .stat-value {
  color: var(--success);
}

.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 1024px) {
  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .analysis-view {
    padding: 0.75rem 0.75rem 1.5rem;
  }

  .stats-bar {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .stat-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
  }

  .stat-label {
    margin-bottom: 0;
    flex-shrink: 0;
  }

  .stat-value {
    font-size: 0.95rem;
    text-align: right;
    word-break: break-word;
  }

  #stat-elev-source {
    font-size: 0.82rem;
    max-width: 55%;
  }

  #stat-filename {
    max-width: 60%;
  }

  .header {
    padding: 0.75rem;
  }

  .header-actions {
    flex-wrap: wrap;
  }

  .header-actions .btn {
    flex: 1;
    justify-content: center;
    min-width: 0;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .legend {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .chart-hint {
    font-size: 0.65rem;
    line-height: 1.4;
  }

  .threshold-control {
    flex-wrap: wrap;
    width: 100%;
  }

  .search-input {
    width: 100%;
  }

  .footer {
    flex-direction: column;
    text-align: center;
    padding: 0.75rem;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.panel-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.legend {
  display: flex;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot-safe { background: var(--success); }
.dot-danger { background: var(--danger); }
.dot-section { background: var(--section); }

.map-panel {
  display: flex;
  flex-direction: column;
  min-height: 460px;
}

#map {
  flex: 1;
  height: 420px;
  min-height: 420px;
  width: 100%;
  z-index: 0;
}

.chart-panel {
  min-height: 460px;
  display: flex;
  flex-direction: column;
}

.chart-panel canvas {
  flex: 1;
  padding: 1rem;
  min-height: 360px;
  max-height: 420px;
  cursor: grab;
}

.chart-panel canvas:active {
  cursor: grabbing;
}

.chart-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.threshold-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
}

.threshold-control input[type="number"] {
  width: 70px;
  padding: 0.3rem 0.5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
}

.search-input {
  padding: 0.4rem 0.75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  width: 220px;
}

.table-wrap {
  overflow-x: auto;
}

.table-wrap-scroll {
  max-height: 360px;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

th {
  background: var(--surface2);
  padding: 0.65rem 0.85rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid rgba(45, 63, 86, 0.5);
  white-space: nowrap;
}

tbody tr:hover {
  background: rgba(59, 130, 246, 0.06);
}

tbody tr.row-danger {
  background: var(--danger-bg);
}

tbody tr.row-danger:hover {
  background: rgba(239, 68, 68, 0.22);
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-safe {
  background: rgba(34, 197, 94, 0.2);
  color: var(--success);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.25);
  color: var(--danger);
}

.badge-section {
  background: rgba(168, 85, 247, 0.2);
  color: var(--section);
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 25, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 2.5rem;
  text-align: center;
  min-width: 320px;
  box-shadow: var(--shadow);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.progress-bar {
  height: 4px;
  background: var(--surface2);
  border-radius: 2px;
  margin-top: 1rem;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.3s;
}

.footer {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.leaflet-container {
  background: #1a2332;
  font-family: inherit;
  height: 100%;
  width: 100%;
}

.leaflet-popup-content-wrapper {
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
}

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