/* Admin pages — extends styles.css */

.admin-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-lg);
}

.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-lg);
}

.login-card {
  background: var(--gradient-card);
  border: 1px solid var(--stope-gray-800);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl) var(--space-xl);
  width: 100%;
  max-width: 420px;
}

.login-card h1 {
  font-size: 1.6rem;
  color: var(--stope-white);
  margin-bottom: var(--space-xs);
  text-align: center;
}

.login-card .subtitle {
  color: var(--stope-gray-500);
  font-size: 0.85rem;
  text-align: center;
  margin-bottom: var(--space-xl);
}

.form-group {
  margin-bottom: var(--space-lg);
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--stope-gray-400);
  margin-bottom: var(--space-xs);
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--stope-dark);
  border: 1px solid var(--stope-gray-700);
  border-radius: var(--radius-md);
  color: var(--stope-white);
  font-size: 0.9rem;
  font-family: var(--font-body);
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.form-input:focus {
  outline: none;
  border-color: var(--stope-gold);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--stope-gold);
  color: var(--stope-black);
  width: 100%;
}

.btn-primary:hover {
  background: var(--stope-copper);
}

.btn-secondary {
  background: transparent;
  border-color: var(--stope-gray-700);
  color: var(--stope-gray-300);
}

.btn-secondary:hover {
  border-color: var(--stope-gray-500);
  color: var(--stope-white);
}

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

.btn-danger:hover {
  background: rgba(220,60,60,0.15);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.78rem;
}

.alert {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  margin-bottom: var(--space-lg);
  display: none;
}

.alert-error {
  background: rgba(220,60,60,0.12);
  border: 1px solid rgba(220,60,60,0.3);
  color: var(--stope-red);
}

.alert-success {
  background: rgba(46,204,113,0.12);
  border: 1px solid rgba(46,204,113,0.3);
  color: var(--stope-green);
}

.forgot-link {
  display: block;
  text-align: center;
  font-size: 0.82rem;
  color: var(--stope-gray-500);
  margin-top: var(--space-md);
  text-decoration: none;
}

.forgot-link:hover {
  color: var(--stope-gold);
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-2xl);
}

.stat-card {
  background: var(--gradient-card);
  border: 1px solid var(--stope-gray-800);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--stope-gold);
}

.stat-label {
  font-size: 0.78rem;
  color: var(--stope-gray-500);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Admin tables */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.admin-table thead {
  background: var(--stope-charcoal);
}

.admin-table th {
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  color: var(--stope-gray-400);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--stope-gray-800);
}

.admin-table td {
  padding: var(--space-sm) var(--space-md);
  color: var(--stope-gray-300);
  border-bottom: 1px solid var(--stope-gray-800);
}

.admin-table tr:hover td {
  background: rgba(255,255,255,0.02);
}

/* Badges */
.badge-admin { background: rgba(212,168,67,0.15); color: var(--stope-gold); }
.badge-editor { background: rgba(79,140,255,0.15); color: var(--stope-blue); }
.badge-viewer { background: rgba(160,174,192,0.15); color: var(--stope-gray-400); }
.badge-issue { background: rgba(220,60,60,0.15); color: var(--stope-red); }
.badge-feature { background: rgba(46,204,113,0.15); color: var(--stope-green); }
.badge-comment { background: rgba(79,140,255,0.15); color: var(--stope-blue); }
.badge-open { background: rgba(212,168,67,0.15); color: var(--stope-gold); }
.badge-in-progress { background: rgba(79,140,255,0.15); color: var(--stope-blue); }
.badge-resolved { background: rgba(46,204,113,0.15); color: var(--stope-green); }
.badge-closed { background: rgba(160,174,192,0.15); color: var(--stope-gray-400); }
.badge-wontfix { background: rgba(220,60,60,0.15); color: var(--stope-red); }

.badge-sm {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: var(--stope-charcoal);
  border: 1px solid var(--stope-gray-700);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl);
  width: 100%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal h2 {
  font-size: 1.2rem;
  color: var(--stope-white);
  margin-bottom: var(--space-lg);
}

.modal-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  margin-top: var(--space-xl);
}

/* Toolbar */
.toolbar {
  display: flex;
  gap: var(--space-md);
  align-items: center;
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.toolbar select {
  padding: 6px 12px;
  background: var(--stope-dark);
  border: 1px solid var(--stope-gray-700);
  border-radius: var(--radius-md);
  color: var(--stope-gray-300);
  font-size: 0.82rem;
  font-family: var(--font-body);
}

.toolbar select:focus {
  outline: none;
  border-color: var(--stope-gold);
}

/* Pagination */
.pagination {
  display: flex;
  gap: var(--space-xs);
  justify-content: center;
  margin-top: var(--space-xl);
}

.pagination button {
  padding: 6px 12px;
  background: var(--stope-charcoal);
  border: 1px solid var(--stope-gray-700);
  border-radius: var(--radius-sm);
  color: var(--stope-gray-300);
  font-size: 0.82rem;
  cursor: pointer;
}

.pagination button.active {
  border-color: var(--stope-gold);
  color: var(--stope-gold);
}

.pagination button:hover {
  border-color: var(--stope-gray-500);
}

.pagination button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Issue card */
.issue-card {
  background: var(--gradient-card);
  border: 1px solid var(--stope-gray-800);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
  cursor: pointer;
  transition: border-color 0.2s;
}

.issue-card:hover {
  border-color: var(--stope-gray-600);
}

.issue-card h4 {
  color: var(--stope-white);
  font-size: 0.95rem;
  margin-bottom: var(--space-xs);
}

.issue-meta {
  font-size: 0.78rem;
  color: var(--stope-gray-500);
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.comment-card {
  background: var(--stope-dark);
  border: 1px solid var(--stope-gray-800);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
  margin-top: var(--space-sm);
}

.comment-card .comment-author {
  font-size: 0.78rem;
  color: var(--stope-gold);
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

.comment-card .comment-body {
  font-size: 0.85rem;
  color: var(--stope-gray-300);
}

/* Section header reused from main site */
.admin-header {
  margin-bottom: var(--space-2xl);
}

.admin-header h1 {
  font-size: 1.8rem;
  color: var(--stope-white);
  margin-bottom: var(--space-xs);
}

.admin-header p {
  color: var(--stope-gray-500);
  font-size: 0.9rem;
}

/* ── Legacy single-row chip nav (kept for back-compat with pages that
   still call the old shape — every page should migrate to the
   portal-shell below) ─────────────────────────────────────────────── */
.admin-nav {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-2xl);
  padding: 4px;
  background: var(--stope-charcoal);
  border: 1px solid var(--stope-gray-800);
  border-radius: var(--radius-md);
  flex-wrap: wrap;
}

.admin-nav a {
  display: block;
  padding: var(--space-sm) var(--space-md);
  color: var(--stope-gray-400);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  letter-spacing: 0.3px;
}

.admin-nav a:hover {
  color: var(--stope-white);
  background: var(--stope-gray-800);
}

.admin-nav a.active {
  color: var(--stope-gold);
  background: rgba(212,168,67,0.1);
}

.admin-nav .nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  font-size: 0.65rem;
  font-weight: 700;
  background: rgba(212,168,67,0.2);
  color: var(--stope-gold);
  margin-left: 6px;
}

/* ── Portal shell — fixed top bar + fixed sidebar + content ────────
   Same shape every page. Top bar = main sections (Overview / Project /
   Docs). Sidebar swaps items based on which section is active. Page
   body gets padding-top + padding-left so content doesn't underflow. */
body.portal-shell-active {
  padding-top: 52px;
  padding-left: 220px;
  background: var(--stope-black);
}

.portal-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0 16px;
  background: var(--stope-charcoal);
  border-bottom: 1px solid var(--stope-gray-800);
  z-index: 100;
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 0 0;
  color: var(--stope-white);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
  text-decoration: none;
  border-right: 1px solid var(--stope-gray-800);
  margin-right: 8px;
}
.portal-brand svg { width: 22px; height: 19px; color: var(--stope-gold); }

.portal-tabs {
  display: flex;
  align-items: stretch;
  gap: 0;
}

.portal-tab {
  display: flex;
  align-items: center;
  padding: 0 18px;
  color: var(--stope-gray-400);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px; /* overlap the topbar border */
  transition: color 0.15s, border-color 0.15s;
}
.portal-tab:hover { color: var(--stope-white); }
.portal-tab.active {
  color: var(--stope-gold);
  border-bottom-color: var(--stope-gold);
}

.portal-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.portal-actions a {
  color: var(--stope-gray-300);
  text-decoration: none;
  font-size: 0.82rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
}
.portal-actions a:hover { color: var(--stope-white); background: var(--stope-gray-800); }
.portal-actions a.external { color: var(--stope-gold); font-weight: 600; }

.portal-sidebar {
  position: fixed;
  top: 52px;
  left: 0;
  bottom: 0;
  width: 220px;
  background: var(--stope-black);
  border-right: 1px solid var(--stope-gray-800);
  padding: 16px 0;
  overflow-y: auto;
  z-index: 90;
}

.sidebar-section {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--stope-gray-500);
  padding: 16px 18px 6px;
  font-weight: 600;
}
.sidebar-section:first-child { padding-top: 4px; }

.sidebar-item {
  display: block;
  padding: 7px 16px 7px 18px;
  color: var(--stope-gray-300);
  font-size: 0.85rem;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background 0.12s, color 0.12s, border-left-color 0.12s;
}
.sidebar-item:hover {
  background: var(--stope-gray-900);
  color: var(--stope-white);
}
.sidebar-item.active {
  background: rgba(212,168,67,0.08);
  color: var(--stope-gold);
  border-left-color: var(--stope-gold);
  font-weight: 600;
}

/* Hamburger button — hidden by default, shown only on mobile. Lives
   in the topbar's left edge so the sidebar can be opened anywhere. */
.portal-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-right: 4px;
  background: transparent;
  border: 0;
  color: var(--stope-gray-300);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 18px;
  line-height: 1;
}
.portal-hamburger:hover { background: var(--stope-gray-800); color: var(--stope-white); }

/* Sidebar overlay (mobile only) — tap outside to close. */
.portal-sidebar-overlay {
  display: none;
  position: fixed;
  top: 52px; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 85;
}
body.portal-sidebar-open .portal-sidebar-overlay { display: block; }

@media (max-width: 768px) {
  body.portal-shell-active { padding-left: 0; }
  .portal-hamburger { display: inline-flex; }
  .portal-sidebar { transform: translateX(-100%); transition: transform 0.2s; box-shadow: 2px 0 8px rgba(0,0,0,0.4); }
  body.portal-sidebar-open .portal-sidebar { transform: translateX(0); }
  /* Hide top-bar tabs on very narrow screens — they live in the
     sidebar already via section labels. Keep brand + hamburger +
     Live App link visible. */
  .portal-tabs { display: none; }
}
@media (max-width: 480px) {
  /* Compact actions row: only Live App stays visible. */
  .portal-actions a:not(.external) { display: none; }
}

/* Responsive */
@media (max-width: 1024px) {
  .admin-container { padding: var(--space-xl) var(--space-md); }
}
@media (max-width: 768px) {
  .admin-container { padding: var(--space-lg) var(--space-md); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .toolbar { flex-direction: column; align-items: stretch; }
}
