/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-primary: #0f1419;
  --bg-secondary: #1a1f2e;
  --bg-card: #232a3b;
  --bg-hover: #2a3349;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-color: #334155;
  --accent-blue: #3b82f6;
  --accent-green: #22c55e;
  --accent-red: #ef4444;
  --accent-orange: #f59e0b;
  --accent-purple: #8b5cf6;
  --accent-cyan: #06b6d4;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --transition: 150ms ease;
}

.btn-danger {
  background: var(--accent-red);
  color: #fff;
  border: none;
}

.btn-danger:hover {
  background: #dc2626;
}

.modal-message {
  margin: 1rem 0 1.5rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
}

/* ===== Header ===== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  z-index: 100;
}

.app-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent-cyan);
  letter-spacing: -0.5px;
}

.header-left, .header-center, .header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-blue);
  color: #fff;
}
.btn-primary:hover {
  background: #2563eb;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-color);
}
.btn-secondary:hover {
  background: var(--bg-hover);
}

.btn-small {
  padding: 4px 10px;
  font-size: 12px;
  background: var(--bg-card);
  color: var(--text-secondary);
  border-color: var(--border-color);
}
.btn-small:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== Select ===== */
.select-control {
  padding: 6px 10px;
  font-size: 13px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* ===== Status badge ===== */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 12px;
  white-space: nowrap;
}

.status-running { background: rgba(34, 197, 94, 0.15); color: var(--accent-green); }
.status-exited { background: rgba(107, 114, 128, 0.15); color: #6b7280; }
.status-error { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); }
.status-restarting { background: rgba(245, 158, 11, 0.15); color: var(--accent-orange); }
.status-paused { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
.status-created { background: rgba(209, 213, 219, 0.1); color: #d1d5db; }
.status-unknown { background: rgba(100, 116, 139, 0.15); color: var(--text-muted); }

/* ===== Main Layout ===== */
.app-main {
  display: flex;
  flex-direction: row;
  height: calc(100vh - 56px);
  overflow: hidden;
}

.left-column {
  display: flex;
  flex-direction: column;
  width: 50%;
  min-width: 400px;
  max-width: 700px;
  overflow: hidden;
}

.right-column {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ===== Panels ===== */
.panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.panel-header h2 {
  font-size: 15px;
  font-weight: 600;
}

.panel-dashboard {
  margin: 12px;
  flex-shrink: 0;
}

.panel-graph {
  flex: 1;
  margin: 12px 12px 12px 0;
  display: flex;
  flex-direction: column;
}

.panel-detail {
  width: 400px;
  margin: 12px 12px 12px 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* ===== Notification ===== */
.notification {
  position: fixed;
  top: 64px;
  right: 20px;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 1000;
  box-shadow: var(--shadow);
  transition: opacity var(--transition), transform var(--transition);
}
.notification.hidden {
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
}
.notification.success { background: var(--accent-green); color: #fff; }
.notification.error { background: var(--accent-red); color: #fff; }
.notification.info { background: var(--accent-blue); color: #fff; }

/* ===== Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal.hidden { display: none; }

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.modal-content {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 480px;
  z-index: 1;
}

.modal-content h3 {
  margin-bottom: 20px;
  font-size: 16px;
}

/* ===== Forms ===== */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.form-group input {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent-blue);
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

/* ===== Loading ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 25, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 300;
}
.loading-overlay.hidden { display: none; }

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-text {
  margin-top: 16px;
  color: var(--text-secondary);
  font-size: 14px;
}

.collect-log {
  margin-top: 20px;
  width: 420px;
  max-height: 160px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 12px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.collect-log:empty {
  display: none;
}

.collect-log-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.collect-log-line .log-time {
  color: var(--accent-cyan);
  margin-right: 6px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Detail Panel ===== */
.detail-content {
  overflow-y: auto;
  flex: 1;
}

.detail-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  padding: 0 12px;
}

.tab-btn {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 500;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
}

.detail-tab-content {
  padding: 12px 16px;
}

.detail-section {
  margin-bottom: 16px;
}

.detail-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(51, 65, 85, 0.3);
}

.detail-subsection {
  margin-bottom: 10px;
  padding-left: 8px;
  border-left: 2px solid var(--border-color);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 3px 0;
  gap: 8px;
}

.detail-key {
  color: var(--text-muted);
  font-size: 12px;
  flex-shrink: 0;
  min-width: 80px;
}

.detail-val {
  color: var(--text-secondary);
  font-size: 13px;
  text-align: right;
  word-break: break-all;
}

/* ===== Utilities ===== */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); font-size: 12px; }
.text-small { font-size: 12px; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
