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

:root {
  --bg: #1a1a2e;
  --bg2: #16213e;
  --bg3: #0f3460;
  --accent: #e94560;
  --text: #eee;
  --text-muted: #999;
  --card-bg: #1e2a4a;
  --border: #2a3a5a;
  --success: #2ecc71;
  --danger: #e74c3c;
  --warning: #f39c12;
}

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

#app {
  display: flex;
  height: 100vh;
  position: relative;
}

/* Sidebar */
#sidebar {
  width: 340px;
  min-width: 340px;
  background: var(--bg2);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  z-index: 1000;
  transition: width 0.25s, min-width 0.25s;
  overflow: hidden;
  position: relative;
}
#sidebar.collapsed {
  width: 0;
  min-width: 0;
}
#sidebar.collapsed > * { opacity: 0; pointer-events: none; }

/* Sidebar toggle */
.sidebar-toggle {
  position: absolute;
  top: 12px;
  left: 340px;
  width: 28px; height: 28px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 6px 6px 0;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  font-size: 12px;
  transition: left 0.25s;
}
.sidebar-toggle:hover { color: var(--accent); }
#sidebar.collapsed ~ .sidebar-toggle { left: 0; }

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-header h1 { font-size: 18px; }
.sidebar-header .subtitle { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Upload zone */
.upload-zone {
  margin: 12px 16px;
  padding: 16px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-muted);
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent);
  background: rgba(233, 69, 96, 0.1);
}
.upload-zone i { margin-bottom: 8px; color: var(--accent); }
.upload-zone p { font-size: 13px; margin-bottom: 8px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border: none; border-radius: 6px;
  cursor: pointer; font-size: 13px; font-weight: 500;
  transition: all 0.2s;
}
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-upload { background: var(--accent); color: #fff; }
.btn-upload:hover { background: #d63850; }
.btn-save { background: var(--success); color: #fff; }
.btn-save:hover { opacity: 0.85; }
.btn-download { background: var(--bg3); color: #fff; }
.btn-download:hover { background: #0f4680; }
.btn-delete { background: var(--danger); color: #fff; }
.btn-delete:hover { opacity: 0.85; }

/* Photo sections */
.photo-section {
  padding: 8px 16px;
  flex: 1;
  overflow-y: auto;
}
.photo-section h2 {
  font-size: 13px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.photo-section .count {
  background: var(--bg3);
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
}
#placedSection { flex: 0 0 auto; max-height: 45%; }

.photo-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Photo card */
.photo-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: var(--card-bg);
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
}
.photo-card:hover {
  border-color: var(--accent);
  background: #253a5a;
}
.photo-card .thumb {
  width: 48px; height: 48px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}
.photo-card .info { flex: 1; min-width: 0; }
.photo-card .filename {
  font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.photo-card .meta {
  font-size: 11px;
  color: var(--text-muted);
}

/* Map container */
#mapContainer {
  flex: 1;
  position: relative;
}
.map-view {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: none;
}
.map-view.active { display: block; }

.map-controls {
  position: absolute;
  top: 12px; right: 56px;
  z-index: 1000;
  display: flex;
  gap: 6px;
}
.btn-map-toggle {
  background: rgba(26, 26, 46, 0.9);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.1);
  padding: 10px 14px;
  font-size: 13px;
}
.btn-map-toggle:hover {
  background: var(--accent);
}

/* Notification toast */
.notification {
  position: fixed;
  bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  z-index: 9999;
  padding: 12px 24px; border-radius: 8px; font-size: 14px;
  opacity: 0; transition: all 0.3s;
  pointer-events: none;
}
.notification.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.notification.success { background: var(--success); color: #fff; }
.notification.warning { background: var(--warning); color: #000; }
.notification.error { background: var(--danger); color: #fff; }

/* Placement mode banner */
.placement-banner {
  position: absolute;
  top: 60px; left: 50%; transform: translateX(-50%);
  z-index: 1000;
  background: var(--accent);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.placement-banner .btn-sm {
  background: rgba(255,255,255,0.2);
  color: #fff;
}
.placement-banner .btn-sm:hover { background: rgba(255,255,255,0.3); }

/* Loading */
.loading-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.spinner {
  width: 40px; height: 40px;
  border: 4px solid rgba(255,255,255,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Popup */
.photo-popup { min-width: 220px; }
.popup-img {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: 4px;
  margin-bottom: 8px;
}
.popup-coords {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.popup-coords label {
  flex: 1;
  font-size: 11px;
  color: #666;
}
.popup-coords input {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 12px;
  font-family: monospace;
}
.popup-actions {
  display: flex;
  gap: 4px;
}
.popup-actions .btn-sm { font-size: 11px; }
.leaflet-popup-content { margin: 10px 12px; }

/* Scrollbar */
#unplacedList, #placedList { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
#unplacedList::-webkit-scrollbar, #placedList::-webkit-scrollbar { width: 4px; }
#unplacedList::-webkit-scrollbar-thumb, #placedList::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Cesium popup */
.cesium-popup {
  position: absolute; z-index: 9999; pointer-events: auto;
  background: #fff; border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  padding: 12px; color: #333;
  transform: translate(-50%, calc(-100% - 12px));
}
.cesium-popup:before {
  content: ''; position: absolute; bottom: -8px; left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 12px; height: 12px; background: #fff;
}
.cesium-popup-close {
  position: absolute; top: 4px; right: 6px;
  background: none; border: none; cursor: pointer;
  color: #999; font-size: 18px; line-height: 1; padding: 2px 6px;
  z-index: 1;
}
.cesium-popup-close:hover { color: #333; }

/* Help modal */
.modal-overlay {
  position: fixed; inset: 0; z-index: 99998;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
}
.help-modal {
  position: relative;
  background: var(--bg2); color: var(--text);
  max-width: 560px; max-height: 85vh; overflow-y: auto;
  border-radius: 12px; padding: 32px;
  line-height: 1.7;
}
.help-modal h2 { font-size: 22px; margin-bottom: 4px; }
.help-modal h3 { font-size: 15px; margin: 20px 0 8px; color: var(--accent); }
.help-modal p, .help-modal li { font-size: 14px; color: #ccc; }
.help-modal ul { padding-left: 20px; }
.help-modal li { margin-bottom: 4px; }
.help-modal strong { color: #fff; }
.help-modal code { background: var(--bg3); padding: 1px 6px; border-radius: 3px; font-size: 13px; }
.help-modal a { color: var(--accent); }
.help-subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.help-footer { margin-top: 24px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-muted); }
.modal-close {
  position: absolute; top: 12px; right: 16px;
  background: none; border: none; color: var(--text-muted);
  font-size: 28px; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: #fff; }

/* Utility */
.hidden { display: none !important; }
