/* ============================================================
 * Tracks to Pictures — CSS
 * ============================================================ */

:root {
  /* Colors */
  --bg-primary: #0a0a0a;
  --bg-secondary: #111111;
  --bg-tertiary: #1a1a1a;
  --bg-elevated: #222222;
  --border-subtle: #2a2a2a;
  --border-medium: #3a3a3a;
  
  --text-primary: #e0e0e0;
  --text-secondary: #888888;
  --text-muted: #555555;
  
  --accent-blue: #3b82f6;
  --accent-green: #22c55e;
  --accent-orange: #f59e0b;
  --accent-red: #ef4444;
  --accent-purple: #8b5cf6;
  
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'Courier New', monospace;
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  
  /* Border radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
 * App Container
 * ============================================================ */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ============================================================
 * Header
 * ============================================================ */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.header-left h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

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

.header-right {
  display: flex;
  gap: var(--space-sm);
}

.stat-badge {
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

/* ============================================================
 * Main Layout
 * ============================================================ */
.app-main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ============================================================
 * Panels
 * ============================================================ */
.panel-left {
  width: 380px;
  min-width: 320px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}

.panel-section {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
}

.panel-section h2 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: var(--space-md);
  color: var(--text-primary);
}

/* ============================================================
 * Upload Zones
 * ============================================================ */
.upload-zone {
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-md);
  padding: var(--space-xl);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: var(--space-md);
}

.upload-zone:hover {
  border-color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.05);
}

.upload-zone.drag-over {
  border-color: var(--accent-green);
  background: rgba(34, 197, 94, 0.05);
}

.upload-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.upload-btn:hover {
  background: var(--bg-elevated);
}

.upload-icon {
  font-size: 1.2rem;
}

.upload-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: var(--space-sm);
}

/* ============================================================
 * Buttons
 * ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s, background 0.2s;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--accent-blue);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: #2563eb;
}

.btn-success {
  background: var(--accent-green);
  color: white;
}

.btn-success:hover:not(:disabled) {
  background: #16a34a;
}

.btn-danger {
  background: var(--accent-red);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

.btn-sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.7rem;
}

/* ============================================================
 * Controls
 * ============================================================ */
.trace-controls,
.photo-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

/* ============================================================
 * Time Display
 * ============================================================ */
.time-display {
  padding: var(--space-sm);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--accent-orange);
  margin-bottom: var(--space-md);
}

/* ============================================================
 * Stats Display
 * ============================================================ */
.stats-display {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-bottom: var(--space-md);
}

.stats-display > span {
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-family: var(--font-mono);
}

/* ============================================================
 * Lists
 * ============================================================ */
.list-container {
  max-height: 300px;
  overflow-y: auto;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-xs);
  font-size: 0.75rem;
}

.list-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  vertical-align: top;
}

.list-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.list-item-meta {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  margin-left: 0;
  flex-shrink: 0;
  flex: 1 1 auto;
}

.list-item-remove {
  color: var(--accent-red);
  cursor: pointer;
  margin-left: var(--space-xs);
  font-size: 0.8rem;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.list-item-remove:hover {
  opacity: 1;
}

/* ============================================================
 * Map
 * ============================================================ */
.map-container {
  flex: 1;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
}

.map-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-muted);
  font-size: 0.9rem;
  pointer-events: none;
  z-index: 1000;
}

/* ============================================================
 * Modal
 * ============================================================ */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.modal[hidden] {
  display: none !important;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  min-width: 320px;
  text-align: center;
}

.modal-content h3 {
  font-size: 0.9rem;
  margin-bottom: var(--space-lg);
}

.progress-bar {
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: var(--space-md);
}

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

.progress-status {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

/* ============================================================
 * Scrollbar
 * ============================================================ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-subtle);
}

/* ============================================================
 * Leaflet overrides for dark theme
 * ============================================================ */
.leaflet-container {
  background: var(--bg-primary) !important;
}

/* Photo tooltip - handle long names */
.photo-tooltip {
  max-width: 300px;
  overflow-wrap: break-word;
}

.photo-tooltip::before {
  border: none !important;
}

/* Marker colors */
.photo-marker {
  filter: drop-shadow(0 0 3px rgba(0,0,0,0.5));
}

/* Original EXIF marker (yellow) */
.photo-marker[style*="🟡"] {
  opacity: 0.8;
}

/* Geolocated marker (green) */
.photo-marker[style*="🟢"] {
  opacity: 1;
}

/* ============================================================
 * Responsive
 * ============================================================ */
@media (max-width: 768px) {
  .app-main {
    flex-direction: column;
  }
  
  .panel-left {
    width: 100%;
    min-width: unset;
    max-height: 40vh;
  }
  
  .map-container {
    min-height: 40vh;
  }
}

/* ============================================================
 * Interactive Links (List ↔ Map)
 * ============================================================ */

/* Photo list item hover highlight */
.list-item.highlight {
  background: var(--bg-elevated);
  border: 2px solid var(--accent-blue);
  box-shadow: 0 0 16px rgba(59, 130, 246, 0.4);
}
