/* MISO Dashboard - Grid Status Style */

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

:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --border-color: #30363d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent-blue: #58a6ff;
  --accent-green: #3fb950;
  --accent-purple: #a371f7;
  --accent-yellow: #d29922;
  --accent-red: #f85149;
  --sidebar-width: 240px;
}

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

/* App Container */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.logo-img {
  max-width: 100%;
  height: auto;
  max-height: 50px;
  filter: invert(1);
}

.node-badge {
  background: var(--accent-blue);
  color: #fff;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: monospace;
  display: inline-block;
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(88, 166, 255, 0.1);
  color: var(--accent-blue);
  border-left-color: var(--accent-blue);
}

.nav-icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
}

.nav-label {
  font-size: 0.9rem;
  font-weight: 500;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
  font-size: 0.75rem;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-badge.connected .status-dot {
  background: var(--accent-green);
}

.status-badge.error .status-dot {
  background: var(--accent-red);
}

.status-badge.loading .status-dot {
  background: var(--accent-yellow);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.status-label {
  color: var(--text-secondary);
}

.last-update {
  color: var(--text-muted);
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 24px;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Views */
.view {
  display: none;
}

.view.active {
  display: block;
}

/* View Header */
.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.view-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 16px;
}

.interval-badge, .node-name, .zone-badge {
  background: var(--bg-tertiary);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.node-name {
  font-family: monospace;
  color: var(--accent-blue);
}

.zone-badge {
  color: var(--accent-purple);
}

/* Metrics Row */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
}

.metric-card.highlight {
  border-color: var(--accent-blue);
  background: linear-gradient(135deg, rgba(88, 166, 255, 0.1) 0%, var(--bg-secondary) 100%);
}

.metric-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

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

.metric-card.highlight .metric-value {
  color: var(--accent-blue);
}

.metric-card.site-load {
  border-color: var(--accent-green);
  background: linear-gradient(135deg, rgba(63, 185, 80, 0.1) 0%, var(--bg-secondary) 100%);
}

.metric-card.site-load .metric-value {
  color: var(--accent-green);
}

.metric-value.forecast-color {
  color: var(--accent-purple);
}

.metric-value.actual-color {
  color: var(--accent-green);
}

.metric-value.earnings-color {
  color: var(--accent-green);
}

.earnings-positive {
  color: var(--accent-green);
}

.earnings-negative {
  color: var(--accent-red);
}

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

.metric-unit {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}

.chart-card.full-width {
  grid-column: 1 / -1;
}

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

.chart-header h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.chart-body {
  padding: 16px;
  height: 280px;
}

.chart-body.tall {
  height: 350px;
}

/* Real Time Energy View */
.site-badge {
  background: var(--bg-tertiary);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--accent-green);
}

.realtime-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  padding: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.realtime-current {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.realtime-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.realtime-timestamp {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.realtime-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent-green);
  line-height: 1.1;
}

.realtime-unit {
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.realtime-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.realtime-chart-card {
  margin-bottom: 24px;
}

.realtime-chart-body {
  height: 450px;
  padding: 20px;
}

/* Time Selector */
.time-selector {
  display: flex;
  gap: 4px;
}

.time-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.time-btn:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

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

/* Data Card */
.data-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 24px;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.card-header h3 {
  font-size: 0.9rem;
  font-weight: 600;
}

.card-body {
  padding: 16px 20px;
}

.card-body.table-scroll {
  max-height: 400px;
  overflow-y: auto;
}

/* Data Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg-tertiary);
}

.data-table td {
  font-size: 0.875rem;
  color: var(--text-primary);
}

.data-table tbody tr:hover {
  background: var(--bg-tertiary);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* Catalog Grid */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.catalog-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 20px;
  transition: all 0.15s ease;
}

.catalog-card:hover {
  border-color: var(--accent-blue);
}

.catalog-card.coming-soon {
  opacity: 0.6;
}

.catalog-card.coming-soon:hover {
  border-color: var(--border-color);
}

.catalog-icon {
  font-size: 2rem;
  margin-bottom: 12px;
}

.catalog-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.catalog-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.5;
}

.catalog-meta {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.tag {
  background: var(--bg-tertiary);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.catalog-endpoint {
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--accent-blue);
  background: var(--bg-tertiary);
  padding: 6px 10px;
  border-radius: 4px;
}

/* API Documentation */
.api-doc {
  margin-bottom: 24px;
}

.api-doc:last-child {
  margin-bottom: 0;
}

.api-doc h4 {
  font-family: monospace;
  font-size: 0.9rem;
  color: var(--accent-green);
  margin-bottom: 8px;
}

.api-doc p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.api-doc pre {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 12px 16px;
  overflow-x: auto;
}

.api-doc code {
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
  font-size: 0.8rem;
  color: var(--text-primary);
}

/* Mobile Responsive */
@media (max-width: 1024px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 768px) {
  :root {
    --sidebar-width: 60px;
  }

  .sidebar-header {
    padding: 12px;
    text-align: center;
  }

  .logo-img {
    max-height: 30px;
  }

  .node-badge,
  .nav-label,
  .status-label,
  .last-update {
    display: none;
  }

  .logo {
    justify-content: center;
    margin-bottom: 0;
  }

  .nav-item {
    justify-content: center;
    padding: 16px;
  }

  .nav-icon {
    font-size: 1.25rem;
  }

  .sidebar-footer {
    padding: 12px;
  }

  .status-badge {
    justify-content: center;
  }

  .main-content {
    padding: 16px;
  }

  .view-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .view-header h1 {
    font-size: 1.25rem;
  }

  .metrics-row {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .metric-card {
    padding: 16px;
  }

  .metric-value {
    font-size: 1.5rem;
  }

  .chart-body {
    height: 220px;
  }

  .chart-body.tall {
    height: 280px;
  }

  .time-selector {
    flex-wrap: wrap;
  }

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

@media (max-width: 480px) {
  .metrics-row {
    grid-template-columns: 1fr;
  }
}
