/* Kundenportal – an Shell-Layout der Serververwaltung angelehnt */

body:has(.portal-layout) {
  background: var(--shell-bg);
}

.portal-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.portal-topbar {
  height: var(--topbar-height);
  min-height: var(--topbar-height);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--shell-bg);
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.portal-topbar-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.portal-brand {
  font-weight: 650;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  color: var(--text);
}

.portal-brand-sub {
  display: block;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--muted);
  margin-top: 0.05rem;
}

.portal-user-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  max-width: min(42vw, 320px);
}

.portal-user-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.portal-user-text {
  min-width: 0;
  line-height: 1.25;
}

.portal-user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-user-id {
  font-size: 0.7rem;
  color: var(--muted);
  font-family: ui-monospace, monospace;
}

.portal-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--shell-bg);
  position: relative;
}

.portal-shell::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: var(--shell-radius);
  height: var(--shell-radius);
  background: var(--shell-bg);
  border-bottom-right-radius: var(--shell-radius);
  pointer-events: none;
  z-index: 0;
}

.portal-main {
  position: relative;
  z-index: 1;
  flex: 1;
  background: var(--bg);
  border-top-left-radius: var(--shell-radius);
  padding: 1.35rem clamp(1rem, 3vw, 2.5rem) 2.5rem;
  width: 100%;
  margin: 0;
  box-sizing: border-box;
}

.portal-content {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
}

.portal-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.portal-page-header {
  margin-bottom: 1.25rem;
}

.portal-page-header h2 {
  font-size: 1.4rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin-bottom: 0.2rem;
}

.portal-page-header .meta {
  margin-bottom: 0;
  max-width: 42rem;
}

.portal-widgets {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  margin-bottom: 1.35rem;
}

.portal-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}

.portal-widget-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.portal-widget strong {
  font-size: 1.45rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.portal-widget.online strong { color: var(--online); }
.portal-widget.offline strong { color: var(--offline); }

.portal-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
  width: 100%;
}

.portal-server-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  padding: 1.1rem 1.2rem 1.15rem;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
}

.portal-server-card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22);
}

.portal-server-card.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(66, 143, 220, 0.35);
}

@media (min-width: 880px) {
  .portal-server-card {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(340px, 1.35fr);
    column-gap: 1.5rem;
    align-items: center;
  }

  .portal-server-top {
    min-width: 0;
  }

  .portal-metrics {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
  }
}

.portal-server-top {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.portal-server-icon {
  width: 2.65rem;
  height: 2.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  flex-shrink: 0;
  position: relative;
}

.portal-server-icon .tabler-icon {
  width: 1.25rem !important;
  height: 1.25rem !important;
}

.portal-server-icon-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  background: var(--offline);
  box-sizing: border-box;
}

.portal-server-icon-dot.online { background: var(--online); }
.portal-server-icon-dot.connecting,
.portal-server-icon-dot.unknown { background: var(--warning); }

.portal-server-title-wrap {
  flex: 1;
  min-width: 0;
}

.portal-server-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.portal-server-head h3 {
  font-size: 1.02rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-server-meta {
  margin-top: 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
}

.portal-type-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
}

.portal-type-chip.vm {
  border-color: rgba(58, 150, 221, 0.35);
  color: #6ec4ff;
  background: rgba(58, 150, 221, 0.1);
}

.portal-type-chip.physical {
  border-color: rgba(19, 161, 14, 0.3);
  color: #7dff7d;
  background: rgba(19, 161, 14, 0.1);
}

.portal-status-text {
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
  color: var(--muted);
}

.portal-status-text.online { color: var(--online); }
.portal-status-text.offline { color: var(--offline); }
.portal-status-text.connecting,
.portal-status-text.unknown { color: var(--warning); }

.portal-server-specs {
  margin-top: 0.4rem;
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.portal-server-ip {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.76rem;
}

.portal-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 1rem;
  padding-top: 0.95rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.portal-metric-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.portal-metric-head span {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.portal-metric-head strong {
  font-size: 0.78rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  line-height: 1.25;
}

.portal-metric-bar {
  height: 5px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.portal-metric-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #5cb8ff);
  max-width: 100%;
  transition: width 0.25s ease;
}

.portal-metric-bar.warn span {
  background: linear-gradient(90deg, var(--warning), #e3b341);
}

.portal-metric-bar.crit span {
  background: linear-gradient(90deg, var(--offline), #ff7b72);
}

.portal-metric-plain strong {
  font-size: 0.88rem;
}

.portal-detail-panel {
  margin-top: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  padding: 1.15rem 1.25rem 1.25rem;
  animation: portalFadeIn 0.2s ease;
}

@keyframes portalFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.portal-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.portal-detail-head h3 {
  font-size: 1.15rem;
  font-weight: 650;
}

.portal-hw-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.5rem;
  margin: 0.85rem 0 0.25rem;
}

.portal-hw-item {
  background: var(--surface-2);
  border-radius: 6px;
  padding: 0.55rem 0.65rem;
  font-size: 0.8125rem;
}

.portal-hw-item span {
  display: block;
  font-size: 0.68rem;
  color: var(--muted);
  margin-bottom: 0.15rem;
}

/* Login-Seite */
body.portal-login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--shell-bg);
  padding: 1rem;
}

.portal-login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  padding: 2rem;
  width: min(420px, 100%);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.portal-login-box h1 {
  font-size: 1.45rem;
  font-weight: 650;
  margin-bottom: 0.15rem;
}

.portal-login-box .portal-brand-sub {
  margin-bottom: 1.25rem;
}

.portal-login-box button[type="submit"] {
  width: 100%;
  margin-top: 0.35rem;
}

.portal-login-box .error-msg {
  background: rgba(248, 81, 73, 0.12);
  color: var(--offline);
  padding: 0.65rem;
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  display: none;
}

.portal-login-links {
  margin-top: 1.25rem;
  font-size: 0.8125rem;
  text-align: center;
  color: var(--muted);
}

.portal-login-links a {
  color: var(--accent);
}

@media (max-width: 720px) {
  .portal-widgets {
    grid-template-columns: 1fr;
  }

  .portal-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .portal-user-id {
    display: none;
  }

  .portal-main {
    border-top-left-radius: 0;
    padding-top: 1rem;
  }

  .portal-shell::before {
    display: none;
  }
}

.portal-ssh-body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #0d1117;
}

.portal-ssh-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  background: var(--shell-bg, #161b22);
  border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  gap: 1rem;
}

.portal-ssh-terminal {
  flex: 1;
  min-height: 0;
  padding: 0.35rem;
}

.portal-ssh-terminal .xterm {
  height: 100%;
}

.portal-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.portal-processes {
  margin-top: 1.25rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.portal-processes-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.portal-restart-units {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.portal-process-table-wrap {
  overflow-x: auto;
  max-height: 280px;
  overflow-y: auto;
}

.portal-process-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.portal-process-table th,
.portal-process-table td {
  text-align: left;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.portal-process-table th {
  color: var(--muted);
  font-weight: 500;
  position: sticky;
  top: 0;
  background: var(--card-bg, var(--bg));
}
