/* ============================================================
   vm-manager dashboard — dark terminal aesthetic
   Geist Mono for data, Geist for UI chrome
   Palette: near-black bg, zinc midtones, cyan accent
   ============================================================ */

[hidden] { display: none !important; }

:root {
  --bg:         #0d0d0f;
  --bg-1:       #131316;
  --bg-2:       #1a1a1e;
  --bg-3:       #222228;
  --border:     #2a2a32;
  --border-hi:  #3a3a46;
  --text:       #e2e2e8;
  --text-2:     #9898a6;
  --text-3:     #5a5a6a;
  --accent:     #00d4aa;
  --accent-dim: #00a888;
  --accent-bg:  rgba(0, 212, 170, 0.08);
  --red:        #ff5a6e;
  --red-bg:     rgba(255, 90, 110, 0.1);
  --yellow:     #f5c542;
  --radius:     4px;
  --radius-lg:  8px;
  --mono:       'Geist Mono', 'Fira Code', 'Cascadia Code', monospace;
  --sans:       'Geist', 'Inter', system-ui, sans-serif;
  --topbar-h:   48px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   Login
   ============================================================ */

#login-screen {
  min-height: calc(100vh - 48px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-box {
  width: 100%;
  max-width: 360px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
}

.login-logo {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--text);
  text-align: center;
  margin-bottom: 6px;
}

.login-subtitle {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  text-align: center;
  letter-spacing: 0.08em;
  margin-bottom: 32px;
}

.logo-bracket {
  color: var(--accent);
}

/* ============================================================
   Top bar
   ============================================================ */

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-h);
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 0;
  z-index: 100;
}

.topbar-brand {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: -0.3px;
  padding-right: 24px;
  border-right: 1px solid var(--border);
  white-space: nowrap;
}

.tab-nav {
  display: flex;
  align-items: stretch;
  height: var(--topbar-h);
  flex: 1;
  padding: 0 8px;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-3);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.03em;
  cursor: pointer;
  padding: 0 14px;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

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

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

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.topbar-user {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
}

/* ============================================================
   Main content
   ============================================================ */

#app {
  height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.content {
  margin-top: var(--topbar-h);
  flex: 1;
  padding: 32px 24px;
  max-width: 1100px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

/* Terminal tab gets no padding so the terminal fills */
#tab-terminal.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-title {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 20px;
}

/* ============================================================
   Dashboard stats
   ============================================================ */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  max-width: 600px;
}

.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
}

.stat-value {
  font-family: var(--mono);
  font-size: 36px;
  font-weight: 300;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 8px;
}

.stat-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-3);
  text-transform: uppercase;
}

/* ============================================================
   Tables
   ============================================================ */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 13px;
}

thead {
  background: var(--bg-2);
}

th {
  padding: 10px 14px;
  text-align: left;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 10px 14px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

tbody tr {
  background: var(--bg-1);
  transition: background 0.1s;
}

tbody tr:hover {
  background: var(--bg-2);
}

.empty-row td {
  color: var(--text-3);
  font-style: italic;
  text-align: center;
  padding: 24px;
}

/* Truncate long values */
td.truncate {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Clickable URL */
td a {
  color: var(--accent);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 12px;
}

td a:hover {
  text-decoration: underline;
}

/* ============================================================
   Badges
   ============================================================ */

.badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 3px;
  text-transform: uppercase;
}

.badge-green {
  background: rgba(0, 212, 170, 0.12);
  color: var(--accent);
  border: 1px solid rgba(0, 212, 170, 0.25);
}

.badge-red {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(255, 90, 110, 0.25);
}

.badge-gray {
  background: var(--bg-3);
  color: var(--text-2);
  border: 1px solid var(--border);
}

/* ============================================================
   Forms
   ============================================================ */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--text-2);
  text-transform: lowercase;
}

.optional {
  color: var(--text-3);
  font-size: 10px;
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
  width: 100%;
  transition: border-color 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-dim);
  background: var(--bg-3);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-3);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235a5a6a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}

select option {
  background: var(--bg-2);
  color: var(--text);
}

textarea {
  resize: vertical;
  min-height: 72px;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  padding-top: 28px; /* align with inputs that have labels */
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.form-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.self-end {
  align-self: flex-end;
  margin-bottom: 1px; /* visually align with input baseline */
}

/* ============================================================
   Details / collapsible forms
   ============================================================ */

.form-details {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-1);
}

.form-details summary {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: color 0.15s;
}

.form-details summary::-webkit-details-marker { display: none; }

.form-details summary:hover {
  color: var(--accent);
}

.form-details[open] summary {
  color: var(--accent);
  border-bottom: 1px solid var(--border);
}

.inline-form {
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  border: none;
  border-radius: var(--radius);
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #0d0d0f;
  font-weight: 600;
}

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

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

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--border-hi);
}

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid rgba(255, 90, 110, 0.3);
  font-size: 11px;
  padding: 4px 10px;
}

.btn-danger:hover:not(:disabled) {
  background: var(--red-bg);
}

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

.btn-full {
  width: 100%;
  justify-content: center;
}

/* ============================================================
   Error messages
   ============================================================ */

.error-msg {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--red);
  background: var(--red-bg);
  border: 1px solid rgba(255, 90, 110, 0.2);
  border-radius: var(--radius);
  padding: 8px 12px;
}

.success-msg {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  background: rgba(0, 212, 170, 0.08);
  border: 1px solid rgba(0, 212, 170, 0.2);
  border-radius: var(--radius);
  padding: 8px 12px;
}

/* ============================================================
   Terminal
   ============================================================ */

.terminal-controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: 16px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.term-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.term-field label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--text-2);
}

.term-field input,
.term-field select {
  width: auto;
  min-width: 140px;
}

.terminal-container {
  flex: 1;
  background: #0a0a0c;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  padding: 8px;
  min-height: 400px;
}

/* xterm overrides — blend into our dark theme */
.xterm {
  height: 100%;
}

.xterm .xterm-viewport {
  background: transparent !important;
}

.xterm-screen {
  background: transparent !important;
}

/* ============================================================
   Scrollbar
   ============================================================ */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border-hi);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-3);
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 640px) {
  .content {
    padding: 20px 14px;
  }

  .topbar-brand {
    display: none;
  }

  .tab-btn {
    padding: 0 10px;
    font-size: 11px;
  }

  .form-row {
    flex-direction: column;
  }

  .self-end {
    align-self: stretch;
    margin-bottom: 0;
  }

  .btn-full-mobile {
    width: 100%;
    justify-content: center;
  }

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