/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #3b82f6;
  --primary-dark: #2563eb;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  --info-color: #06b6d4;
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-dark: #1e293b;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --border-color: #e2e8f0;
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

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

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

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--bg-dark);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-header {
  padding: 2rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h1 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.sidebar-header .subtitle {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.6);
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 0.875rem 1.5rem;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  transition: all 0.2s;
  cursor: pointer;
}

.nav-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: white;
}

.nav-item.active {
  background-color: var(--primary-color);
  color: white;
  border-left: 4px solid var(--primary-dark);
}

.nav-item .icon {
  font-size: 1.25rem;
  margin-right: 0.75rem;
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: 260px;
  display: flex;
  flex-direction: column;
}

.header {
  background-color: var(--bg-secondary);
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow);
}

.header h2 {
  font-size: 1.75rem;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background-color: var(--bg-primary);
  border-radius: 6px;
}

.status-indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--success-color);
  animation: pulse 2s infinite;
}

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

.status-indicator.disconnected .dot {
  background-color: var(--danger-color);
}

.content {
  flex: 1;
  padding: 2rem;
}

/* Buttons */
.btn {
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background-color: var(--primary-dark);
}

.btn-secondary {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--border-color);
}

.btn-refresh {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-refresh:hover {
  background-color: var(--bg-primary);
}

.btn-warning {
  background-color: var(--warning-color);
  color: white;
}

.btn-warning:hover {
  opacity: 0.9;
}

.btn-danger {
  background-color: var(--danger-color);
  color: white;
}

.btn-danger:hover {
  opacity: 0.9;
}

/* Pages */
.page {
  display: none;
}

.page.active {
  display: block;
  animation: fadeIn 0.3s;
}

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

/* Stats Grid */
.stats-section, .health-section, .activity-section, .alerts-section, .tools-section {
  margin-bottom: 2rem;
}

.stats-section h3, .health-section h3, .activity-section h3, .alerts-section h3, .tools-section h3 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

.stat-card {
  background-color: var(--bg-secondary);
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary-color);
}

.stat-card h4 {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  font-weight: 600;
}

.stat-card .value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.stat-card .subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.stat-card.success {
  border-left-color: var(--success-color);
}

.stat-card.warning {
  border-left-color: var(--warning-color);
}

.stat-card.danger {
  border-left-color: var(--danger-color);
}

.stat-card.info {
  border-left-color: var(--info-color);
}

/* Health Grid */
.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.health-item {
  background-color: var(--bg-secondary);
  padding: 1rem;
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.health-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.health-icon.healthy {
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--success-color);
}

.health-icon.degraded {
  background-color: rgba(245, 158, 11, 0.1);
  color: var(--warning-color);
}

.health-icon.unhealthy {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--danger-color);
}

.health-info h5 {
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
}

.health-info p {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Alerts */
.alerts-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.alert {
  padding: 1rem 1.5rem;
  border-radius: 8px;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  box-shadow: var(--shadow);
}

.alert.critical {
  background-color: rgba(239, 68, 68, 0.1);
  border-left: 4px solid var(--danger-color);
  color: var(--danger-color);
}

.alert.warning {
  background-color: rgba(245, 158, 11, 0.1);
  border-left: 4px solid var(--warning-color);
  color: #92400e;
}

.alert.info {
  background-color: rgba(6, 182, 212, 0.1);
  border-left: 4px solid var(--info-color);
  color: #164e63;
}

.alert-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.alert-content h4 {
  margin-bottom: 0.25rem;
  font-weight: 600;
}

.alert-content p {
  font-size: 0.875rem;
}

/* Activity List */
.activity-list {
  background-color: var(--bg-secondary);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-height: 400px;
  overflow-y: auto;
}

.activity-item {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-info {
  flex: 1;
}

.activity-info .type {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.activity-info .details {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.activity-time {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Data Table */
.data-table-container {
  background-color: var(--bg-secondary);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead {
  background-color: var(--bg-primary);
}

.data-table th {
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.data-table td {
  padding: 1rem;
  border-top: 1px solid var(--border-color);
}

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

.badge {
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-block;
}

.badge.success {
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--success-color);
}

.badge.warning {
  background-color: rgba(245, 158, 11, 0.1);
  color: var(--warning-color);
}

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

.badge.info {
  background-color: rgba(6, 182, 212, 0.1);
  color: var(--info-color);
}

/* Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.search-bar input {
  padding: 0.625rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.875rem;
  min-width: 300px;
}

.filter-group {
  display: flex;
  gap: 0.5rem;
}

.filter-group select {
  padding: 0.625rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.875rem;
  background-color: var(--bg-secondary);
}

.actions {
  display: flex;
  gap: 0.5rem;
}

/* Logs Container */
.logs-container {
  background-color: var(--bg-dark);
  color: #e2e8f0;
  border-radius: 8px;
  padding: 1rem;
  max-height: 600px;
  overflow-y: auto;
  font-family: 'Courier New', monospace;
  font-size: 0.875rem;
}

.log-entry {
  padding: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  gap: 1rem;
}

.log-entry:last-child {
  border-bottom: none;
}

.log-timestamp {
  color: #64748b;
  flex-shrink: 0;
}

.log-level {
  font-weight: 600;
  flex-shrink: 0;
  width: 60px;
}

.log-level.error {
  color: var(--danger-color);
}

.log-level.warn {
  color: var(--warning-color);
}

.log-level.info {
  color: var(--info-color);
}

.log-message {
  flex: 1;
}

/* Tool Cards */
.tool-card {
  background-color: var(--bg-secondary);
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.tool-card h4 {
  margin-bottom: 0.5rem;
}

.tool-card p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.tool-card .btn {
  margin-right: 0.5rem;
}

.result-container {
  margin-top: 1rem;
  padding: 1rem;
  background-color: var(--bg-primary);
  border-radius: 6px;
  display: none;
}

.result-container.show {
  display: block;
}

.diagnostic-item {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.diagnostic-item:last-child {
  border-bottom: none;
}

.diagnostic-status {
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.diagnostic-status.pass {
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--success-color);
}

.diagnostic-status.warning {
  background-color: rgba(245, 158, 11, 0.1);
  color: var(--warning-color);
}

.diagnostic-status.fail {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--danger-color);
}

/* Info Grid */
.info-grid {
  background-color: var(--bg-secondary);
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.info-item {
  padding: 0.75rem;
}

.info-item .label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.info-item .value {
  font-weight: 600;
  font-size: 1rem;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.show {
  display: flex;
}

.modal-content {
  background-color: var(--bg-secondary);
  padding: 2rem;
  border-radius: 8px;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
}

.modal-content h3 {
  margin-bottom: 1rem;
}

.modal-content p {
  margin-bottom: 1.5rem;
  color: var(--text-secondary);
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* Loading State */
.loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
}

.loading-card {
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Responsive Design */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    position: relative;
    height: auto;
  }

  .main-content {
    margin-left: 0;
  }

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

  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .search-bar input {
    min-width: 100%;
  }
}
