/* ─────────────────────────────────────────────────────────────
   wleenk · License Admin — "Obsidian Vault"
   Dark luxury admin panel stylesheet
   ───────────────────────────────────────────────────────────── */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --bg:             #07090d;
  --surface:        #0d1118;
  --surface-2:      #111720;
  --surface-3:      #161e28;
  --border:         #1c2433;
  --border-bright:  #253040;
  --text:           #d8e2f0;
  --text-muted:     #506070;
  --text-dim:       #2d3d4d;
  --accent:         #00e5a0;
  --accent-dim:     rgba(0, 229, 160, 0.10);
  --accent-glow:    rgba(0, 229, 160, 0.20);
  --accent-hover:   #00cc8e;
  --danger:         #ff4d6a;
  --danger-dim:     rgba(255, 77, 106, 0.12);
  --warn:           #ffb84d;
  --warn-dim:       rgba(255, 184, 77, 0.12);
  --ok:             #00e5a0;
  --sidebar-w:      210px;
  --radius:         4px;
  --font-serif:     'Cormorant Garamond', Georgia, serif;
  --font-mono:      'JetBrains Mono', 'Fira Code', monospace;
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-mono);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-bright);
  border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

/* ── Unauthenticated (Login) State ──────────────────────────── */
body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 60% 50% at 50% 60%, rgba(0, 229, 160, 0.04) 0%, transparent 70%),
    var(--bg);
}

body #sidebar {
  display: none;
}

/* ── Authenticated Layout ───────────────────────────────────── */
body.authenticated {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  background: var(--bg);
}

body.authenticated #sidebar {
  display: flex;
}

/* ── Sidebar ────────────────────────────────────────────────── */
#sidebar {
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}

.brand {
  padding: 28px 20px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand-name {
  display: block;
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 400;
  color: #ffffff;
  line-height: 1;
  letter-spacing: 0.5px;
}

.brand-sub {
  display: block;
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: var(--text-muted);
  margin-top: 6px;
}

#nav {
  display: flex;
  flex-direction: column;
  padding: 12px 0;
  flex: 1;
}

#nav a {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 10px 20px;
  color: var(--text-muted);
  text-decoration: none;
  letter-spacing: 0.5px;
  border-left: 2px solid transparent;
  transition: color 0.2s, background 0.2s, border-left-color 0.2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#nav a:hover {
  color: var(--text);
  background: var(--surface-2);
}

#nav a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-dim);
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-footer button {
  width: 100%;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 8px 12px;
  font-size: 10px;
  letter-spacing: 1.5px;
}

.sidebar-footer button:hover {
  color: var(--danger);
  border-color: rgba(255, 77, 106, 0.4);
  background: var(--danger-dim);
}

/* ── Main Content ───────────────────────────────────────────── */
#app,
main {
  padding: 32px 36px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  min-width: 0;
}

/* ── Login Card ─────────────────────────────────────────────── */
.login-card {
  width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 48px 40px;
  box-shadow:
    0 0 60px rgba(0, 229, 160, 0.06),
    0 24px 48px rgba(0, 0, 0, 0.4);
}

.login-brand {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.login-brand-name {
  display: block;
  font-family: var(--font-serif);
  font-size: 42px;
  font-weight: 300;
  color: #ffffff;
  line-height: 1;
  letter-spacing: 0.5px;
}

.login-brand-sub {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 4px;
  color: var(--text-muted);
}

.login-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* Login form: underline-only inputs */
.login-card form {
  gap: 20px;
}

.login-card label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-card input {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 10px 0;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  transition: border-bottom-color 0.2s;
}

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

.login-card input::placeholder {
  color: var(--text-dim);
}

.login-card .btn-submit {
  width: 100%;
  background: var(--accent);
  color: #000000;
  border: none;
  border-radius: 0;
  padding: 13px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 2px;
  cursor: pointer;
  margin-top: 8px;
  position: relative;
  transition: background 0.15s;
}

.login-card .btn-submit:hover {
  background: var(--accent-hover);
}

/* Loading spinner state */
.login-card .btn-submit.btn-loading {
  color: transparent;
  pointer-events: none;
}

.login-card .btn-submit.btn-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(0, 0, 0, 0.3);
  border-top-color: #000000;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.login-error {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--danger);
  margin: 12px 0 0;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
}

.card.narrow {
  max-width: 480px;
  margin: 0 auto;
}

/* ── Typography ─────────────────────────────────────────────── */
h2 {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 400;
  color: var(--text);
  margin: 0 0 20px;
  letter-spacing: 0.5px;
}

h3 {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin: 24px 0 12px;
}

p {
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Flex Utilities ─────────────────────────────────────────── */
.flex {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.flex.between {
  justify-content: space-between;
}

/* ── Buttons ────────────────────────────────────────────────── */
button {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  border: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  background: var(--accent);
  color: #000000;
  line-height: 1;
}

button:hover {
  background: var(--accent-hover);
}

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

button.ghost:hover {
  color: var(--text);
  border-color: var(--border-bright);
  background: transparent;
}

button.danger {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid rgba(255, 77, 106, 0.3);
}

button.danger:hover {
  background: rgba(255, 77, 106, 0.2);
}

/* ── Forms (authenticated) ──────────────────────────────────── */
form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
}

input,
select,
textarea {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  transition: border-color 0.15s, background 0.15s;
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-3);
}

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

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

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

/* ── Tables ─────────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12px;
}

th {
  font-size: 10px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-dim);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

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

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

tr:hover td {
  background: var(--surface-2);
}

td code,
dd code {
  color: var(--accent);
  font-size: 11px;
  font-family: var(--font-mono);
}

td.actions {
  text-align: right;
  white-space: nowrap;
}

td.actions button + button {
  margin-left: 6px;
}

/* ── Status Badges ──────────────────────────────────────────── */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status.active::before {
  background: var(--ok);
  box-shadow: 0 0 6px var(--ok);
}
.status.active {
  color: var(--ok);
}

.status.suspended::before {
  background: var(--warn);
}
.status.suspended {
  color: var(--warn);
}

.status.revoked::before {
  background: var(--danger);
}
.status.revoked {
  color: var(--danger);
}

.status.trial::before {
  background: #60a5fa;
}
.status.trial {
  color: #60a5fa;
}

/* ── Stat Cards (dashboard) ─────────────────────────────────── */
.grid {
  display: grid;
  gap: 16px;
}

.grid.stats {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 32px 16px;
  gap: 8px;
}

.stat .num {
  font-family: var(--font-serif);
  font-size: 52px;
  font-weight: 300;
  color: var(--accent);
  line-height: 1;
  letter-spacing: -1px;
}

.stat .label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
}

/* ── Definition List ────────────────────────────────────────── */
dl.kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px 24px;
  margin: 0 0 20px;
}

dl.kv dt {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  padding-top: 2px;
}

dl.kv dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
}

dl.kv pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 11px;
  overflow: auto;
  margin: 0;
  color: var(--text);
  font-family: var(--font-mono);
}

/* ── Misc Utilities ─────────────────────────────────────────── */
.error {
  color: var(--danger);
  font-family: var(--font-mono);
  font-size: 12px;
  margin: 0;
}

.back {
  color: var(--text-muted);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  transition: color 0.15s;
}

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

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

code {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  body.authenticated {
    grid-template-columns: 1fr;
  }

  body.authenticated #sidebar {
    display: none;
  }

  #app,
  main {
    padding: 20px 16px;
  }

  dl.kv {
    grid-template-columns: 1fr;
    gap: 4px 0;
  }

  dl.kv dt {
    margin-top: 10px;
  }

  dl.kv dt:first-child {
    margin-top: 0;
  }

  .login-card {
    width: 100%;
    max-width: 380px;
    padding: 36px 24px;
  }

  .grid.stats {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  table {
    font-size: 11px;
  }

  th, td {
    padding: 8px 8px;
  }
}

/* ── Console ────────────────────────────────────────────────── */
.console-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 16px;
  height: calc(100vh - 160px);
  min-height: 400px;
}

.console-cmds {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
}

.console-cmds-title {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 12px 4px;
}

.console-btn-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.console-cmd-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 6px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.console-cmd-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.console-cmd-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.console-panel {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.console-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}

.console-prompt {
  color: var(--accent);
  font-size: 14px;
  line-height: 1;
}

.console-cmd-label {
  color: var(--text);
  font-size: 12px;
  flex: 1;
}

.console-ts {
  font-size: 10px;
  color: var(--text-dim);
}

.console-spinner {
  color: var(--accent);
  font-size: 14px;
  animation: blink 0.8s step-start infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.console-output {
  flex: 1;
  margin: 0;
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.7;
  color: var(--text);
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.console-output.console-error {
  color: var(--danger);
}

@media (max-width: 768px) {
  .console-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .console-cmds {
    max-height: 200px;
  }
  .console-output {
    min-height: 300px;
  }
}

/* ── Perpetual license form ─────────────────────────────────── */
.expires-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.expires-row input[name="expires_at"] {
  flex: 1;
}
.perpetual-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}
.perpetual-check input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
}
