/* ============================================================
   Brightforge Admin — internal tool design
   White surfaces, dark typography, blue accent.
   ============================================================ */
:root {
  --navy: #07111F;
  --mid: #0B1728;
  --blue: #2563EB;
  --blue-2: #3B82F6;
  --ink: #0F172A;
  --ink-soft: #52617A;
  --text: #334155;
  --line: #E2E8F0;
  --paper: #F6F8FB;
  --danger: #DC2626;
  --success: #059669;
  --warning: #D97706;
  --radius: 4px;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
}
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
h1, h2, h3, h4, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }

/* ---------- Layout ---------- */
.admin-shell { display: flex; min-height: 100vh; }

.admin-sidebar {
  width: 236px;
  flex: none;
  background: var(--navy);
  color: #94A3B8;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1.15rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-brand-word {
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.18em;
  color: #F8FAFC;
}
.sidebar-brand-sub { display: block; font-family: var(--font-mono); font-size: 0.52rem; letter-spacing: 0.16em; color: #64748B; }
.sidebar-nav { padding: 0.9rem 0.75rem; flex: 1; }
.sidebar-section { font-family: var(--font-mono); font-size: 0.58rem; letter-spacing: 0.16em; text-transform: uppercase; color: #475569; padding: 0.9rem 0.55rem 0.4rem; }
.sidebar-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  border-radius: 3px;
  color: #94A3B8;
  font-size: 0.86rem;
  margin-bottom: 1px;
  transition: background 0.15s, color 0.15s;
}
.sidebar-link:hover { background: rgba(255, 255, 255, 0.06); color: #E2E8F0; }
.sidebar-link.is-active { background: var(--blue); color: #fff; }
.sidebar-link .count {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  background: rgba(255, 255, 255, 0.1);
  padding: 0.1rem 0.45rem;
  border-radius: 8px;
}
.sidebar-link.is-active .count { background: rgba(255, 255, 255, 0.22); }
.sidebar-foot { padding: 1rem 1.25rem; border-top: 1px solid rgba(255, 255, 255, 0.08); font-size: 0.75rem; color: #64748B; }
.sidebar-foot .user { color: #CBD5E1; font-weight: 600; display: block; }
.sidebar-foot a { color: #64748B; display: block; margin-top: 0.25rem; }
.sidebar-foot a:hover { color: var(--blue-2); }

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 0.85rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 20;
}
.admin-topbar h1 { font-size: 1.05rem; font-weight: 600; color: var(--ink); }
.admin-topbar .sub { font-size: 0.78rem; color: var(--ink-soft); font-family: var(--font-mono); }
.admin-topbar .actions { display: flex; gap: 0.6rem; align-items: center; }

.admin-content { padding: 1.75rem; max-width: 1280px; width: 100%; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--blue); color: var(--blue); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-2); border-color: var(--blue-2); color: #fff; }
.btn-danger { background: #fff; border-color: #FECACA; color: var(--danger); }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.78rem; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Cards & stats ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.75rem; }
.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.stat-card .label { font-size: 0.75rem; color: var(--ink-soft); font-weight: 500; }
.stat-card .value { font-size: 1.7rem; font-weight: 700; color: var(--ink); letter-spacing: -0.02em; font-family: var(--font-mono); }
.stat-card .value a { color: inherit; }
.stat-card .value a:hover { color: var(--blue); }

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 1.75rem;
}
.card-head {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.card-head h2 { font-size: 0.95rem; font-weight: 600; color: var(--ink); }
.card-body { padding: 1.25rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 500;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--line);
  background: #FBFCFE;
  white-space: nowrap;
}
.table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #FAFBFD; }
.table .title-cell { font-weight: 600; color: var(--ink); }
.table .title-cell a:hover { color: var(--blue); }
.table .muted { color: var(--ink-soft); font-size: 0.8rem; }
.table .mono { font-family: var(--font-mono); font-size: 0.76rem; color: var(--ink-soft); }
.table .actions { display: flex; gap: 0.4rem; justify-content: flex-end; }
.table .actions .btn { padding: 0.28rem 0.6rem; font-size: 0.75rem; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 10px;
  background: #F1F5F9;
  color: var(--ink-soft);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-green { background: #ECFDF5; color: var(--success); }
.badge-blue { background: #EFF6FF; color: var(--blue); }
.badge-amber { background: #FFFBEB; color: var(--warning); }
.badge-red { background: #FEF2F2; color: var(--danger); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field label { font-size: 0.8rem; font-weight: 600; color: var(--ink); }
.field .hint { font-size: 0.74rem; color: var(--ink-soft); font-weight: 400; }
.input, .select, .textarea {
  font: inherit;
  font-size: 0.9rem;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  width: 100%;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.textarea { min-height: 130px; resize: vertical; font-family: inherit; line-height: 1.6; }
.checkbox-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.86rem; color: var(--ink); cursor: pointer; }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--blue); }
.form-actions { display: flex; gap: 0.7rem; margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.form-error, .form-success {
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  font-size: 0.86rem;
  margin-bottom: 1.25rem;
}
.form-error { background: #FEF2F2; border: 1px solid #FECACA; color: var(--danger); }
.form-success { background: #ECFDF5; border: 1px solid #A7F3D0; color: var(--success); }
.field-error { color: var(--danger); font-size: 0.76rem; }

/* ---------- Flash ---------- */
.flash { margin-bottom: 1.25rem; padding: 0.85rem 1.1rem; border-radius: var(--radius); font-size: 0.88rem; }
.flash-success { background: #ECFDF5; border: 1px solid #A7F3D0; color: var(--success); }
.flash-error { background: #FEF2F2; border: 1px solid #FECACA; color: var(--danger); }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 0.35rem; padding: 1rem 1.25rem; }
.pagination .page {
  min-width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 0.8rem; color: var(--ink-soft); background: #fff;
}
.pagination .page:hover { border-color: var(--blue); color: var(--blue); }
.pagination .page.current { background: var(--blue); border-color: var(--blue); color: #fff; }

/* ---------- Login ---------- */
.login-body { background: var(--navy); display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1.5rem; }
.login-card {
  width: 100%; max-width: 400px;
  background: #fff;
  border-radius: 6px;
  padding: 2.25rem;
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.6);
}
.login-card .brand { display: flex; align-items: center; gap: 0.65rem; margin-bottom: 1.75rem; }
.login-card .brand-word { font-weight: 700; letter-spacing: 0.2em; color: var(--ink); font-size: 0.95rem; }
.login-card .brand-sub { font-family: var(--font-mono); font-size: 0.56rem; letter-spacing: 0.16em; color: var(--ink-soft); display: block; }
.login-card h1 { font-size: 1.25rem; font-weight: 700; color: var(--ink); margin-bottom: 0.3rem; }
.login-card .sub { font-size: 0.85rem; color: var(--ink-soft); margin-bottom: 1.5rem; }
.login-card .field { margin-bottom: 1rem; }
.login-card .btn-block { margin-top: 0.75rem; }
.login-note { text-align: center; font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.1em; color: #475569; margin-top: 1.25rem; text-transform: uppercase; }

/* ---------- Media ---------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; }
.media-item { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.media-item img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--navy); display: block; }
.media-item .media-meta { padding: 0.6rem 0.7rem; }
.media-item .media-name { font-size: 0.72rem; color: var(--ink-soft); font-family: var(--font-mono); word-break: break-all; }
.media-item .media-actions { display: flex; justify-content: space-between; gap: 0.4rem; padding: 0 0.7rem 0.7rem; }
.media-item .media-actions .btn { padding: 0.2rem 0.5rem; font-size: 0.7rem; }

/* ---------- Preview thumb in forms ---------- */
.thumb-preview { margin-top: 0.6rem; max-width: 220px; border: 1px solid var(--line); border-radius: var(--radius); }
.thumb-preview img { border-radius: calc(var(--radius) - 1px); }

/* ---------- Permissions grid ---------- */
.perm-group { margin-bottom: 1.25rem; }
.perm-group h4 { font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 0.6rem; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0.5rem; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .admin-sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 40;
  }
  .admin-sidebar.is-open { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed; inset: 0;
    background: rgba(7, 17, 31, 0.5);
    z-index: 39;
    display: none;
  }
  .sidebar-backdrop.is-open { display: block; }
  .admin-topbar .menu-btn { display: inline-flex; }
  .form-grid { grid-template-columns: 1fr; }
}
.menu-btn { display: none; }
