/* SPX License Manager — dark theme.
   Palette/fonts are PLACEHOLDERS approximating spxgraphics.com; all values are
   consolidated here as custom properties so the real brand palette can be
   dropped in by editing this :root block only (see PLAN.md §8). */

@font-face {
  font-family: "UI-Light";
  src: url("../fonts/EncodeSansSemiExpanded-Light.ttf");
}

@font-face {
  font-family: "UI-Regular";
  src: url("../fonts/EncodeSansSemiExpanded-Regular.ttf");
}

@font-face {
  font-family: "UI-Bold";
  src: url("../fonts/EncodeSansSemiExpanded-Bold.ttf");
}

:root {
  --bg:           #1d252c;
  --surface:      #161b22;
  --surface-2:    #29323f;
  --border:       #2a313c;
  --text:         #e6edf3;
  --text-muted:   #8b949e;
  --accent:       #0fbe44; /* brand color */
  --accent-hover: #ffffff;
  --danger:       #e5534b;
  --success:      #2ea043;
  --radius:       2px;
  --radius-sm:    2px;
  --shadow:       0 8px 24px rgba(0, 0, 0, 0.4);
  --font: 'UI-Regular', sans-serif;
  --mono: 'UI-Regular', monospace;
}

* {
  box-sizing: border-box;
}

/* The HTML `hidden` attribute must win over component display rules below
   (e.g. `.modal { display: flex }`), otherwise hidden modals stay visible. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

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

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

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ─── Top bar ─────────────────────────────────────────────── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 56px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--text);
}

.brand-mark {
  width: 3em;
  height: 3em;
  background-image: url('../img/SPX_GRAPHICS_glossy_150px_outline-green.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  padding: 2px 8px;
}

.brand-name {
  color: var(--text);
}

.brand-lg {
  font-size: 22px;
  justify-content: center;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
}

.nav {
  display: flex;
  gap: 4px;
  margin-right: auto;
}

.nav-link {
  padding: 0.4em 1em;
  font-size: 0.8rem;
  font-family: 'UI-Bold';
  color: var(--text-muted);
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  border-bottom: 2px solid transparent;
}

.nav-link:hover {
  background: var(--surface-2);
  color: var(--text);
  border-bottom: 2px solid white;
}

.nav-link.is-active {
  color: var(--text);
  background: var(--surface-2);
  border-bottom: 2px solid var(--accent);
}

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

.user-email {
  color: var(--text-muted);
  font-size: 13px;
}

/* ─── Layout pieces ───────────────────────────────────────── */
main.container {
  padding-top: 28px;
  padding-bottom: 64px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-head h1 {
  font-size: 24px;
  margin: 0;
}

.back-link {
  font-size: 13px;
  color: var(--text-muted);
}

.toolbar {
  margin-bottom: 16px;
}

.toolbar-flex {
  gap: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.result-count {
  height: 100%;
  display: flex;
  flex-grow: 1;
  font-size: 0.8em;
  align-items: center;
  white-space: nowrap;
  color: var(--text-muted);
}

.filter-panel {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-field label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.filter-field .input {
  min-width: 180px;
}

.filter-actions {
  display: flex;
  gap: 10px;
  margin-left: auto;
}

.pager-top {
  gap: 18px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pager-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  transition: opacity 0.15s, color 0.15s;
}

.pager-btn svg {
  width: 26px;
  height: 26px;
}

.pager-btn:hover:not(:disabled) {
  color: var(--accent);
}

.pager-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.pager-info {
  min-width: 58px;
  text-align: center;
  font-size: 17px;
  letter-spacing: 1px;
  color: var(--text);
}

.muted {
  color: var(--text-muted);
  font-weight: 400;
}

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
  font-family: 'UI-Bold';
  cursor: pointer;
  padding: 9px 16px;
  text-transform: uppercase;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  text-shadow: 0 0.1em 0.4em rgba(0,0,0,0.5);
  transition: background 0.15s, border-color 0.15s;
}

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

.btn-primary:hover {
  border-bottom-color: var(--accent-hover);
}

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

.btn-ghost:hover {
  background: var(--surface-2);
}

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

.btn-block {
  width: 100%;
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--border);
}

.btn-danger:hover {
  background: rgba(229, 83, 75, 0.12);
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 4px 6px;
  font: inherit;
}

/* ─── Inputs ──────────────────────────────────────────────── */
.input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font: inherit;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
}

.search {
  max-width: 360px;
}

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

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

.data-table th, .data-table td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-table tbody tr:hover {
  background: var(--surface-2);
}

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

.data-table code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
}

.empty {
  padding: 28px;
  text-align: center;
  color: var(--text-muted);
}

.pager {
  text-align: center;
}

/* ─── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-sub {
  background: rgba(255, 90, 31, 0.15);
  color: var(--accent);
}

.badge-purchase {
  background: var(--surface-2);
  color: var(--text-muted);
}

.badge-active {
  background: rgba(46, 160, 67, 0.15);
  color: var(--success);
}

.badge-inactive {
  background: rgba(229, 83, 75, 0.15);
  color: var(--danger);
}

/* ─── Cards / detail ──────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
}

.card h2 {
  margin-top: 0;
  font-size: 16px;
}

.kv {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 8px 16px;
}

.kv dt {
  color: var(--text-muted);
}

.kv dd {
  margin: 0;
}

.events {
  list-style: none;
  padding: 0;
  margin: 0;
}

.events li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.events li:last-child {
  border-bottom: none;
}

/* ─── Modal ───────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 520px;
  padding: 24px;
  max-height: 90vh;
  overflow: auto;
}

.modal-card h2 {
  margin-top: 0;
}

.form label {
  display: block;
  margin-bottom: 14px;
  color: var(--text-muted);
  font-size: 13px;
}

.form label .input, .form label input, .form label select, .form label textarea {
  margin-top: 5px;
  color: var(--text);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

/* ─── Login ───────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: var(--shadow);
}

.login-sub {
  color: var(--text-muted);
  margin: 8px 0 24px;
}

.login-error {
  color: var(--danger);
  margin-top: 14px;
  font-size: 14px;
}

.error-code {
  font-size: 48px;
  margin: 0 0 8px;
}

/* ─── Public portal ───────────────────────────────────────── */
.portal-card {
  max-width: 420px;
}

.portal-done {
  text-align: center;
}

.portal-check {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #fff;
  background: var(--success);
  border-radius: 999px;
}

.portal-h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin: 0 0 10px;
}

.portal-status {
  background: rgba(46, 160, 67, 0.12);
  border: 1px solid var(--success);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  margin: 0 0 16px;
  text-align: left;
}

.portal-licenses {
  list-style: none;
  padding: 0;
  margin: 0;
}

.portal-licenses li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.portal-licenses li:last-child {
  border-bottom: none;
}

.lic-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.lic-host {
  font-size: 14px;
  color: var(--text);
}

.lic-info .muted {
  font-size: 12px;
}

/* ─── Toast ───────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  border-color: var(--danger);
}

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