/* Starseed Fleet Dashboard -- Dark Theme */

:root {
  --bg-primary: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --accent: #3b82f6;
  --health-green: #22c55e;
  --health-yellow: #eab308;
  --health-red: #ef4444;
  --border: #334155;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
}

/* --- Header --- */

.fleet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.fleet-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.fleet-summary {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.summary-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.summary-value {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
}

.summary-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.connection-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-secondary);
  flex-shrink: 0;
  transition: background 0.3s ease;
}

.connection-status.connected {
  background: var(--health-green);
}

.connection-status.disconnected {
  background: var(--health-red);
}

.connection-status.reconnecting {
  background: var(--health-yellow);
}

/* --- Org Grid --- */

main {
  padding: 1rem 1.5rem;
}

.org-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}

/* --- Org Card --- */

.org-card {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.org-card:hover {
  background: var(--bg-card-hover);
}

.org-card.expanded {
  border-color: var(--accent);
}

/* --- Card Header --- */

.card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.health-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.org-name {
  font-weight: 600;
  font-size: 0.95rem;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.org-status {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* --- Status Badges --- */

.badge-active {
  background: rgba(34, 197, 94, 0.15);
  color: var(--health-green);
}

.badge-paused {
  background: rgba(234, 179, 8, 0.15);
  color: var(--health-yellow);
}

.badge-degraded {
  background: rgba(239, 68, 68, 0.15);
  color: var(--health-red);
}

.badge-provisioning {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
}

.badge-staging {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-secondary);
}

.badge-decommissioning {
  background: rgba(239, 68, 68, 0.1);
  color: var(--health-red);
}

/* --- Card Metrics --- */

.card-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
}

.metric-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.metric-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

/* --- Card Sparkline --- */

.card-sparkline {
  margin-top: 0.25rem;
  margin-bottom: 0.5rem;
}

.card-sparkline svg {
  width: 100%;
  height: 30px;
}

/* --- Card Scorecards (top 3 metrics) --- */

.card-scorecards {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.top-metrics {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.metric-pill {
  font-size: 0.68rem;
  padding: 0.2rem 0.5rem;
  border-radius: 10px;
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent);
  font-weight: 500;
  white-space: nowrap;
}

.no-data {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* --- Expanded Panel --- */

.expanded-panel {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: 8px;
  margin-top: 1rem;
  border: 1px solid var(--accent);
}

.expanded-panel.hidden {
  display: none;
}

.expanded-panel h2 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.scorecard-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

.scorecard-table th,
.scorecard-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.scorecard-table th {
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
}

.scorecard-table td:last-child {
  text-align: right;
  font-weight: 600;
}

.expanded-section {
  margin-bottom: 1.25rem;
}

.expanded-section h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.btn-mc {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 1.25rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-mc:hover {
  background: #2563eb;
}

/* --- Chart Container & Toggle --- */

.chart-container {
  max-width: 100%;
  padding: 0.5rem 0;
  position: relative;
  height: 300px;
}

.chart-toggle {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.chart-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.chart-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.chart-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* --- All Metrics Table --- */

.all-metrics td:last-child {
  text-align: right;
}

.fleet-avg-cell {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.below-fleet-avg {
  display: inline-block;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.4rem;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.15);
  color: var(--health-red);
  margin-left: 0.35rem;
  vertical-align: middle;
  font-weight: 500;
}

/* --- Skeleton Loading Animation --- */

.skeleton-loading {
  position: relative;
  overflow: hidden;
  color: transparent !important;
}

.skeleton-loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(148, 163, 184, 0.08), transparent);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

@keyframes skeleton-pulse {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* --- Responsive --- */

@media (max-width: 768px) {
  .fleet-header {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .fleet-summary {
    gap: 1rem;
    order: 3;
    width: 100%;
    justify-content: space-around;
  }

  .org-grid {
    grid-template-columns: 1fr;
  }

  .card-metrics {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* --- Tab Navigation --- */

.tab-nav {
  display: flex;
  gap: 0;
  padding: 0 2rem;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  padding: 0.75rem 1.5rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(59, 130, 246, 0.1);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* --- Approval Queue --- */

.approval-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 2rem;
}

.approval-controls select {
  padding: 0.5rem 1rem;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
}

.approval-count {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.drafts-list {
  padding: 0 2rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.draft-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

.draft-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.channel-badge {
  background: var(--accent);
  color: #fff;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
}

.priority-badge {
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.priority-time_sensitive {
  background: var(--health-red);
  color: #fff;
}

.priority-standard {
  background: var(--accent);
  color: #fff;
}

.priority-evergreen {
  background: var(--health-green);
  color: #fff;
}

.draft-time {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-left: auto;
}

.draft-content {
  color: var(--text-primary);
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 0.75rem;
  white-space: pre-wrap;
}

.draft-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-approve {
  padding: 0.4rem 1rem;
  background: var(--health-green);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
}

.btn-approve:hover {
  background: #16a34a;
}

.btn-reject {
  padding: 0.4rem 1rem;
  background: var(--health-red);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
}

.btn-reject:hover {
  background: #dc2626;
}

.reject-reason {
  flex: 1;
  padding: 0.4rem 0.75rem;
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
}

.empty-text, .error-text {
  color: var(--text-secondary);
  text-align: center;
  padding: 2rem;
}

.error-text {
  color: var(--health-red);
}

.hidden {
  display: none !important;
}
