/* ================================================================
   Project Zeratul — modules/admin-tenants.css
   Styles for the super admin Tenant Management page.
   Scoped under .at-* to avoid collisions with app.css globals.
   ================================================================ */


/* ── Page wrapper ────────────────────────────────────────────── */
.at-wrap {
  padding: var(--sp-8) var(--sp-8) var(--sp-16);
  max-width: 860px;
}

/* ── Page header ─────────────────────────────────────────────── */
.at-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-6);
  margin-bottom: var(--sp-8);
  padding-bottom: var(--sp-6);
  border-bottom: 1px solid var(--border);
}

.at-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 300;
  letter-spacing: 0.05em;
  color: var(--cream);
  margin-bottom: var(--sp-1);
}

.at-sub {
  font-size: var(--text-sm);
  color: var(--stone-light);
}

/* ── Loading state ───────────────────────────────────────────── */
.at-loading {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-8) 0;
  font-size: var(--text-sm);
  color: var(--stone-light);
}

/* ── Tenant list table overrides ─────────────────────────────── */
.at-mono {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: var(--stone-light);
  letter-spacing: 0.04em;
}

.at-muted {
  color: var(--stone-light);
  font-size: var(--text-sm);
}


/* ── Create view ─────────────────────────────────────────────── */
.at-create-header {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  margin-bottom: var(--sp-7);
}

.at-back-btn {
  background: none;
  border: none;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--stone-light);
  cursor: pointer;
  letter-spacing: 0.03em;
  padding: 0;
  transition: color var(--t-fast);
}

.at-back-btn:hover { color: var(--cream); }

.at-create-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 300;
  letter-spacing: 0.06em;
  color: var(--cream);
}


/* ── Form cards ──────────────────────────────────────────────── */
.at-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: var(--sp-5);
}

.at-card-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-6);
  border-bottom: 1px solid var(--border);
  background: var(--surface-raised);
}

.at-card-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--gold-dim);
  border: 1px solid var(--gold-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--gold);
  flex-shrink: 0;
}

.at-card-title {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cream-muted);
}

.at-card-body {
  padding: var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}


/* ── Form controls ───────────────────────────────────────────── */
.at-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-5);
}

.at-form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.at-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--stone-light);
}

.at-label-hint {
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: none;
  opacity: 0.7;
  margin-left: 4px;
}

.at-input,
.at-select {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-2) var(--sp-3);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--cream);
  outline: none;
  transition: border-color var(--t-fast);
  width: 100%;
}

.at-input::placeholder { color: var(--stone-light); }

.at-input:focus,
.at-select:focus { border-color: var(--gold-muted); }

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

.at-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238A8278'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

.at-select option {
  background: var(--surface-raised);
  color: var(--cream);
}

.at-slug-preview {
  font-size: 10px;
  color: var(--gold-muted);
  letter-spacing: 0.04em;
  font-family: 'Courier New', monospace;
}

.at-field-error {
  font-size: 10px;
  color: var(--danger-text);
  letter-spacing: 0.02em;
}

.at-hint {
  font-size: var(--text-xs);
  color: var(--stone-light);
  line-height: 1.6;
}

.at-hint strong { color: var(--cream-muted); }


/* ── Module grid ─────────────────────────────────────────────── */
.at-module-controls {
  display: flex;
  gap: var(--sp-4);
  margin-bottom: var(--sp-2);
}

.at-link {
  font-size: 10px;
  color: var(--stone-light);
  letter-spacing: 0.04em;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--t-fast);
}

.at-link:hover { color: var(--cream-muted); }

.at-module-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-2);
}

.at-module-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--t-fast);
  user-select: none;
}

.at-module-item:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.at-module-item.selected {
  border-color: var(--gold-muted);
  background: var(--gold-faint);
}

.at-mod-check {
  width: 14px;
  height: 14px;
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 9px;
  color: transparent;
  transition: all var(--t-fast);
}

.at-module-item.selected .at-mod-check {
  background: var(--gold-dim);
  border-color: var(--gold-muted);
  color: var(--gold);
}

.at-mod-name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--stone-mid);
  transition: color var(--t-fast);
}

.at-module-item.selected .at-mod-name { color: var(--cream); }

.at-mod-desc {
  font-size: 10px;
  color: var(--stone-light);
  margin-top: 1px;
}


/* ── Action row ──────────────────────────────────────────────── */
.at-action-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-3);
  margin-top: var(--sp-2);
  padding-top: var(--sp-4);
}

.at-action-error {
  font-size: var(--text-sm);
  color: var(--danger-text);
  letter-spacing: 0.02em;
  flex: 1;
}


/* ── Progress log ────────────────────────────────────────────── */
.at-progress {
  background: var(--stone-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-6);
  margin-top: var(--sp-6);
  font-family: 'Courier New', monospace;
}

.at-progress-title {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--stone-light);
  margin-bottom: var(--sp-4);
}

.at-log-lines {
  max-height: 220px;
  overflow-y: auto;
}

.at-log-line {
  font-size: 11px;
  letter-spacing: 0.03em;
  line-height: 2;
  color: var(--stone-light);
}

.at-log-line.ok     { color: var(--success-text); }
.at-log-line.err    { color: var(--danger-text);  }
.at-log-line.active { color: var(--cream-muted);  }
.at-log-line.warn   { color: var(--warning-text); }


/* ── Success card ────────────────────────────────────────────── */
.at-success {
  background: var(--success-dim);
  border: 1px solid var(--success);
  border-radius: var(--radius-md);
  padding: var(--sp-7);
  margin-top: var(--sp-6);
}

.at-success-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 300;
  letter-spacing: 0.06em;
  color: var(--success-text);
  margin-bottom: var(--sp-5);
}

.at-summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.at-sum-label {
  width: 160px;
  padding: var(--sp-2) 0;
  border-bottom: 1px solid rgba(46, 125, 82, 0.2);
  color: var(--stone-light);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding-right: var(--sp-4);
  vertical-align: top;
}

.at-sum-val {
  padding: var(--sp-2) 0;
  border-bottom: 1px solid rgba(46, 125, 82, 0.2);
  color: var(--cream);
  font-family: 'Courier New', monospace;
  font-size: 11px;
}

.at-summary-table tr:last-child td { border-bottom: none; }

.at-success-actions {
  display: flex;
  gap: var(--sp-3);
  margin-top: var(--sp-6);
}

/* ── Annual fee input with $ prefix ─────────────────────────── */
.at-input-prefix-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.at-input-prefix {
  position: absolute;
  left: 10px;
  font-size: var(--text-sm);
  color: var(--stone-light);
  pointer-events: none;
  z-index: 1;
}

.at-input-prefixed {
  padding-left: 22px;
}


/* ── Clickable table rows ────────────────────────────────────── */
.at-clickable-row:hover td {
  background: var(--surface-hover);
}

/* ── Edit modal ─────────────────────────────────────────────── */
.at-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: var(--sp-6);
}

.at-modal {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
}

.at-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.at-modal-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 300;
  letter-spacing: 0.05em;
  color: var(--cream);
}

.at-modal-close {
  background: none;
  border: none;
  font-size: var(--text-md);
  color: var(--stone-light);
  cursor: pointer;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius);
  transition: color var(--t-fast);
  line-height: 1;
}

.at-modal-close:hover { color: var(--cream); }

.at-modal-body {
  padding: var(--sp-6);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  flex: 1;
}

.at-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}