/* =============================================
   The Bloodvault — Admin Panel Styles
   ============================================= */

body.admin-body {
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-admin);
  font-size: 0.9rem;
  line-height: 1.5;
  min-height: 100vh;
}

/* ─── Top Bar ─── */
.admin-topbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--bg-border);
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.admin-brand {
  font-family: var(--font-fraktur);
  font-size: 1.25rem;
  color: var(--accent-glow);
  text-decoration: none;
  letter-spacing: 0.03em;
}
.admin-brand:hover { color: var(--accent-hover); }

.admin-topnav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.admin-user {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* ─── Layout ─── */
.admin-layout {
  display: flex;
  min-height: calc(100vh - 52px);
}

.admin-sidebar {
  width: 200px;
  min-width: 200px;
  background: var(--bg-surface);
  border-right: 1px solid var(--bg-border);
  padding: 1rem 0;
}

.admin-nav {
  list-style: none;
}

.admin-nav-link {
  display: block;
  padding: 0.55rem 1.25rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  font-size: 0.88rem;
}

.admin-nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-raised);
  border-left-color: var(--accent);
}

.nav-divider {
  height: 1px;
  background: var(--bg-border);
  margin: 0.5rem 0;
}

.admin-main {
  flex: 1;
  padding: 2rem 2.5rem;
  overflow-y: auto;
}

/* ─── Page Header ─── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
}

.page-subtitle {
  color: var(--text-secondary);
  margin-top: 0.25rem;
  font-size: 0.9rem;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid var(--bg-border);
  background: var(--bg-raised);
  color: var(--text-primary);
  font-family: var(--font-admin);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn:hover {
  background: var(--bg-border);
  border-color: var(--text-muted);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent-light);
  color: #f0e0d6;
}
.btn-primary:hover {
  background: var(--accent-light);
  border-color: var(--accent-glow);
}

.btn-danger {
  background: var(--red);
  border-color: var(--red-light);
  color: #f0d0d0;
}
.btn-danger:hover {
  background: var(--red-light);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--bg-raised);
  color: var(--text-primary);
  border-color: var(--bg-border);
}

.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
}

.btn-full { width: 100%; justify-content: center; }

/* ─── Forms ─── */
.admin-form {
  max-width: 860px;
}

.form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
}

.form-group-grow { flex: 1; min-width: 200px; }

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="file"],
.form-group select,
.form-group textarea {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-admin);
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent-light);
  box-shadow: 0 0 0 2px rgba(139,26,26,0.25);
}

.md-editor {
  font-family: var(--font-mono) !important;
  font-size: 0.85rem !important;
  line-height: 1.6;
  resize: vertical;
  min-height: 300px;
  width: 100%;
}

.radio-group {
  display: flex;
  gap: 1.5rem;
}
.radio-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  color: var(--text-primary);
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
  font-weight: normal;
}

.field-hint {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 0.2rem;
}

.required { color: var(--accent-hover); }

.form-actions {
  display: flex;
  gap: 0.75rem;
  padding-top: 0.5rem;
}

/* ─── Tables ─── */
.table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.admin-table th {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--bg-border);
  padding: 0.6rem 0.75rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

.admin-table td {
  border-bottom: 1px solid var(--bg-border);
  padding: 0.65rem 0.75rem;
  vertical-align: middle;
}

.admin-table tr:hover td { background: var(--bg-surface); }

.col-check { width: 2rem; text-align: center; }

.admin-table td.actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

td.empty {
  color: var(--text-muted);
  text-align: center;
  font-style: italic;
  padding: 2rem;
}

.inline-form { display: inline; }

/* ─── Badges ─── */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.badge-green {
  background: var(--green);
  color: var(--green-light);
}

.badge-gray {
  background: var(--gray);
  color: var(--gray-light);
}

/* Clickable publish toggle badge */
.badge-toggle {
  cursor: pointer;
  border: none;
  font-family: var(--font-admin);
  transition: opacity 0.15s, transform 0.1s;
}
.badge-toggle:hover {
  opacity: 0.75;
  transform: scale(1.05);
}

/* ─── Alerts ─── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.88rem;
}

.alert-success {
  background: rgba(45,106,45,0.2);
  border: 1px solid var(--green);
  color: var(--green-light);
}

.alert-error {
  background: rgba(110,21,21,0.2);
  border: 1px solid var(--red-light);
  color: #e88080;
}

/* ─── Dashboard Stats ─── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  text-align: center;
}

.stat-number {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent-glow);
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}

.quick-actions h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.8rem;
}

.action-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ─── Panel Layout ─── */
.panel-row {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.panel {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  min-width: 260px;
}

.panel-grow { flex: 1; }

.panel h2 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 1rem;
}

.hint {
  font-size: 0.75rem;
  font-weight: normal;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: normal;
}

/* ─── Sortable Menu List ─── */
.sortable-list {
  list-style: none;
}

.menu-tree { list-style: none; }
.menu-tree .menu-children {
  list-style: none;
  padding-left: 1.5rem;
  border-left: 2px solid var(--bg-border);
  margin-left: 1rem;
}
.menu-children.menu-collapsed { display: none; }

.menu-item {
  cursor: default;
  transition: background 0.1s;
  border-radius: var(--radius);
  margin-bottom: 2px;
}
.menu-item-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--bg-border);
  background: var(--bg-surface);
  border-radius: var(--radius);
}
.menu-item-row:hover { background: var(--bg-raised); }

.move-btns {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex-shrink: 0;
}
.move-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.6rem;
  line-height: 1;
  padding: 1px 3px;
  border-radius: 2px;
}
.move-btn:hover { color: var(--text-primary); background: var(--bg-raised); }

.menu-collapse-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 0.2rem;
  font-size: 0.75rem;
  flex-shrink: 0;
  line-height: 1;
}
.menu-collapse-btn:hover { color: var(--text-primary); }


.item-label { font-weight: 500; flex: 1; min-width: 0; display:flex; flex-direction:column; gap:0.1rem; }
.item-dest  { color: var(--text-muted); font-size: 0.72rem; font-family: var(--font-mono); font-weight:400; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.item-meta  { color: var(--text-muted); font-size: 0.78rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }

.empty {
  color: var(--text-muted);
  font-style: italic;
  padding: 1rem;
  text-align: center;
}

.menu-child {
  background: var(--bg-deep) !important;
  border-left: 3px solid var(--accent) !important;
}

.child-indent {
  color: var(--accent);
  font-size: 0.9rem;
  flex-shrink: 0;
}

/* ─── Login ─── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-deep);
  padding: 2rem;
}

.login-box {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
}

.login-title {
  font-family: var(--font-fraktur);
  font-size: 2rem;
  color: var(--accent-glow);
  text-align: center;
  margin-bottom: 0.25rem;
}

.login-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 1.5rem;
}

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

/* ─── Overlay Modal (full-screen blocking, e.g. password change) ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay .modal-box {
  max-width: 460px;
  max-height: 90vh;
}

/* ─── Modal / Side Panel ─── */
.modal {
  position: fixed;
  top: 52px; /* below topbar */
  right: 0;
  bottom: 0;
  width: 340px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-left: 1px solid var(--bg-border);
  box-shadow: -4px 0 24px rgba(0,0,0,0.4);
  overflow-y: auto;
}

.modal-box {
  padding: 1.5rem;
  flex: 1;
}

.modal-box h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ─── Responsive ─── */
@media (max-width: 640px) {
  .admin-sidebar { display: none; }
  .admin-main { padding: 1.25rem; }
  .panel-row { flex-direction: column; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ─── Image Grid ─── */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

.image-card {
  background: var(--bg-deep);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.image-card a {
  display: block;
  aspect-ratio: 1;
  overflow: hidden;
  background: #111;
}

.image-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.15s;
}
.image-card img:hover { opacity: 0.85; }

.image-card-name {
  padding: 0.4rem 0.5rem 0.2rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  word-break: break-all;
  flex: 1;
}

.image-card-actions {
  display: flex;
  gap: 0.3rem;
  padding: 0.4rem 0.5rem;
  flex-wrap: wrap;
}

/* ─── Layout Page ─── */
.layout-tree,
.layout-children {
  list-style: none;
  margin: 0;
  padding: 0;
}

.layout-children {
  padding-left: 1.5rem;
  border-left: 2px solid var(--bg-border);
  margin-left: 1.25rem;
  margin-top: 2px;
}

.layout-item {
  margin-bottom: 2px;
}

.layout-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.5rem;
  border-radius: var(--radius);
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
}
.layout-row:hover { background: var(--bg-raised); }

.layout-section > .layout-row {
  border-left: 3px solid var(--accent);
}

.layout-icon { font-size: 0.85rem; flex-shrink: 0; }

.layout-label {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  font-weight: 500;
  overflow: hidden;
}

.section-label {
  color: var(--accent-glow);
}

.layout-slug {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-family: var(--font-mono);
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layout-sub {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 400;
}

/* Published/draft dot toggle */
.pub-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: transform 0.1s, opacity 0.15s;
}
.pub-dot:hover { transform: scale(1.3); opacity: 0.85; }

.pub-on {
  background: var(--green-light);
  border-color: var(--green);
  box-shadow: 0 0 4px var(--green);
}

.pub-off {
  background: var(--bg-border);
  border-color: var(--text-muted);
}

/* Unlinked pages section */
.unlinked-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--bg-border);
  border-radius: var(--radius);
}
.unlinked-row:last-child { border-bottom: none; }
.unlinked-row:hover { background: var(--bg-raised); }

.unlinked-title {
  flex: 1;
  min-width: 0;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unlinked-add {
  display: flex !important;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.add-select {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-admin);
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
  max-width: 160px;
}
.add-select:focus {
  outline: none;
  border-color: var(--accent-light);
}

.layout-empty {
  color: var(--text-muted);
  font-style: italic;
  padding: 1rem 0.5rem;
  margin: 0;
}
