/* Base Layout */
html {
  font-size: 16px;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-normal);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  overflow-x: hidden;
}

/* Header */
.header {
  position: sticky;
  top: 0;
  height: var(--header-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-primary);
  backdrop-filter: blur(8px);
  z-index: var(--z-dropdown);
}

.header__container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 var(--space-6);
  max-width: var(--max-content-width);
  margin: 0 auto;
}

.header__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.header__icon {
  width: 24px;
  height: 24px;
  color: var(--color-primary-500);
}

.header__title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.header__summary {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.header-summary__item {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.header-summary__label {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.header-summary__value {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.header-summary__divider {
  width: 1px;
  height: 32px;
  background-color: var(--border-primary);
}

@media (max-width: 768px) {
  .header__summary {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    row-gap: var(--space-2);
  }

  .header-summary__divider {
    display: none;
  }

  .header-summary__item {
    flex: 1 1 45%;
  }
}

.header__status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
}

.header__controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.header__stats {
  display: flex;
  gap: var(--space-4);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-primary);
}

.stat-label {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: var(--font-weight-medium);
}

.stat-value {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.header__nav {
  display: flex;
  gap: var(--space-1);
}

/* Navigation */
.nav-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-secondary);
  background-color: transparent;
  transition: all var(--transition-fast);
  cursor: pointer;
}

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

.nav-btn--active {
  color: var(--color-primary-400);
  background-color: var(--color-primary-900);
}

.nav-btn .icon {
  width: 16px;
  height: 16px;
}

/* Status Indicator */
.status-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.status-indicator__dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background-color: var(--color-error-500);
  animation: pulse 2s infinite;
}

.status-indicator--connected .status-indicator__dot {
  background-color: var(--color-success-500);
  animation: none;
}

.status-indicator--connecting .status-indicator__dot {
  background-color: var(--color-warning-500);
}

.status-indicator__text {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-weight: var(--font-weight-medium);
}

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

/* Main Content */
.main {
  min-height: calc(100vh - var(--header-height));
  max-width: var(--max-content-width);
  margin: 0 auto;
  padding: var(--space-6);
}

/* Views */
.view {
  display: none;
  animation: fadeIn 0.3s ease;
}

.view--active {
  display: block;
}

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

/* Controls Panel */
.controls-panel {
  margin-bottom: var(--space-6);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.controls-panel__container {
  display: flex;
  gap: var(--space-6);
  padding: var(--space-4) var(--space-6);
  align-items: center;
  flex-wrap: wrap;
}

.controls-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.controls-label {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Charts Container */
.charts-container {
  position: relative;
  min-height: 60vh;
}

.charts-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  margin-bottom: var(--space-6);
}

/* Empty State */
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
}

.empty-state--hidden {
  display: none;
}

.empty-state__content {
  max-width: 400px;
}

.empty-state__icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-6);
  color: var(--color-primary-500);
  opacity: 0.5;
}

.empty-state__title {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.empty-state__description {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  margin-bottom: var(--space-6);
  line-height: var(--line-height-relaxed);
}

/* Loading Spinner */
.loading-spinner {
  display: flex;
  justify-content: center;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-primary);
  border-top: 3px solid var(--color-primary-500);
  border-radius: var(--radius-full);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Settings & Logs Views */
.settings-container,
.logs-container {
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
  padding: var(--space-12);
}

.settings-container h2,
.logs-container h2 {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-4);
}

.settings-container p,
.logs-container p {
  font-size: var(--font-size-lg);
  color: var(--text-secondary);
}

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

  .controls-panel__container {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-4);
  }
}

@media (max-width: 1200px) {
  .header__controls .btn__text {
    display: none;
  }

  .header__controls .btn__shortcut {
    display: none;
  }

  .header__controls .btn {
    min-width: auto;
    padding: var(--space-2);
  }
}

@media (max-width: 768px) {
  .header__container {
    padding: 0 var(--space-4);
    flex-wrap: wrap;
  }

  .header__brand {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-1);
  }

  .header__nav {
    flex-direction: column;
  }

  .header__controls {
    order: 3;
    width: 100%;
    justify-content: center;
    padding-top: var(--space-2);
  }

  .main {
    padding: var(--space-4);
  }

  .nav-btn span {
    display: none;
  }
}

@media (max-width: 480px) {
  .header__status {
    display: none;
  }

  .charts-grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
}
