/* ============================================================
   Tenant Admin UI — style.css
   ============================================================ */

/* --- Reset / Base --- */
:root {
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #16a34a;
  --warn: #d97706;
  --bg: #f8fafc;
  --surface: #fff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 8px;
  --radius-lg: 12px;
}

body {
  background: var(--bg);
  color: var(--text);
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* --- Header bar (fixed top) --- */
.header-bar {
  position: sticky;
  top: 0;
  z-index: 900;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-bar .brand {
  font-weight: 700;
  font-size: 1.1em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.header-actions .btn {
  padding: 6px 14px;
  font-size: 0.85em;
}

/* slug jump form in header */
.slug-jump {
  display: flex;
  align-items: center;
  gap: 4px;
  position: relative;
}

.slug-jump input {
  width: 160px;
  padding: 5px 10px;
  font-size: 0.85em;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  font-family: monospace;
  margin: 0;
}

.slug-jump input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.slug-jump .slug-error {
  position: absolute;
  top: 100%;
  left: 0;
  font-size: 0.75em;
  color: var(--danger);
  white-space: nowrap;
  margin-top: 2px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  font-size: 0.9em;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
  line-height: 1.4;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

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

.btn-secondary {
  background: #e2e8f0;
  color: var(--text);
}
.btn-secondary:hover { background: #cbd5e1; }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: var(--danger-hover); }

.btn:disabled, .btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 0.8em;
}

/* --- Main content --- */
.main-content {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

/* --- Flash messages --- */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 0.9em;
}

.flash-success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.flash-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* --- Badges --- */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 0.75em;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.badge-active { background: var(--success); color: #fff; }
.badge-paused { background: var(--warn); color: #fff; }
.badge-canceled { background: var(--danger); color: #fff; }

/* --- Secret status --- */
.secret-set { color: var(--success); font-weight: 700; }
.secret-notset { color: var(--danger); font-weight: 700; }

/* --- Tables --- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
}

thead th {
  text-align: left;
  padding: 8px 12px;
  background: var(--bg);
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  font-size: 0.85em;
  color: var(--text-muted);
}

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

tbody tr:hover { background: #f1f5f9; }

.mono {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.88em;
}

/* --- Cards (menu) --- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.menu-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.menu-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.menu-card h3 {
  margin: 0;
  font-size: 1.05em;
  color: var(--text);
}

.menu-card p {
  margin: 0;
  font-size: 0.88em;
  color: var(--text-muted);
  flex: 1;
}

.menu-card .btn {
  align-self: flex-start;
}

/* --- Forms --- */
fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
}

legend {
  font-weight: 700;
  font-size: 0.95em;
  padding: 0 6px;
}

label {
  display: block;
  margin-bottom: 14px;
  font-size: 0.9em;
  font-weight: 500;
}

input[type="text"],
input[type="password"],
textarea,
select {
  display: block;
  width: 100%;
  padding: 8px 12px;
  margin-top: 4px;
  font-size: 0.9em;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-sizing: border-box;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

input:disabled, textarea:disabled {
  background: #f1f5f9;
  color: var(--text-muted);
}

.field-error {
  color: var(--danger);
  font-size: 0.8em;
  margin-top: 2px;
}

small {
  color: var(--text-muted);
  font-size: 0.82em;
}

/* --- Details / Sections --- */
details {
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}

details > summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 0.95em;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

details > summary::before {
  content: "▶";
  font-size: 0.7em;
  transition: transform 0.15s;
}

details[open] > summary::before {
  transform: rotate(90deg);
}

/* --- Button groups --- */
.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* --- Confirm modal --- */
.confirm-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.confirm-overlay.show { display: flex; }

.confirm-box {
  background: var(--surface);
  padding: 28px;
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 90%;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.confirm-box h4 { margin-top: 0; }

.confirm-detail {
  font-family: monospace;
  font-size: 0.85em;
  background: var(--bg);
  padding: 12px;
  border-radius: var(--radius);
  margin: 12px 0;
  white-space: pre-wrap;
}

/* --- Sort links (list table headers) --- */
.sort-link {
  text-decoration: none;
  color: inherit;
  white-space: nowrap;
}
.sort-link:hover { color: var(--accent); }

/* --- Responsive --- */
@media (max-width: 640px) {
  .header-bar {
    padding: 0 12px;
    gap: 8px;
  }

  .header-actions {
    gap: 4px;
  }

  .header-actions .btn {
    padding: 5px 10px;
    font-size: 0.8em;
  }

  .slug-jump input {
    width: 110px;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .main-content {
    padding: 16px 12px 32px;
  }

  details {
    padding: 12px 14px;
  }
}

/* --- RAG tabs --- */
.rag-tabs { display: flex; gap: 0; margin-bottom: 12px; }
.rag-tab { padding: 6px 16px; border: 1px solid var(--border); background: var(--bg); cursor: pointer; font-size: 0.85em; }
.rag-tab:first-child { border-radius: 4px 0 0 4px; }
.rag-tab:last-child { border-radius: 0 4px 4px 0; }
.rag-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-example { font-size: 0.7em; padding: 2px 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 3px; cursor: pointer; margin-top: 4px; }
.btn-example:hover { background: var(--border); }
.textarea-wrap { position: relative; }
