/*
 * NitroCloud portal CONTENT helpers — shared by admin / gaming / security.
 *
 * The page chrome (sidebar, mobile header, bottom nav, topbar) is NOT defined here any more:
 * it is the NitroApp shell mounted by shared/app-shell.js and styled by NitroApp styles.css
 * (assets/nitro-app.css). The old `.nx-topbar / .nx-brand / .nx-portal-link / .nx-user` top bar
 * was removed — do not use it in portal HTML.
 *
 * What stays: tokens + small content primitives (tables, badges, dialogs, notices, metrics …)
 * used inside the shell's content slot. All classes are prefixed `nx-` so this file can sit next
 * to NitroApp styles.css without colliding with .btn-primary etc.
 */

:root {
  --nx-bg: #07080c;
  --nx-panel: #0d1017;
  --nx-raised: #12171f;
  --nx-line: #1e2633;
  --nx-line-soft: #161c27;
  --nx-text: #e8edf5;
  --nx-muted: #8b95a8;
  --nx-cyan: #22d3ee;
  --nx-cyan-dim: #0891b2;
  --nx-ok: #34d399;
  --nx-warn: #fbbf24;
  --nx-err: #fb7185;
  --nx-radius: 8px;
  --nx-font: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --nx-display: 'Syne', 'DM Sans', system-ui, sans-serif;
  --nx-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
}

[hidden] {
  display: none !important;
}

.nx-body {
  margin: 0;
  min-height: 100vh;
  background: var(--nx-bg);
  color: var(--nx-text);
  font-family: var(--nx-font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.nx-body *,
.nx-body *::before,
.nx-body *::after {
  box-sizing: border-box;
}

.nx-body a,
.nx-content a:not(.nx-btn):not(.nav-btn):not(.btn-primary):not(.btn-sm):not(.btn-ghost) {
  color: var(--nx-cyan);
  text-decoration: none;
}
.nx-body a:hover,
.nx-content a:not(.nx-btn):not(.nav-btn):not(.btn-primary):not(.btn-sm):not(.btn-ghost):hover {
  text-decoration: underline;
}
.nx-content .nx-btn,
.nx-content .nx-btn:hover {
  text-decoration: none;
}

.nx-mono {
  font-family: var(--nx-mono);
}
.nx-muted {
  color: var(--nx-muted);
}

/* ——— Buttons ——— */
.nx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.95rem;
  border-radius: 6px;
  border: 1px solid var(--nx-line);
  background: var(--nx-raised);
  color: var(--nx-text);
  font: 500 0.85rem/1.2 var(--nx-font);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.nx-btn:hover:not(:disabled) {
  border-color: var(--nx-cyan-dim);
}
.nx-btn:focus-visible {
  outline: 2px solid var(--nx-cyan);
  outline-offset: 2px;
}
.nx-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.nx-btn-primary {
  background: var(--nx-cyan);
  border-color: var(--nx-cyan);
  color: #04141a;
  font-weight: 600;
}
.nx-btn-primary:hover:not(:disabled) {
  background: #5ee6fa;
  border-color: #5ee6fa;
}
.nx-btn-ghost {
  background: transparent;
}
.nx-btn-danger {
  color: var(--nx-err);
  border-color: rgba(251, 113, 133, 0.35);
  background: transparent;
}
.nx-btn-danger:hover:not(:disabled) {
  border-color: var(--nx-err);
}
.nx-btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.78rem;
}

/* ——— Forms ——— */
.nx-label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--nx-muted);
}
.nx-input,
.nx-select,
.nx-textarea {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--nx-line);
  background: var(--nx-panel);
  color: var(--nx-text);
  font: 400 0.9rem var(--nx-font);
}
.nx-input:focus,
.nx-select:focus,
.nx-textarea:focus {
  outline: none;
  border-color: var(--nx-cyan);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12);
}
.nx-help {
  margin: 0.3rem 0 0;
  font-size: 0.75rem;
  color: var(--nx-muted);
}
.nx-form-row {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

/* ——— Page structure ——— */
.nx-page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}
.nx-section {
  padding: 1.5rem 0;
  border-top: 1px solid var(--nx-line);
}
.nx-section:first-child {
  border-top: 0;
  padding-top: 0;
}
.nx-h1 {
  margin: 0;
  font: 800 clamp(1.75rem, 4vw, 2.5rem)/1.1 var(--nx-display);
  letter-spacing: -0.01em;
}
.nx-h2 {
  margin: 0 0 0.25rem;
  font: 700 1.2rem/1.2 var(--nx-display);
}
.nx-lede {
  margin: 0.6rem 0 0;
  max-width: 56ch;
  color: var(--nx-muted);
}
.nx-eyebrow {
  margin: 0 0 0.5rem;
  font: 500 0.7rem var(--nx-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--nx-cyan);
}
.nx-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

/* ——— Gate / full-screen state (no card) ——— */
.nx-gate {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-height: 60vh;
  max-width: 560px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
}
.nx-gate .nx-btn {
  margin-top: 1.5rem;
}
.nx-gate-rule {
  width: 48px;
  height: 2px;
  margin: 0 0 1.25rem;
  background: var(--nx-cyan);
}
.nx-gate-rule.is-err {
  background: var(--nx-err);
}

/* ——— Metrics as ruled rows (no cards) ——— */
.nx-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  border-top: 1px solid var(--nx-line);
  border-bottom: 1px solid var(--nx-line);
}
.nx-metric {
  padding: 1rem 1rem 1rem 0;
}
.nx-metric + .nx-metric {
  padding-left: 1rem;
  border-left: 1px solid var(--nx-line-soft);
}
.nx-metric-value {
  font: 700 1.9rem/1 var(--nx-mono);
  letter-spacing: -0.02em;
}
.nx-metric-label {
  margin-top: 0.35rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--nx-muted);
}

/* ——— Tables ——— */
.nx-table-wrap {
  overflow-x: auto;
  border-top: 1px solid var(--nx-line);
}
.nx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
.nx-table th {
  padding: 0.6rem 0.75rem;
  text-align: left;
  font: 500 0.68rem var(--nx-font);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--nx-muted);
  border-bottom: 1px solid var(--nx-line);
  white-space: nowrap;
}
.nx-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--nx-line-soft);
  vertical-align: middle;
}
.nx-table tbody tr:hover {
  background: rgba(34, 211, 238, 0.03);
}
.nx-table .is-num {
  font-family: var(--nx-mono);
  text-align: right;
}
.nx-empty {
  padding: 1.5rem 0;
  color: var(--nx-muted);
  font-size: 0.9rem;
}

/* ——— Badges / chips ——— */
.nx-badge {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--nx-line);
  font: 500 0.7rem var(--nx-mono);
  color: var(--nx-muted);
  white-space: nowrap;
}
.nx-badge.is-ok {
  color: var(--nx-ok);
  border-color: rgba(52, 211, 153, 0.35);
}
.nx-badge.is-warn {
  color: var(--nx-warn);
  border-color: rgba(251, 191, 36, 0.35);
}
.nx-badge.is-err {
  color: var(--nx-err);
  border-color: rgba(251, 113, 133, 0.35);
}
.nx-badge.is-cyan {
  color: var(--nx-cyan);
  border-color: rgba(34, 211, 238, 0.35);
}
.nx-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* ——— Inline notices ——— */
.nx-notice {
  margin: 0 0 1rem;
  padding: 0.65rem 0.85rem;
  border-left: 2px solid var(--nx-cyan);
  background: rgba(34, 211, 238, 0.05);
  font-size: 0.86rem;
}
.nx-notice.is-err {
  border-left-color: var(--nx-err);
  background: rgba(251, 113, 133, 0.06);
}
.nx-notice.is-warn {
  border-left-color: var(--nx-warn);
  background: rgba(251, 191, 36, 0.06);
}
.nx-notice.is-ok {
  border-left-color: var(--nx-ok);
  background: rgba(52, 211, 153, 0.06);
}

/* ——— Loading ——— */
.nx-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--nx-line);
  border-top-color: var(--nx-cyan);
  animation: nx-spin 0.7s linear infinite;
}
@keyframes nx-spin {
  to {
    transform: rotate(360deg);
  }
}
.nx-loading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem 0;
  color: var(--nx-muted);
}

/* ——— Toast ——— */
.nx-toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 100;
  max-width: 340px;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--nx-line);
  border-left: 2px solid var(--nx-cyan);
  border-radius: 6px;
  background: var(--nx-raised);
  font-size: 0.85rem;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
}
.nx-toast.is-err {
  border-left-color: var(--nx-err);
}

/* ——— Dialog ——— */
.nx-dialog {
  padding: 1.25rem;
  width: min(480px, calc(100vw - 2rem));
  border: 1px solid var(--nx-line);
  border-radius: var(--nx-radius);
  background: var(--nx-panel);
  color: var(--nx-text);
}
.nx-dialog::backdrop {
  background: rgba(3, 4, 7, 0.72);
}
.nx-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

@media (prefers-reduced-motion: reduce) {
  .nx-spinner {
    animation-duration: 2s;
  }
}

/* ——— Print: drop the shell chrome, let the content flow (used by Security "Rapporter") ——— */
@media print {
  .desktop-sidebar,
  .mobile-header,
  .desktop-topbar,
  .bottom-nav,
  .more-sheet,
  .no-print {
    display: none !important;
  }
  html,
  body,
  .app-shell,
  .app-shell > div,
  .main-scroll {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }
  body {
    background: #fff !important;
    color: #000 !important;
  }
}
