/* app.css - astroGeo v3 */
:root {
  --bg: #0d1117;
  --panel: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #58a6ff;
  --radius: 6px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; font-size: 13px; }
#app { height: 100%; display: flex; flex-direction: column; }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand .title { font-weight: 600; font-size: 14px; }
.brand .subtitle { font-size: 10px; color: var(--muted); }

.toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sep { width: 1px; height: 18px; background: var(--border); }

.btn {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn-secondary { color: var(--muted); }
.btn-small { padding: 4px 8px; font-size: 11px; }

.input, .select {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
}
.input { width: 120px; }
.input::placeholder { color: var(--muted); }
.select-small { width: 60px; padding: 4px 6px; }

.toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.toggle input { accent-color: var(--accent); width: 14px; height: 14px; }

.zoom-slider {
  width: 80px;
  height: 4px;
  accent-color: var(--accent);
}

/* Main Layout */
.main { flex: 1; display: grid; grid-template-columns: 280px 1fr; min-height: 0; }

.sidebar {
  padding: 8px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
}

.panel-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.panel-title { font-weight: 600; font-size: 12px; }
.panel-meta { font-size: 10px; color: var(--muted); }

.kv-row { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px solid var(--border); font-size: 11px; }
.kv-row:last-child { border-bottom: none; }
.kv-k { color: var(--muted); }
.kv-v { font-family: monospace; }

/* Legend */
.legend { display: flex; flex-direction: column; gap: 2px; }
.legend-item {
  display: flex;
  justify-content: space-between;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
}
.legend-item:hover { background: var(--panel); }
.legend-name { text-transform: capitalize; }
.legend-count { color: var(--muted); font-family: monospace; }

/* Style Panel */
.style-panel { font-size: 11px; }
.style-section { margin-bottom: 10px; }
.style-title { font-weight: 600; margin-bottom: 6px; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.style-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.style-label { width: 50px; font-size: 11px; }
.style-color {
  width: 28px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  background: transparent;
}
.style-weight {
  width: 44px;
  padding: 3px 4px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg);
  color: var(--text);
  font-size: 11px;
}
.style-dash {
  flex: 1;
  padding: 3px 4px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg);
  color: var(--text);
  font-size: 11px;
}

.style-range {
  flex: 1;
  height: 4px;
  accent-color: var(--accent);
}

.style-val {
  font-size: 10px;
  color: var(--muted);
  width: 30px;
  text-align: right;
}

/* Zodiac edge label style */
.edge-zodiac {
  opacity: 0.8;
  font-size: 9px;
}

/* Cards */
.cards { max-height: 200px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.card {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
}
.card:hover { border-color: var(--accent); }
.card.selected { border-color: var(--accent); background: rgba(88, 166, 255, 0.1); }
.card-title { font-weight: 500; margin-bottom: 2px; font-size: 12px; }
.card-meta { display: flex; gap: 8px; color: var(--muted); font-family: monospace; font-size: 10px; }
.card-more { text-align: center; color: var(--muted); font-size: 10px; padding: 6px; }

/* Dropzone */
.dropzone { border-style: dashed; text-align: center; padding: 16px; }
.dropzone.dragover { border-color: var(--accent); }
.drop-title { font-weight: 500; font-size: 12px; }
.drop-sub { font-size: 10px; color: var(--muted); margin-top: 2px; }

/* Map */
.mapwrap { position: relative; min-width: 0; min-height: 0; }
#map { position: absolute; inset: 0; }

/* Edge Labels Container */
.edge-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 500;
  overflow: hidden;
}

.edge-label {
  position: absolute;
  padding: 3px 6px;
  background: rgba(13, 17, 23, 0.92);
  font-size: 10px;
  font-family: system-ui, sans-serif;
  line-height: 1.3;
  pointer-events: auto;
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
}

.edge-label:hover {
  background: rgba(13, 17, 23, 1);
  z-index: 10;
}

.edge-top {
  transform: translateX(-50%);
  border-top: 3px solid var(--accent);
  border-radius: 0 0 4px 4px;
}
.edge-bottom {
  transform: translateX(-50%);
  border-bottom: 3px solid var(--accent);
  border-radius: 4px 4px 0 0;
}
.edge-left {
  transform: translateY(-50%);
  border-left: 3px solid var(--accent);
  border-radius: 0 4px 4px 0;
}
.edge-right {
  transform: translateY(-50%);
  border-right: 3px solid var(--accent);
  border-radius: 4px 0 0 4px;
}

.edge-axis {
  font-weight: 700;
  font-size: 11px;
}
.edge-deg {
  color: rgba(255, 255, 255, 1);
}
.edge-symbol {
  font-size: 12px;
}

/* Zoom Status */
.zoom-status {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 8px;
  background: rgba(13, 17, 23, 0.85);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  font-family: monospace;
  z-index: 500;
}

/* Chart Info Text Box (Sidebar) */
.chart-info-box {
  padding: 12px 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.chart-info-box:hover {
  background: var(--panel);
}

.chart-info-box.hidden {
  display: none;
}

.chart-info-text {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
  user-select: text;
  white-space: pre-line;
}

.chart-info-text .chart-date {
  font-size: 20px;
  font-weight: 400;
  color: #22c55e;
  font-family: monospace;
  margin-top: 8px;
  display: block;
}

/* Toast */
.toast {
  position: absolute;
  bottom: 16px;
  left: 16px;
  padding: 6px 10px;
  background: rgba(13, 17, 23, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  z-index: 600;
}
.toast.hidden { display: none; }

/* Popup */
.popup-content { font-size: 12px; line-height: 1.5; }
.popup-title { font-weight: 600; margin-bottom: 4px; font-size: 13px; }

/* Zone symbols */
.zone-symbol {
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-shadow: 0 0 8px rgba(0,0,0,0.5);
  font-weight: bold;
}

/* Context Panel */
.context-panel {
  position: absolute;
  z-index: 2000;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  min-width: 200px;
  max-width: 280px;
  font-family: system-ui, sans-serif;
}

.context-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px 8px 0 0;
}

.context-title {
  font-weight: 600;
  font-size: 12px;
  color: var(--text);
}

.context-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--muted);
  padding: 0 4px;
  line-height: 1;
}

.context-close:hover {
  color: var(--text);
}

.context-text {
  width: 100%;
  min-height: 180px;
  max-height: 350px;
  padding: 10px 12px;
  border: none;
  background: var(--bg);
  color: var(--text);
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  box-sizing: border-box;
  overflow-y: auto;
}

.context-text:focus {
  outline: none;
}

.context-actions {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

.btn-small {
  padding: 4px 12px;
  font-size: 11px;
}

/* Responsive */
@media (max-width: 900px) {
  .main { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); max-height: 220px; flex-direction: row; flex-wrap: wrap; }
  .sidebar .panel { flex: 1; min-width: 140px; }
  .mapwrap { min-height: 400px; }
}
