/*
 * Dashboard Advanced UI Styles
 * Tabbed interface for Overview, Channels, Devices, Logs
 */

/* ========== Tab Bar ========== */
.dash-tabs {
  display: flex;
  border-bottom: 1px solid var(--md-outline-variant);
  background: var(--md-surface-container-low);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.dash-tab {
  flex: 1;
  min-width: 80px;
  padding: 14px 16px;
  border: none;
  background: transparent;
  color: var(--md-on-surface-variant);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  position: relative;
  transition: color var(--md-motion-duration-short) var(--md-motion-standard),
              background var(--md-motion-duration-short) var(--md-motion-standard);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.dash-tab:hover {
  background: rgba(240, 240, 245, 0.05);
  color: var(--md-on-surface);
}

.dash-tab.active {
  color: var(--md-primary);
}

.dash-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 16px;
  right: 16px;
  height: 3px;
  background: var(--md-primary);
  border-radius: 3px 3px 0 0;
}

/* ========== Tab Content ========== */
.dash-tab-content {
  max-width: 900px;
  margin: 0 auto;
}

.dash-panel {
  display: none;
  padding: 16px;
}

.dash-panel.active {
  display: block;
}

/* ========== Overview Grid ========== */
.dash-overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.dash-stat-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--md-surface-container);
  border-radius: var(--md-shape-md);
  border: 1px solid var(--md-outline-variant);
}

.dash-stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--md-shape-md);
  flex-shrink: 0;
}

.dash-stat-icon.green { background: rgba(0, 230, 118, 0.12); color: var(--sc-green); }
.dash-stat-icon.green svg { fill: var(--sc-green); }
.dash-stat-icon.amber { background: rgba(255, 143, 0, 0.12); color: var(--sc-amber); }
.dash-stat-icon.amber svg { fill: var(--sc-amber); }
.dash-stat-icon.cyan { background: rgba(0, 188, 212, 0.12); color: var(--sc-cyan); }
.dash-stat-icon.cyan svg { fill: var(--sc-cyan); }
.dash-stat-icon.purple { background: rgba(156, 39, 176, 0.12); color: var(--sc-purple); }
.dash-stat-icon.purple svg { fill: var(--sc-purple); }

.dash-stat-info {
  flex: 1;
  min-width: 0;
}

.dash-stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--md-on-surface);
  line-height: 1.4;
}

.dash-stat-label {
  font-size: 0.75rem;
  color: var(--md-on-surface-variant);
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* ========== Sections ========== */
.dash-section {
  margin-bottom: 16px;
}

/* ========== Capacity Bars ========== */
.dash-capacity-bars {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0 16px;
}

.dash-capacity-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dash-capacity-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dash-capacity-title {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--md-on-surface);
}

.dash-capacity-value {
  font-size: 0.75rem;
  color: var(--md-on-surface-variant);
  font-weight: 500;
}

.dash-capacity-bar-bg {
  height: 8px;
  background: var(--md-surface-variant);
  border-radius: 4px;
  overflow: hidden;
}

.dash-capacity-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--sc-green), var(--sc-amber));
  border-radius: 4px;
  transition: width 0.5s var(--md-motion-standard);
  min-width: 0;
}

.dash-capacity-bar-fill.warning {
  background: linear-gradient(90deg, var(--sc-amber), var(--sc-red));
}

/* ========== Server Info List ========== */
.dash-info-list {
  padding: 0 16px;
}

.dash-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--md-outline-variant);
}

.dash-info-row:last-child {
  border-bottom: none;
}

.dash-info-key {
  font-size: 0.8125rem;
  color: var(--md-on-surface-variant);
  font-weight: 500;
}

.dash-info-val {
  font-size: 0.8125rem;
  color: var(--md-on-surface);
  font-weight: 500;
  font-family: 'Roboto Mono', monospace;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ========== Channel / Device List Container ========== */
.dash-list-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dash-empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--md-on-surface-variant);
  font-size: 0.875rem;
}

/* ========== Channel Card ========== */
.dash-channel-card {
  background: var(--md-surface-container);
  border-radius: var(--md-shape-md);
  border: 1px solid var(--md-outline-variant);
  padding: 16px;
}

.dash-channel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.dash-channel-name {
  flex: 1;
  font-size: 1rem;
  font-weight: 600;
  color: var(--md-on-surface);
}

.dash-channel-badge {
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--md-shape-full);
  background: rgba(0, 230, 118, 0.15);
  color: var(--sc-green);
  letter-spacing: 0.03em;
}

.dash-channel-members {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dash-member-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 6px;
  background: var(--md-surface-container-high);
  border-radius: var(--md-shape-full);
  font-size: 0.75rem;
  color: var(--md-on-surface);
  border: 1px solid var(--md-outline-variant);
}

.dash-member-chip.speaking {
  border-color: var(--sc-green);
  background: rgba(0, 230, 118, 0.08);
}

.dash-member-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--md-on-surface-variant);
  flex-shrink: 0;
}

.dash-member-dot.online {
  background: var(--sc-green);
  box-shadow: 0 0 4px rgba(0, 230, 118, 0.4);
}

.dash-member-dot.speaking {
  background: var(--sc-green);
  box-shadow: 0 0 6px rgba(0, 230, 118, 0.6);
  animation: speak-pulse 1s ease-in-out infinite;
}

@keyframes speak-pulse {
  0%, 100% { box-shadow: 0 0 4px rgba(0, 230, 118, 0.4); }
  50% { box-shadow: 0 0 10px rgba(0, 230, 118, 0.8); }
}

/* ========== Device Card ========== */
.dash-device-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--md-surface-container);
  border-radius: var(--md-shape-md);
  border: 1px solid var(--md-outline-variant);
  padding: 14px 16px;
}

.dash-device-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--sc-amber);
  color: #000;
  font-size: 1rem;
  font-weight: 700;
  flex-shrink: 0;
}

.dash-device-info {
  flex: 1;
  min-width: 0;
}

.dash-device-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--md-on-surface);
}

.dash-device-meta {
  font-size: 0.75rem;
  color: var(--md-on-surface-variant);
  margin-top: 2px;
}

.dash-device-metrics {
  display: flex;
  gap: 12px;
  font-size: 0.6875rem;
  color: var(--md-on-surface-variant);
}

.dash-metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.dash-metric-val {
  font-weight: 700;
  color: var(--md-on-surface);
  font-size: 0.75rem;
}

.dash-metric-label {
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ========== Logs ========== */
.dash-logs-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 12px;
  flex-wrap: wrap;
}

.dash-select {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--md-shape-sm);
  background: var(--md-surface-container);
  color: var(--md-on-surface);
  font-family: inherit;
  font-size: 0.8125rem;
  outline: none;
  cursor: pointer;
  appearance: auto;
}

.dash-select:focus {
  border-color: var(--md-primary);
}

.dash-search-input {
  flex: 1;
  min-width: 120px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--md-shape-sm);
  background: var(--md-surface-container);
  color: var(--md-on-surface);
  font-family: inherit;
  font-size: 0.8125rem;
  outline: none;
}

.dash-search-input::placeholder {
  color: var(--md-on-surface-variant);
}

.dash-search-input:focus {
  border-color: var(--md-primary);
}

.dash-btn-sm {
  height: 32px !important;
  padding: 0 12px !important;
  font-size: 0.75rem !important;
}

#log-auto-scroll-btn {
  position: relative;
}

#log-auto-scroll-btn.active {
  color: var(--md-primary);
  background: var(--md-primary-container);
}

.dash-log-viewer {
  background: var(--md-surface-container-low);
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--md-shape-md);
  height: 500px;
  overflow-y: auto;
  font-family: 'Roboto Mono', 'Courier New', monospace;
  font-size: 0.75rem;
  line-height: 1.6;
  padding: 8px 0;
}

.dash-log-entry {
  display: flex;
  padding: 2px 12px;
  gap: 8px;
  transition: background 0.1s;
}

.dash-log-entry:hover {
  background: rgba(240, 240, 245, 0.04);
}

.dash-log-ts {
  color: var(--md-on-surface-variant);
  white-space: nowrap;
  flex-shrink: 0;
}

.dash-log-level {
  font-weight: 700;
  width: 44px;
  flex-shrink: 0;
  text-align: center;
}

.dash-log-level.DEBUG { color: #80CBC4; }
.dash-log-level.INFO { color: var(--sc-green); }
.dash-log-level.WARN { color: var(--sc-gold); }
.dash-log-level.ERROR { color: var(--sc-red); }

.dash-log-msg {
  color: var(--md-on-surface);
  word-break: break-word;
  flex: 1;
  min-width: 0;
}

/* ========== Responsive ========== */
@media (max-width: 600px) {
  .dash-overview-grid {
    grid-template-columns: 1fr;
  }

  .dash-logs-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .dash-logs-toolbar .dash-search-input {
    min-width: unset;
  }

  .dash-log-viewer {
    height: 400px;
  }

  .dash-device-metrics {
    display: none;
  }
}
