/* ==========================================================================
   Design tokens
   Subject: personal infra command-center for a self-hosting sysadmin.
   Signature: the status dot — one visual language for "is it alive" that
   repeats everywhere (dashboard, server list, server detail).
   ========================================================================== */
:root {
  --bg:            #0b0e14;
  --surface:       #12151f;
  --surface-2:     #171b27;
  --surface-hover: #1b2030;
  --border:        #212635;
  --border-strong: #2b3145;

  --text:          #e7e9f2;
  --text-muted:    #838ba8;
  --text-faint:    #545c78;

  --accent:        #ff6b35;
  --accent-hover:  #ff7f4f;
  --accent-dim:    rgba(255, 107, 53, .14);
  --accent-fg:     #1a0d06;

  --success:       #2dd4a7;
  --success-dim:   rgba(45, 212, 167, .14);
  --warning:       #f5b942;
  --warning-dim:   rgba(245, 185, 66, .14);
  --danger:        #ff5470;
  --danger-dim:    rgba(255, 84, 112, .14);
  --neutral-dim:   rgba(131, 139, 168, .14);

  --font-display: 'Space Grotesk', 'Segoe UI', sans-serif;
  --font-body:    'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  --radius-sm: 7px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --sidebar-w: 236px;
}

* { box-sizing: border-box; }

html, body {
  background: var(--bg);
}

body {
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14.5px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6, .display-font {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

code, .mono { font-family: var(--font-mono); }

::selection { background: var(--accent-dim); color: var(--text); }

/* Faint ambient grid, restrained — only on auth screens */
.auth-bg {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 900px 500px at 50% -10%, rgba(255,107,53,.10), transparent 60%),
    linear-gradient(var(--border) 1px, transparent 1px) 0 0 / 42px 42px,
    linear-gradient(90deg, var(--border) 1px, transparent 1px) 0 0 / 42px 42px,
    var(--bg);
  background-blend-mode: normal, overlay, overlay, normal;
  position: relative;
}
.auth-bg::before {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 40%, transparent 0%, var(--bg) 78%);
  pointer-events: none;
}

/* ==========================================================================
   App shell: fixed sidebar + main column
   ========================================================================== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 40;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1.3rem 1.25rem 1.1rem;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #ff8e5c);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-fg);
  font-size: 1rem;
  flex-shrink: 0;
}
.brand-text {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  line-height: 1.15;
}
.brand-text small {
  display: block;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: .68rem;
  color: var(--text-faint);
  letter-spacing: .04em;
  text-transform: uppercase;
}

.sidebar-nav {
  padding: .9rem .7rem;
  display: flex;
  flex-direction: column;
  gap: .15rem;
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .55rem .75rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: .875rem;
  font-weight: 500;
  border-left: 2px solid transparent;
  transition: background .12s ease, color .12s ease;
}
.nav-item i { font-size: 1.05rem; width: 18px; text-align: center; }
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-left-color: var(--accent);
}

.sidebar-footer {
  padding: .9rem .7rem 1.1rem;
  border-top: 1px solid var(--border);
}
.sidebar-user {
  display: flex; align-items: center; gap: .6rem;
  padding: .4rem .75rem .7rem;
  font-size: .8rem;
  color: var(--text-faint);
}
.sidebar-user .dot { position: static; margin: 0; }

.main-area {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  padding: 1.4rem 2rem 0;
}
.topbar .page-title {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0;
}
.topbar .page-sub {
  color: var(--text-muted);
  font-size: .85rem;
  margin-top: .15rem;
}

.content { padding: 1.25rem 2rem 2.5rem; }

/* ==========================================================================
   Cards / panels
   ========================================================================== */
.card, .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text);
}

.panel-header {
  padding: 1rem 1.35rem;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: .95rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
}
.panel-header .bi { color: var(--accent); margin-right: .35rem; }

/* Stat tiles */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.15rem 1.25rem;
  display: flex;
  align-items: center;
  gap: .9rem;
}
.stat-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
  background: var(--accent-dim);
  color: var(--accent);
}
.stat-icon.warn { background: var(--warning-dim); color: var(--warning); }
.stat-icon.danger { background: var(--danger-dim); color: var(--danger); }
.stat-icon.ok { background: var(--success-dim); color: var(--success); }
.stat-number {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1.1;
}
.stat-label {
  color: var(--text-muted);
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-top: .1rem;
}

/* ==========================================================================
   Status dot — the signature element. Solid = static, ring = live/positive.
   ========================================================================== */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .28rem .65rem .28rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
}
.status-pill .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
}
.status-up { background: var(--success-dim); color: var(--success); }
.status-up .dot { background: var(--success); }
.status-up .dot::after {
  content: "";
  position: absolute; inset: -4px;
  border-radius: 50%;
  border: 1px solid var(--success);
  opacity: .6;
  animation: pulse-ring 2s ease-out infinite;
}
.status-down { background: var(--danger-dim); color: var(--danger); }
.status-down .dot { background: var(--danger); }
.status-unknown { background: var(--neutral-dim); color: var(--text-muted); }
.status-unknown .dot { background: var(--text-faint); }

@keyframes pulse-ring {
  0%   { transform: scale(.6); opacity: .7; }
  100% { transform: scale(1.5); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .status-up .dot::after { animation: none; }
}

/* Expiry badges reuse the pill shape without the dot */
.badge-soft {
  display: inline-block;
  padding: .28rem .65rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-soft.ok { background: var(--success-dim); color: var(--success); }
.badge-soft.warn { background: var(--warning-dim); color: var(--warning); }
.badge-soft.danger { background: var(--danger-dim); color: var(--danger); }
.badge-soft.neutral { background: var(--neutral-dim); color: var(--text-muted); }

/* ==========================================================================
   Tables
   ========================================================================== */
.table {
  color: var(--text);
  --bs-table-bg: transparent;
  --bs-table-hover-bg: var(--surface-hover);
  margin-bottom: 0;
  font-size: .875rem;
}
.table > :not(caption) > * > * {
  border-bottom-color: var(--border);
  padding: .85rem 1.35rem;
  vertical-align: middle;
}
.table > thead > tr > * {
  background: var(--surface-2);
  color: var(--text-faint);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.table-hostname { font-family: var(--font-mono); font-size: .82rem; color: var(--text-muted); }

/* ==========================================================================
   Forms
   ========================================================================== */
label.form-label {
  color: var(--text-muted);
  font-size: .78rem;
  font-weight: 500;
  margin-bottom: .35rem;
}
.form-control, .form-select {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: .5rem .75rem;
  font-size: .875rem;
}
.form-control:focus, .form-select:focus {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.form-control::placeholder { color: var(--text-faint); }
.form-control:disabled, .form-control[readonly] { background: var(--surface); opacity: .65; }
textarea.form-control { font-family: var(--font-mono); font-size: .82rem; }

.form-check-input {
  background-color: var(--surface-2);
  border-color: var(--border-strong);
}
.form-check-input:checked {
  background-color: var(--accent);
  border-color: var(--accent);
}
.form-check-input:focus {
  box-shadow: 0 0 0 3px var(--accent-dim);
  border-color: var(--accent);
}

/* Credential reveal */
.credential-value {
  filter: blur(5px);
  transition: filter .15s ease;
  user-select: none;
}
.credential-value.revealed { filter: none; user-select: text; }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn { font-size: .85rem; font-weight: 600; border-radius: var(--radius-sm); }
.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}
.btn-accent:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-fg);
}
.btn-outline-light {
  border-color: var(--border-strong);
  color: var(--text-muted);
}
.btn-outline-light:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-outline-danger { border-color: var(--danger); color: var(--danger); }
.btn-outline-danger:hover { background: var(--danger); border-color: var(--danger); color: #1a0000; }
.btn-danger { background: var(--danger); border-color: var(--danger); }

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-content {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
}
.modal-header, .modal-footer { border-color: var(--border); }
.modal-title { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; }
.btn-close { filter: invert(1) grayscale(100%) brightness(200%); opacity: .6; }
.btn-close:hover { opacity: 1; }

/* ==========================================================================
   Alerts
   ========================================================================== */
.alert { border-radius: var(--radius-md); border: 1px solid transparent; font-size: .875rem; }
.alert-success { background: var(--success-dim); color: var(--success); border-color: rgba(45,212,167,.3); }
.alert-danger  { background: var(--danger-dim);  color: var(--danger);  border-color: rgba(255,84,112,.3); }
.alert-warning { background: var(--warning-dim); color: var(--warning); border-color: rgba(245,185,66,.3); }
.alert-info    { background: var(--neutral-dim); color: var(--text-muted); }

/* ==========================================================================
   Auth pages (login / install)
   ========================================================================== */
.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 2.1rem;
  position: relative;
  z-index: 1;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.auth-card.wide { max-width: 480px; }
.auth-logo {
  display: flex; align-items: center; gap: .65rem;
  margin-bottom: .3rem;
}
.text-muted-dash { color: var(--text-muted) !important; }
.text-faint { color: var(--text-faint) !important; }
.text-accent { color: var(--accent) !important; }

/* Misc */
.breadcrumb { font-size: .8rem; }
.breadcrumb-item.active { color: var(--text-muted); }
hr { border-color: var(--border); opacity: 1; }
.list-group-item {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
  padding: .75rem 1.35rem;
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .content { padding: 1rem 1.1rem 2rem; }
  .topbar { padding: 1.1rem 1.1rem 0; }
}
