/* Whitebox Admin — self-contained styles, no framework dependency */

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

:root {
  --sidebar-width: 220px;
  --sidebar-bg: #1e2a38;
  --sidebar-text: #c8d6e5;
  --sidebar-active: #ffffff;
  --sidebar-hover: #2d3f54;
  --accent: #4a90d9;
  --body-bg: #f5f7fa;
  --body-text: #212529;
  --border: #dee2e6;
  --radius: 4px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font);
  font-size: 15px;
  color: var(--body-text);
  background: var(--body-bg);
}

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

/* ── Layout ─────────────────────────────────────────────────────────── */

.admin-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 1.25rem 1.5rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--sidebar-active);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar ul {
  list-style: none;
  margin: 0.25rem 0 0;
  padding: 0;
}

.sidebar-section {
  padding: 0.45rem 0 0.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-label {
  padding: 0.5rem 1.25rem 0.2rem;
  color: #a9bacb;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar ul li a {
  display: block;
  margin: 0.05rem 0.75rem 0.05rem 1.15rem;
  padding: 0.5rem 0.75rem;
  color: var(--sidebar-text);
  text-decoration: none;
  transition: background 0.15s;
  font-size: 0.9rem;
  border-radius: var(--radius);
}

.sidebar ul li a:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-active);
}

.sidebar ul li a.active {
  background: var(--sidebar-hover);
  color: var(--sidebar-active);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar-footer {
  margin-top: auto;
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.82rem;
  color: var(--sidebar-text);
}

.sidebar-footer a { color: var(--sidebar-text); }

.main-content {
  flex: 1;
  padding: 2rem 2.5rem;
  overflow-y: auto;
  max-width: 1100px;
}

.breadcrumbs {
  margin-bottom: 0.75rem;
  font-size: 0.82rem;
}

.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.breadcrumbs li:not(:last-child)::after {
  content: "/";
  margin-left: 0.4rem;
  color: #8a96a3;
}

.breadcrumbs span {
  color: #6c757d;
}

/* ── Page header ─────────────────────────────────────────────────────── */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.page-header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.page-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.object-meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: -0.9rem;
  margin-bottom: 1rem;
  color: #6c757d;
  font-size: 0.84rem;
}

.hub-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 1rem;
  align-items: start;
}

.hub-main,
.related-panel,
.summary-panel {
  min-width: 0;
}

.related-panel,
.summary-panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.related-panel h2,
.summary-panel h2 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
}

.related-list {
  display: grid;
  gap: 0.45rem;
}

.related-list a {
  display: block;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: #334155;
  background: #f8fafc;
}

.related-list a:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
  background: #fff;
}

.summary-list {
  display: grid;
  grid-template-columns: 9rem minmax(0, 1fr);
  gap: 0.55rem 0.75rem;
  margin: 0;
  font-size: 0.88rem;
}

.summary-list dt {
  color: #6c757d;
  font-weight: 600;
}

.summary-list dd {
  margin: 0;
  min-width: 0;
  word-break: break-word;
}

.section-tabs {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  margin: 0 0 1rem;
  background: #e9eef5;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-wrap: wrap;
}

.section-tab {
  display: inline-block;
  min-width: 6rem;
  padding: 0.4rem 0.75rem;
  color: #495057;
  font-size: 0.86rem;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
}

.section-tab:hover {
  color: var(--accent);
  background: #fff;
  text-decoration: none;
}

.section-tab.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

/* ── Flash messages ──────────────────────────────────────────────────── */

.flash {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.flash.is-hiding {
  opacity: 0;
  transform: translateY(-4px);
}

.flash-dismiss {
  flex: 0 0 auto;
  width: 1.25rem;
  height: 1.25rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: currentColor;
  font-size: 1.1rem;
  line-height: 1;
  opacity: 0.7;
}

.flash-dismiss:hover {
  opacity: 1;
  background: transparent;
}

.flash-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.flash-error   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.flash-info    { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

.confetti-rain {
  position: fixed;
  inset: 0;
  z-index: 9999;
  overflow: hidden;
  pointer-events: none;
}

.confetti-rain span {
  position: absolute;
  top: -1rem;
  width: 0.5rem;
  height: 0.85rem;
  border-radius: 1px;
  opacity: 0.9;
  animation-name: confetti-fall;
  animation-timing-function: cubic-bezier(0.32, 0.02, 0.72, 1);
  animation-fill-mode: forwards;
}

@keyframes confetti-fall {
  0% {
    translate: 0 -1rem;
    rotate: 0deg;
  }
  100% {
    translate: 1.5rem 105vh;
    rotate: 540deg;
  }
}

@media (prefers-reduced-motion: reduce) {
  .confetti-rain {
    display: none;
  }
}

/* ── Tables ──────────────────────────────────────────────────────────── */

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

thead th {
  background: #f0f3f6;
  text-align: left;
  padding: 0.65rem 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6c757d;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

tbody tr.duplicate-access-row {
  background: #fff8e1;
}

tbody tr.duplicate-access-row:hover {
  background: #fff3cd;
}

.row-link {
  font-weight: 600;
}

.sort-link {
  color: inherit;
  display: inline-flex;
  gap: 0.25rem;
  align-items: center;
  text-decoration: none;
}

.sort-link:hover,
.sort-link.active {
  color: var(--accent);
  text-decoration: none;
}

.empty-state {
  padding: 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: #6c757d;
  background: #fff;
}

/* ── Buttons ─────────────────────────────────────────────────────────── */

button, .btn, input[type="submit"] {
  display: inline-block;
  padding: 0.45rem 1rem;
  font-size: 0.88rem;
  font-weight: 500;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: opacity 0.15s, background 0.15s;
  font-family: var(--font);
  line-height: 1.5;
}

.btn-primary, input[type="submit"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover, input[type="submit"]:hover { opacity: 0.88; color: #fff; text-decoration: none; }

.btn-secondary {
  background: #6c757d;
  color: #fff;
  border-color: #6c757d;
}

.btn-secondary:hover { opacity: 0.88; color: #fff; text-decoration: none; }

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

.btn-outline:hover { background: var(--accent); color: #fff; text-decoration: none; }

.btn-danger {
  background: #dc3545;
  color: #fff;
  border-color: #dc3545;
}

.btn-danger:hover { opacity: 0.88; color: #fff; text-decoration: none; }

.btn-sm {
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
}

/* ── Forms ───────────────────────────────────────────────────────────── */

.form-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
  max-width: 600px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 0.3rem;
  color: #495057;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
  display: block;
  width: 100%;
  padding: 0.45rem 0.75rem;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--body-text);
  font-family: var(--font);
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(74,144,217,0.15);
}

.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.form-check label { margin: 0; font-size: 0.9rem; }

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.form-errors {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

/* ── Badges ──────────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 0.2em 0.55em;
  border-radius: 3px;
  font-size: 0.77rem;
  font-weight: 600;
}

.badge-success  { background: #28a745; color: #fff; }
.badge-secondary { background: #6c757d; color: #fff; }
.badge-warning  { background: #ffc107; color: #212529; }
.badge-danger { background: #dc3545; color: #fff; }
.badge-primary { background: var(--accent); color: #fff; }

/* ── Filter form ─────────────────────────────────────────────────────── */

.filter-form {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.filter-form .form-group { margin-bottom: 0; }

/* ── Dashboard stats ─────────────────────────────────────────────────── */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 0.85rem;
  color: #6c757d;
  margin-top: 0.25rem;
}

/* ── Login page ──────────────────────────────────────────────────────── */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--body-bg);
}

.login-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  text-align: center;
}

.login-card h2 { margin: 0 0 1.5rem; font-size: 1.4rem; }

/* ── Utility ─────────────────────────────────────────────────────────── */

.text-muted { color: #6c757d; font-size: 0.88rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.gap-1 { gap: 0.5rem; }
hr { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }

/* ── Cron help tooltip ───────────────────────────────────────────────── */

.cron-help-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: default;
  margin-left: 0.35rem;
  vertical-align: middle;
  user-select: none;
}

.cron-help-box {
  display: none;
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  padding: 0.75rem 1rem;
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--body-text);
  white-space: nowrap;
  z-index: 100;
  line-height: 1.7;
}

.cron-help-box code {
  background: #f0f3f6;
  border-radius: 3px;
  padding: 0.05em 0.3em;
  font-family: monospace;
  font-size: 0.9em;
}

.cron-help-trigger:hover .cron-help-box {
  display: block;
}

.tenant-tab-nav {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  padding: 0.25rem;
  margin: 0 0 1.25rem;
  background: #e9eef5;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 100%;
}

.tenant-tab-link {
  display: inline-block;
  min-width: 6.75rem;
  padding: 0.45rem 1rem;
  color: #495057;
  font-size: 0.9rem;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
}

.tenant-tab-link:hover {
  color: var(--accent);
  background: #fff;
  text-decoration: none;
}

.tenant-tab-link.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
}

.tenant-tab-link.active:hover {
  color: #fff;
}

.tenant-notes-markdown {
  line-height: 1.6;
  font-size: 0.92rem;
}

.tenant-notes-markdown h1,
.tenant-notes-markdown h2,
.tenant-notes-markdown h3,
.tenant-notes-markdown h4,
.tenant-notes-markdown h5,
.tenant-notes-markdown h6 {
  margin-top: 1.1rem;
  margin-bottom: 0.45rem;
  line-height: 1.3;
}

.tenant-notes-markdown h1,
.tenant-notes-markdown h2 {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.25rem;
}

.tenant-notes-markdown p,
.tenant-notes-markdown ul,
.tenant-notes-markdown ol,
.tenant-notes-markdown blockquote,
.tenant-notes-markdown pre,
.tenant-notes-markdown table {
  margin-top: 0.55rem;
  margin-bottom: 0.55rem;
}

.tenant-notes-markdown ul,
.tenant-notes-markdown ol {
  padding-left: 1.5rem;
}

.tenant-notes-markdown code {
  background: #f0f3f6;
  border-radius: 3px;
  padding: 0.1em 0.3em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.9em;
}

.tenant-notes-markdown pre {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem;
  overflow-x: auto;
}

.tenant-notes-markdown pre code {
  background: transparent;
  padding: 0;
}

.tenant-notes-markdown blockquote {
  margin-left: 0;
  padding: 0.45rem 0.8rem;
  border-left: 3px solid #b8c4d3;
  background: #f8fafc;
  color: #495057;
}

.tenant-notes-markdown table {
  width: 100%;
  border-collapse: collapse;
}

.tenant-notes-markdown th,
.tenant-notes-markdown td {
  border: 1px solid var(--border);
  padding: 0.35rem 0.5rem;
}

.tenant-notes-markdown th {
  background: #f0f4f8;
}

@media (max-width: 900px) {
  .admin-layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
  }

  .sidebar-section {
    padding: 0.2rem 0;
  }

  .main-content {
    padding: 1.25rem;
  }

  .hub-layout {
    grid-template-columns: 1fr;
  }
}
