/* ─────────────────────────────────────────────
   Warmup Hub — styles.css
   Dark theme matching Ops Hub aesthetic
   ───────────────────────────────────────────── */

:root {
  --bg-body: #0a0a0f;
  --bg-surface: #111118;
  --bg-input: #0d0d14;
  --border: #1e1e2e;
  --border-focus: #2a2a3e;
  --text-primary: #e0e0e0;
  --text-secondary: #888;
  --accent: #6366f1;
  --accent-hover: #5558e6;
  --green: #10b981;
  --yellow: #f59e0b;
  --red: #ef4444;
  --gray: #6b7280;
  --sidebar-w: 220px;
}

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

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

#app { display: flex; min-height: 100vh; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-body); }
::-webkit-scrollbar-thumb { background: #2a2a3e; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a4e; }

/* ── Sidebar ── */
#sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 20px 16px 12px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand span { color: var(--accent); }

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

.sidebar-link {
  display: block;
  padding: 10px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.sidebar-link:hover {
  background: #1a1a2e;
  color: var(--text-primary);
}

.sidebar-link.active {
  border-left-color: var(--accent);
  background: #1a1a2e;
  color: #fff;
  font-weight: 500;
}

.sidebar-link .link-icon {
  display: inline-block;
  width: 22px;
  text-align: center;
  margin-right: 8px;
}

/* ── Main Content ── */
#content {
  margin-left: var(--sidebar-w);
  padding: 24px;
  flex: 1;
  min-width: 0;
}

/* ── Panel Header ── */
.panel-header {
  margin-bottom: 24px;
}

.panel-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.panel-header .subtitle {
  color: var(--text-secondary);
  font-size: 13px;
}

.panel-header .toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.spacer { flex: 1; }

/* ── KPI Cards ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
}

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

.kpi-value {
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.kpi-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ── Tables ── */
.table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 24px;
}

.table-title {
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  border-bottom: 1px solid var(--border);
}

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

thead th {
  background: var(--bg-input);
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

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

tbody tr:hover { background: rgba(99, 102, 241, 0.04); }

.text-right { text-align: right; }
.text-center { text-align: center; }

.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-warming { background: rgba(245, 158, 11, 0.15); color: var(--yellow); }
.badge-warm    { background: rgba(16, 185, 129, 0.15); color: var(--green); }
.badge-paused  { background: rgba(107, 114, 128, 0.15); color: var(--gray); }
.badge-error   { background: rgba(239, 68, 68, 0.15); color: var(--red); }
.badge-online  { background: rgba(16, 185, 129, 0.15); color: var(--green); }
.badge-offline { background: rgba(107, 114, 128, 0.15); color: var(--gray); }
.badge-active  { background: rgba(16, 185, 129, 0.15); color: var(--green); }
.badge-available { background: rgba(99, 102, 241, 0.15); color: var(--accent); }
.badge-assigned  { background: rgba(245, 158, 11, 0.15); color: var(--yellow); }
.badge-inactive  { background: rgba(107, 114, 128, 0.15); color: var(--gray); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

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

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

.btn-secondary:hover {
  background: #1a1a2e;
  color: var(--text-primary);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
}

.btn-danger:hover { background: rgba(239, 68, 68, 0.25); }

.btn-sm { padding: 5px 12px; font-size: 12px; }

.btn-icon {
  padding: 6px 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.btn-icon:hover { background: #1a1a2e; color: var(--text-primary); }

/* ── Progress Bar ── */
.progress-wrap {
  background: var(--border);
  border-radius: 4px;
  height: 6px;
  width: 100%;
  min-width: 60px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}

.progress-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── Charts container (placeholder) ── */
.chart-container {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 24px;
}

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

.vm-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

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

.vm-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.vm-status-dot.online { background: var(--green); box-shadow: 0 0 6px rgba(16, 185, 129, 0.4); }
.vm-status-dot.offline { background: var(--gray); }

.vm-card-host {
  font-weight: 600;
  color: #fff;
  font-size: 14px;
}

.vm-card-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 3px 0;
  color: var(--text-secondary);
}

.vm-card-row span:last-child { color: var(--text-primary); }

/* ── Modal ── */
#modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

#modal-overlay.visible { display: flex; }

#modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

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

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.modal-close:hover { color: var(--text-primary); }

.modal-body { padding: 20px; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ── Forms ── */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-focus);
  border-radius: 6px;
  color: #fff;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.form-control:focus { border-color: var(--accent); }

select.form-control { cursor: pointer; }
select.form-control option { background: var(--bg-input); }

textarea.form-control { resize: vertical; min-height: 80px; }

/* ── Tabs ── */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab-btn {
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.tab-btn:hover { color: var(--text-primary); }

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Toast ── */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 10px 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-primary);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  transition: opacity 0.3s;
}

.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--red); }

/* ── Spinner ── */
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Settings Section ── */
.settings-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.settings-section h3 {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 16px;
}

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

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

/* ── Toggle switch ── */
.toggle {
  position: relative;
  width: 40px;
  height: 22px;
  cursor: pointer;
}

.toggle input { display: none; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--gray);
  border-radius: 22px;
  transition: 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  left: 3px;
  top: 3px;
  transition: 0.2s;
}

.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ── Responsive ── */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s;
  }
  #sidebar.open { transform: translateX(0); }
  #content { margin-left: 0; padding: 16px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .vm-grid { grid-template-columns: 1fr; }
}
