/* Planet Dashboard — full-viewport canvas-based ecosystem visualization */

.planet-dashboard {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #08081a;
}

.planet-dashboard canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Header */
.dashboard-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  pointer-events: none;
  z-index: 10;
}

.dashboard-title {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 18px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 0.5px;
  margin: 0;
}

.dashboard-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}

.dashboard-updated {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.35);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.dashboard-refresh {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 6px 8px;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
}

.dashboard-refresh:hover {
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.8);
}

/* Loading */
.dashboard-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  gap: 6px;
  z-index: 20;
}

.loading-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  animation: loading-pulse 1.2s infinite ease-in-out;
}

.loading-dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes loading-pulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.2); }
}

/* Error */
.dashboard-error {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 20;
}

.dashboard-error p {
  color: rgba(255, 255, 255, 0.5);
  font-size: 14px;
  margin-bottom: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.dashboard-error button {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.7);
  padding: 8px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  transition: all 0.2s;
}

.dashboard-error button:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* Legend / Visual Key */
.dashboard-legend {
  position: absolute;
  bottom: 16px;
  left: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  z-index: 10;
  pointer-events: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.legend-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-label {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.25);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
}

.legend-text {
  font-style: italic;
}

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

.legend-healthy { background: hsl(210, 60%, 55%); }
.legend-warning { background: hsl(45, 70%, 55%); }
.legend-unhealthy { background: hsl(0, 65%, 50%); }
.legend-growing { background: hsl(120, 65%, 50%); box-shadow: 0 0 6px hsl(120, 65%, 50%); }
.legend-shrinking { background: hsl(0, 65%, 50%); box-shadow: 0 0 6px hsl(0, 65%, 50%); }

.legend-ring {
  width: 12px;
  height: 6px;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
}

.legend-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: hsl(0, 65%, 50%);
  animation: legend-pulse-anim 1.5s ease-in-out infinite;
}

@keyframes legend-pulse-anim {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.6; }
}

.legend-refresh-info {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.2);
}

/* Detail Panel */
.detail-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 340px;
  height: 100%;
  background: rgba(12, 12, 36, 0.95);
  backdrop-filter: blur(12px);
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 30;
  overflow-y: auto;
  padding: 20px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.detail-panel.panel-open {
  transform: translateX(0);
}

.panel-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: color 0.2s;
}

.panel-close:hover {
  color: rgba(255, 255, 255, 0.8);
}

/* Panel content */
.panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-right: 32px;
}

.panel-planet-name {
  font-size: 20px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.95);
  margin: 0;
}

.panel-visit-link {
  font-size: 13px;
  color: rgba(140, 180, 255, 0.8);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.2s;
}

.panel-visit-link:hover {
  color: rgba(180, 210, 255, 1);
}

/* Health bar */
.panel-health {
  margin-bottom: 20px;
}

.panel-health-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 6px;
}

.panel-health-value {
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
}

.panel-health-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.panel-health-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* Metrics grid */
.panel-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.metric-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.metric-value {
  font-size: 16px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
}

.metric-label {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
}

.metric-warning .metric-value {
  color: hsl(45, 90%, 65%);
}

.metric-warning {
  border-color: rgba(255, 200, 50, 0.15);
}

.metric-traffic .metric-value {
  color: hsl(210, 70%, 70%);
}

.metric-growth .metric-value {
  color: hsl(120, 65%, 60%);
}

.metric-growth {
  border-color: rgba(80, 200, 80, 0.15);
}

.metric-shrink .metric-value {
  color: hsl(0, 65%, 65%);
}

.metric-shrink {
  border-color: rgba(255, 100, 100, 0.15);
}

/* Sections */
.panel-section {
  margin-bottom: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.panel-section h3 {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.45);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 8px 0;
}

.panel-work-items {
  display: flex;
  gap: 12px;
}

.work-item {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
}

.work-bug {
  color: hsl(0, 70%, 65%);
}

.metric-dim .metric-value {
  color: rgba(255, 255, 255, 0.3);
  font-size: 13px;
}

.metric-dim {
  border-color: rgba(255, 255, 255, 0.03);
  background: rgba(255, 255, 255, 0.02);
}

.panel-traffic-section {
  background: rgba(255, 255, 255, 0.02);
  margin-left: -20px;
  margin-right: -20px;
  padding: 12px 20px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.panel-hint {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.25);
  font-style: italic;
  margin-top: 8px;
}

.panel-footer-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-deploy-info,
.panel-importance-info {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.35);
}

/* View toggle buttons */
.view-toggle {
  display: flex;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  overflow: hidden;
}

.view-toggle-btn {
  background: rgba(255, 255, 255, 0.05);
  border: none;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  padding: 6px 9px;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
}

.view-toggle-btn:last-child {
  border-right: none;
}

.view-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.7);
}

.view-toggle-btn.active {
  background: rgba(100, 160, 255, 0.2);
  color: rgba(140, 190, 255, 0.9);
}

/* Table view container */
.table-view {
  position: absolute;
  top: 56px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  z-index: 5;
  background: #08081a;
}

.table-wrapper {
  height: 100%;
  overflow: auto;
  padding: 0 24px 24px;
}

/* Ecosystem table */
.ecosystem-table {
  width: 100%;
  border-collapse: collapse;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.8);
}

.ecosystem-table thead {
  position: sticky;
  top: 0;
  background: rgba(8, 8, 26, 0.98);
  backdrop-filter: blur(8px);
  z-index: 2;
}

.ecosystem-table th {
  padding: 12px 10px 10px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.35);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  user-select: none;
}

.ecosystem-table th.col-num {
  text-align: right;
}

.ecosystem-table th.sortable {
  cursor: pointer;
}

.ecosystem-table th.sortable:hover {
  color: rgba(255, 255, 255, 0.6);
}

.ecosystem-table th.sort-asc,
.ecosystem-table th.sort-desc {
  color: rgba(140, 190, 255, 0.9);
}

.sort-icon::after {
  content: "";
  display: inline-block;
  margin-left: 4px;
  opacity: 0.4;
}

th.sort-asc .sort-icon::after {
  content: "↑";
  opacity: 1;
}

th.sort-desc .sort-icon::after {
  content: "↓";
  opacity: 1;
}

.ecosystem-table td {
  padding: 10px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}

.ecosystem-table td.col-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ecosystem-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.table-app-link {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  font-weight: 500;
}

.table-app-link:hover {
  color: rgba(140, 190, 255, 1);
}

.table-app-name {
  color: rgba(255, 255, 255, 0.5);
  font-size: 11px;
}

.table-type-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.type-game {
  background: rgba(180, 100, 255, 0.15);
  color: rgba(200, 140, 255, 0.85);
}

.type-tool {
  background: rgba(100, 160, 255, 0.15);
  color: rgba(140, 190, 255, 0.85);
}

.type-infrastructure {
  background: rgba(255, 200, 50, 0.1);
  color: rgba(255, 210, 80, 0.75);
}

.table-growth-pos {
  color: hsl(120, 65%, 55%);
}

.table-growth-neg {
  color: hsl(0, 65%, 60%);
}

.table-growth-neutral {
  color: rgba(255, 255, 255, 0.35);
}

.table-health-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.table-health-track {
  width: 50px;
  height: 4px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 2px;
  overflow: hidden;
}

.table-health-fill {
  height: 100%;
  border-radius: 2px;
}

.table-error-count {
  color: rgba(255, 255, 255, 0.6);
}

.table-error-count.has-errors {
  color: hsl(0, 70%, 65%);
}

.table-deploy-time {
  color: rgba(255, 255, 255, 0.35);
  font-size: 12px;
}

.table-no-data {
  color: rgba(255, 255, 255, 0.2);
}

/* Expandable query rows in table */
.query-row {
  display: none;
}

.query-row.expanded {
  display: table-row;
}

.query-row td {
  padding: 8px 10px 8px 24px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.query-row-content {
  font-size: 12px;
}

.query-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
}

.query-item {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  color: rgba(255, 255, 255, 0.6);
}

.query-text {
  color: rgba(255, 255, 255, 0.8);
  font-weight: 500;
}

.query-stats {
  color: rgba(255, 255, 255, 0.35);
  font-size: 11px;
}

/* Panel top queries */
.panel-query-title {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.35);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 8px 0 6px;
}

.panel-query-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.panel-query-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 4px;
}

.panel-query-text {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 500;
}

.panel-query-stats {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
  white-space: nowrap;
  margin-left: 8px;
}

/* Mobile: panel slides up from bottom */
/* Mobile table adjustments */
@media (max-width: 640px) {
  .table-view {
    top: 48px;
  }

  .table-wrapper {
    padding: 0 12px 12px;
  }

  .ecosystem-table {
    font-size: 12px;
  }

  .ecosystem-table th,
  .ecosystem-table td {
    padding: 8px 6px;
  }

  /* Hide lower-priority columns on mobile */
  .col-type,
  th.col-type,
  td:nth-child(2) {
    display: none;
  }

  .table-health-track {
    width: 32px;
  }

  .table-type-badge {
    font-size: 9px;
    padding: 1px 4px;
  }

  .view-toggle-btn {
    padding: 5px 7px;
  }
}

/* Mobile: panel slides up from bottom */
@media (max-width: 640px) {
  .detail-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 60%;
    border-left: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    transform: translateY(100%);
    border-radius: 16px 16px 0 0;
  }

  .detail-panel.panel-open {
    transform: translateY(0);
  }

  .dashboard-legend {
    bottom: 8px;
    left: 12px;
    gap: 4px 12px;
  }

  .legend-item {
    font-size: 9px;
  }

  .legend-label {
    font-size: 9px;
  }

  .legend-refresh-info {
    display: none;
  }

  .dashboard-header {
    padding: 12px 16px;
  }

  .dashboard-title {
    font-size: 15px;
  }
}
