/* ============================
   三维实景平台 - Glassmorphism Dark Theme
   Style reference: uupm.cc
   ============================ */

:root {
  --bg-dark: #0a0a0f;
  --glass-bg: rgba(17, 17, 26, 0.72);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-highlight: rgba(255, 255, 255, 0.04);
  --accent-blue: #60A5FA;
  --accent-purple: #A78BFA;
  --accent-cyan: #22D3EE;
  --accent-gradient: linear-gradient(135deg, #60A5FA 0%, #A78BFA 100%);
  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.4);
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --transition-spring: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}

/* ===== Glass Panel ===== */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glass);
}

.glass-badge {
  background: rgba(96, 165, 250, 0.12);
  border: 1px solid rgba(96, 165, 250, 0.2);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  font-size: 13px;
  color: var(--accent-blue);
  font-weight: 500;
}

/* ===== Loading Overlay ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-content {
  text-align: center;
  animation: fadeInUp 0.6s ease;
}

.loading-content h2 {
  font-size: 24px;
  font-weight: 600;
  margin-top: 24px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.loading-text {
  color: var(--text-secondary);
  margin-top: 8px;
  font-size: 14px;
}

.loading-ring {
  width: 48px;
  height: 48px;
  border: 3px solid var(--glass-border);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  margin: 0 auto;
  animation: spin 1s linear infinite;
}

/* ===== Sidebar Hint ===== */
.sidebar-hint {
  position: fixed;
  top: 90px;
  left: 344px;
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(96, 165, 250, 0.25);
  border-radius: var(--radius-md);
  box-shadow: 0 0 20px rgba(96, 165, 250, 0.15);
  animation: fadeInUp 0.5s ease, hintPulse 2s ease-in-out 1s infinite;
}

@keyframes hintPulse {
  0%, 100% { border-color: rgba(96, 165, 250, 0.25); box-shadow: 0 0 20px rgba(96, 165, 250, 0.15); }
  50% { border-color: rgba(96, 165, 250, 0.5); box-shadow: 0 0 30px rgba(96, 165, 250, 0.3); }
}

.sidebar-hint-arrow {
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 8px solid var(--accent-blue);
  flex-shrink: 0;
}

.sidebar-hint-text {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
}

.sidebar-hint-close {
  background: rgba(96, 165, 250, 0.15);
  border: 1px solid rgba(96, 165, 250, 0.2);
  border-radius: 6px;
  color: var(--accent-blue);
  font-size: 12px;
  padding: 4px 10px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  white-space: nowrap;
  transition: var(--transition-fast);
}

.sidebar-hint-close:hover {
  background: rgba(96, 165, 250, 0.25);
}

.sidebar-hint.hidden {
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

/* Mobile: position differently */
@media (max-width: 768px) {
  .sidebar-hint {
    top: 120px;
    left: 12px;
    right: 12px;
  }

  .sidebar-hint-arrow {
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 8px solid var(--accent-blue);
  }
}

/* ===== Welcome Overlay ===== */
.welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 8000;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.4s ease;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.welcome-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.welcome-card {
  width: 420px;
  max-width: 90vw;
  padding: 32px 28px;
  text-align: center;
  animation: fadeInUp 0.5s ease 0.1s both;
}

.welcome-header {
  margin-bottom: 24px;
}

.welcome-logo {
  width: 40px;
  height: 40px;
  margin-bottom: 12px;
}

.welcome-header h2 {
  font-size: 20px;
  font-weight: 600;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}

.welcome-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.welcome-body {
  text-align: left;
  margin-bottom: 24px;
}

.guide-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
}

.guide-item + .guide-item {
  border-top: 1px solid var(--glass-border);
}

.guide-icon {
  font-size: 18px;
  flex-shrink: 0;
  width: 28px;
  text-align: center;
  line-height: 1.4;
}

.guide-text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.guide-text strong {
  color: var(--text-primary);
  font-weight: 600;
}

.welcome-btn {
  width: 100%;
  padding: 10px 0;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent-gradient);
  color: white;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.welcome-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(96, 165, 250, 0.3);
}

.welcome-btn:active {
  transform: scale(0.98);
}

/* ===== Tileset Loading Indicator ===== */
.tileset-loading {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 500;
  animation: fadeIn 0.2s ease;
}

.tileset-loading-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 28px;
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glass);
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--glass-border);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

#tileset-loading-text {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ===== Stats Panel (top right) ===== */
.stats-panel {
  position: fixed;
  top: 84px;
  right: 16px;
  z-index: 100;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideInRight 0.5s ease 0.3s both;
  min-width: 160px;
}

.stat-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.stat-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  min-width: 28px;
  text-align: right;
}

.stat-unit {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-divider {
  width: 1px;
  height: 18px;
  background: var(--glass-border);
}

/* ===== Focus Button ===== */
.focus-btn {
  position: fixed;
  top: 50%;
  right: 16px;
  margin-top: -20px;
  z-index: 100;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  color: var(--text-secondary);
  transition: var(--transition-fast);
}

.focus-btn:hover {
  color: var(--accent-blue);
  border-color: rgba(96, 165, 250, 0.3);
  transform: scale(1.05);
}

.focus-btn:active {
  transform: scale(0.95);
}

/* ===== Animations ===== */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 8px rgba(96, 165, 250, 0.3); }
  50% { box-shadow: 0 0 20px rgba(96, 165, 250, 0.5); }
}

/* ===== App Layout ===== */
#app {
  width: 100vw;
  height: 100vh;
  position: relative;
}

#cesiumContainer {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}

/* Remove Cesium default UI */
.cesium-viewer-bottom,
.cesium-viewer-toolbar > div:first-child {
  display: none !important;
}

.cesium-widget-credits {
  display: none !important;
}

/* ===== Top Bar ===== */
.top-bar {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  height: 52px;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  animation: fadeInUp 0.5s ease 0.2s both;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 28px;
  height: 28px;
  animation: spin 8s linear infinite;
}

.logo-text {
  font-size: 16px;
  font-weight: 600;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.5px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.logo-version {
  font-size: 10px;
  font-weight: 400;
  background: none;
  -webkit-text-fill-color: var(--text-muted);
  color: var(--text-muted);
  letter-spacing: 0;
  opacity: 0.7;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.current-project-badge {
  font-size: 13px;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Sidebar ===== */
.sidebar {
  position: fixed;
  top: 84px;
  left: 16px;
  bottom: 80px;
  width: 320px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease;
}

.sidebar.collapsed {
  transform: translateX(-100%);
  opacity: 0;
  pointer-events: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--glass-border);
}

.sidebar-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-toggle:hover {
  background: var(--glass-highlight);
  color: var(--text-primary);
}

.sidebar-expand {
  position: fixed;
  top: 84px;
  left: 16px;
  width: 40px;
  height: 40px;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  color: var(--text-secondary);
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glass);
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease;
}

.sidebar-expand:hover {
  color: var(--accent-blue);
  border-color: rgba(96, 165, 250, 0.3);
}

/* ===== Search ===== */
.sidebar-search {
  padding: 12px 16px;
}

.search-input {
  width: 100%;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: var(--transition-fast);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:focus {
  border-color: rgba(96, 165, 250, 0.4);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.1);
}

/* ===== Project List ===== */
.project-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 12px 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.project-list::-webkit-scrollbar { width: 5px; }
.project-list::-webkit-scrollbar-track { background: transparent; }
.project-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

.project-group {
  margin-bottom: 8px;
}

.project-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
  border: 1px solid transparent;
}

.project-group-header:hover {
  background: var(--glass-highlight);
  border-color: var(--glass-border);
}

.project-group-header.active {
  background: rgba(96, 165, 250, 0.08);
  border-color: rgba(96, 165, 250, 0.15);
}

.project-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.project-icon svg {
  width: 18px;
  height: 18px;
  fill: white;
}

.project-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.project-info {
  flex: 1;
  min-width: 0;
}

.project-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.project-arrow {
  color: var(--text-muted);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.project-arrow.expanded {
  transform: rotate(90deg);
}

/* Year sub-items */
.project-versions {
  padding-left: 46px;
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease;
}

.project-versions.expanded {
  max-height: 300px;
}

.year-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: var(--transition-fast);
  position: relative;
}

.year-item:hover {
  background: var(--glass-highlight);
  color: var(--text-primary);
}

.year-item.active {
  color: var(--accent-blue);
  background: rgba(96, 165, 250, 0.06);
}

.year-item::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: var(--transition-fast);
}

.year-item.active::before {
  background: var(--accent-blue);
  box-shadow: 0 0 8px rgba(96, 165, 250, 0.5);
}

.year-item.loading::before {
  animation: pulseGlow 1.5s ease infinite;
  background: var(--accent-blue);
}

/* Single project (no versions) */
.project-single {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
  border: 1px solid transparent;
}

.project-single:hover {
  background: var(--glass-highlight);
  border-color: var(--glass-border);
}

.project-single.active {
  background: rgba(96, 165, 250, 0.08);
  border-color: rgba(96, 165, 250, 0.15);
}

/* ===== Year Switcher (floating) ===== */
.year-switcher {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  animation: fadeInUp 0.4s ease;
}

.year-switcher-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.year-buttons {
  display: flex;
  gap: 6px;
}

.year-btn {
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition-fast);
  font-weight: 500;
}

.year-btn:hover {
  background: var(--glass-highlight);
  border-color: rgba(255,255,255,0.15);
  color: var(--text-primary);
}

.year-btn.active {
  background: rgba(96, 165, 250, 0.15);
  border-color: rgba(96, 165, 250, 0.3);
  color: var(--accent-blue);
}

/* ===== Info Panel ===== */
.info-panel {
  position: fixed;
  bottom: 24px;
  right: 16px;
  z-index: 100;
  padding: 12px 18px;
  min-width: 180px;
  animation: slideInRight 0.5s ease 0.4s both;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
}

.info-row + .info-row {
  border-top: 1px solid var(--glass-border);
  margin-top: 3px;
  padding-top: 6px;
}

.info-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.info-value {
  font-size: 13px;
  color: var(--text-secondary);
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-weight: 500;
}

/* ===== Sidebar Overlay (mobile) ===== */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.visible {
  opacity: 1;
  visibility: visible;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .top-bar {
    top: 8px;
    left: 8px;
    right: 8px;
    height: 46px;
    padding: 0 14px;
    border-radius: var(--radius-md);
  }

  .logo-text { font-size: 14px; }
  .logo-icon { width: 24px; height: 24px; }

  .current-project-badge {
    max-width: 140px;
    font-size: 12px;
  }

  .sidebar {
    top: 0;
    left: 0;
    bottom: 0;
    width: 80vw;
    max-width: 320px;
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    z-index: 100;
  }

.sidebar.collapsed {
  transform: translateX(-100%);
  opacity: 0;
  pointer-events: none;
}

  .sidebar-expand {
    top: 65px;
    left: 8px;
    width: 46px;
    height: 46px;
    border-radius: var(--radius-md);
    z-index: 100;
  }

  .stats-panel {
    top: 62px;
    right: 8px;
    padding: 8px 12px;
    min-width: auto;
    border-radius: var(--radius-md);
    gap: 8px;
  }

  .stat-value { font-size: 12px; }
  .stat-unit { font-size: 10px; }

  .focus-btn {
    top: 50%;
    right: 4px;
    margin-top: -18px;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
  }

  .year-switcher {
    bottom: 16px;
    left: 8px;
    right: 8px;
    transform: none;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    justify-content: center;
    flex-wrap: wrap;
  }

  .year-btn {
    padding: 5px 12px;
    font-size: 12px;
  }

  .year-switcher-label { font-size: 11px; }

  .info-panel {
    bottom: 60px;
    right: 8px;
    padding: 10px 14px;
    min-width: 150px;
    border-radius: var(--radius-md);
  }

  .info-label { font-size: 10px; }
  .info-value { font-size: 12px; }

  .project-name { font-size: 13px; }
}

@media (max-width: 480px) {
  .sidebar { width: 85vw; }

  .focus-btn {
    left: auto;
    top: 50%;
    right: 4px;
  }

  .info-panel {
    display: none;
  }
}

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state-text {
  font-size: 14px;
}

/* ===== Footer Bar ===== */
.footer-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 6px 16px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  pointer-events: none;
}
.footer-bar a {
  color: rgba(255, 255, 255, 0.4);
  text-decoration: none;
  pointer-events: auto;
  transition: color 0.2s ease;
}
.footer-bar a:hover {
  color: rgba(255, 255, 255, 0.7);
}
