/* Admin CMS: unified mobile-first layout (scoped to SPA admin root). Palette unchanged. */

.hf-spa-admin-root.hf-admin-layout {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.hf-admin-shell-nav {
  position: sticky;
  z-index: 20;
  top: calc(env(safe-area-inset-top, 0px) + var(--hf-topbar-height, 56px));
  margin: 0 -0.25rem;
  padding: 0.35rem 0.25rem 0.5rem;
  background: var(--wb-bg, #0a0a0a);
  border-bottom: 1px solid var(--wb-border, rgba(255, 255, 255, 0.12));
}

.hf-admin-primary-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.hf-admin-primary-tabs .tab {
  flex: 0 1 auto;
}

.hf-admin-stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.hf-admin-panel.panel {
  margin-bottom: 0;
}

.hf-admin-panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
}

.hf-admin-panel-head h2,
.hf-admin-panel-head h3 {
  margin: 0;
}

.hf-admin-panel-desc {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  color: var(--wb-muted, #9ca3af);
  width: 100%;
}

.hf-admin-panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.hf-admin-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.hf-admin-subnav-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0.35rem 0.75rem;
  border-radius: var(--wb-radius, 0.625rem);
  border: 1px solid var(--wb-border, rgba(255, 255, 255, 0.22));
  background: var(--wb-surface, #000);
  color: var(--wb-muted, #9ca3af);
  font-size: 0.875rem;
  text-decoration: none;
}

.hf-admin-subnav-link:hover {
  background: var(--wb-elevated, #111);
  color: var(--wb-text, #fff);
}

/* Active subnav: figma-theme .admin-cms .hf-admin-subnav-link.active (white pill) — do not override here */

.hf-admin-card-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.hf-admin-card {
  padding: 0.75rem;
  border: 1px solid var(--wb-border, rgba(255, 255, 255, 0.22));
  border-radius: var(--wb-radius, 0.625rem);
  background: var(--wb-surface, #000);
}

.hf-admin-form .form label,
.hf-admin-form label {
  display: block;
  margin-bottom: 0.65rem;
}

.hf-admin-form input[type="text"],
.hf-admin-form input[type="email"],
.hf-admin-form input[type="password"],
.hf-admin-form input[type="number"],
.hf-admin-form input[type="search"],
.hf-admin-form select,
.hf-admin-form textarea {
  min-height: 44px;
  width: 100%;
}

.hf-admin-empty {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--wb-muted, #9ca3af);
}

.hf-admin-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.75rem;
}

.hf-admin-form-actions--sticky {
  position: sticky;
  z-index: 15;
  bottom: 0;
  margin: 0.75rem -0.75rem -0.75rem;
  padding: 0.65rem 0.75rem calc(0.65rem + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, var(--wb-bg, #0a0a0a) 70%, transparent);
  border-top: 1px solid var(--wb-border, rgba(255, 255, 255, 0.12));
}

@media (max-width: 767px) {
  .hf-spa-admin-root .hf-admin-shell-nav .hf-mobile-section-picker-btn {
    margin-bottom: 0;
  }

  .hf-spa-admin-root .hf-admin-subnav {
    display: none;
  }

  .hf-spa-admin-root .hf-admin-form-actions--sticky {
    margin-left: 0;
    margin-right: 0;
  }

  .hf-spa-admin-root table.hf-admin-table thead,
  .hf-spa-admin-root table.hf-table-cards thead,
  .hf-spa-admin-root table.audit-table thead,
  .hf-spa-admin-root table.security-table thead,
  .hf-spa-admin-root table.data-table thead {
    display: none;
  }

  .hf-spa-admin-root table.hf-admin-table,
  .hf-spa-admin-root table.hf-admin-table tbody,
  .hf-spa-admin-root table.hf-admin-table tr,
  .hf-spa-admin-root table.hf-admin-table td,
  .hf-spa-admin-root table.hf-table-cards,
  .hf-spa-admin-root table.hf-table-cards tbody,
  .hf-spa-admin-root table.hf-table-cards tr,
  .hf-spa-admin-root table.hf-table-cards td,
  .hf-spa-admin-root table.audit-table,
  .hf-spa-admin-root table.audit-table tbody,
  .hf-spa-admin-root table.audit-table tr,
  .hf-spa-admin-root table.audit-table td,
  .hf-spa-admin-root table.security-table,
  .hf-spa-admin-root table.security-table tbody,
  .hf-spa-admin-root table.security-table tr,
  .hf-spa-admin-root table.security-table td,
  .hf-spa-admin-root table.data-table,
  .hf-spa-admin-root table.data-table tbody,
  .hf-spa-admin-root table.data-table tr,
  .hf-spa-admin-root table.data-table td {
    display: block;
    width: 100%;
  }

  .hf-spa-admin-root table.hf-admin-table tr,
  .hf-spa-admin-root table.hf-table-cards tr,
  .hf-spa-admin-root table.audit-table tr,
  .hf-spa-admin-root table.security-table tr,
  .hf-spa-admin-root table.data-table tr {
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--wb-border, rgba(255, 255, 255, 0.22));
    border-radius: var(--wb-radius, 0.625rem);
    background: var(--wb-surface, #000);
  }

  .hf-spa-admin-root table.hf-admin-table td,
  .hf-spa-admin-root table.hf-table-cards td,
  .hf-spa-admin-root table.audit-table td,
  .hf-spa-admin-root table.security-table td,
  .hf-spa-admin-root table.data-table td {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.35rem 0;
    border: 0;
  }

  .hf-spa-admin-root table.hf-admin-table td::before,
  .hf-spa-admin-root table.hf-table-cards td::before,
  .hf-spa-admin-root table.audit-table td::before,
  .hf-spa-admin-root table.security-table td::before,
  .hf-spa-admin-root table.data-table td::before {
    content: attr(data-label);
    color: var(--wb-muted, #9ca3af);
    font-size: 0.8125rem;
    flex: 0 0 40%;
  }

  .hf-spa-admin-root .automsg-card {
    border: 1px solid var(--wb-border, rgba(255, 255, 255, 0.22));
    border-radius: var(--wb-radius, 0.625rem);
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    background: var(--wb-surface, #000);
  }

  .hf-spa-admin-root dialog.hf-admin-dialog {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
  }

  /* Admin AI tab — single scroll in thread, static composer */
  .hf-spa-admin-root:has(.admin-ai-tab) .hf-admin-main {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
  }

  .hf-spa-admin-root:has(.admin-ai-tab) .hf-admin-stack {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
  }

  .admin-ai-tab {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1 1 auto;
    overflow: hidden;
  }

  .admin-ai-layout {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
  }

  .admin-ai-chat-panel {
    display: flex;
    flex-direction: column;
    min-height: min(70dvh, calc(100dvh - var(--hf-topbar-height, 56px) - 10rem));
    flex-shrink: 0;
  }

  .admin-ai-chat-shell {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    gap: 0.5rem;
  }

  .admin-ai-chat-thread {
    flex: 1 1 auto;
    min-height: 12rem;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.5rem 0;
    border: 1px solid var(--wb-border, rgba(255, 255, 255, 0.22));
    border-radius: var(--wb-radius, 0.625rem);
    background: rgba(0, 0, 0, 0.22);
  }

  .admin-ai-chat-composer {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .admin-ai-chat-input {
    width: 100%;
    box-sizing: border-box;
    min-height: 44px;
  }

  .admin-ai-chat-send {
    min-height: 44px;
  }

  /* Override inline grid on AdminAiTab until shell markup uses admin-ai-chat-shell */
  .admin-ai-tab .admin-ai-layout {
    display: flex !important;
    flex-direction: column;
    grid-template-columns: unset !important;
  }

  .admin-ai-tab .admin-ai-chat {
    min-height: 12rem !important;
    max-height: min(42dvh, 420px) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    margin-bottom: 0.75rem !important;
  }

  .admin-ai-chat-msg {
    margin-bottom: 0.75rem;
  }

  .admin-ai-chat-msg-body {
    white-space: pre-wrap;
  }

  .admin-ai-escalation-list {
    list-style: none;
    padding: 0;
    margin: 0;
  }

  .admin-ai-escalation-item {
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--wb-border, rgba(255, 255, 255, 0.12));
  }

  .admin-ai-escalation-meta {
    font-size: 12px;
  }

  .admin-ai-escalation-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.35rem;
  }

  .admin-ai-proposal {
    margin-top: 0.5rem;
    padding: 0.5rem;
    border: 1px solid var(--wb-border, rgba(255, 255, 255, 0.22));
    border-radius: var(--wb-radius, 0.625rem);
  }

  .admin-ai-proposal-diff {
    font-size: 13px;
    margin: 0.35rem 0;
    padding-left: 1.1rem;
  }

  .admin-ai-proposal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
}

@media (min-width: 768px) {
  .hf-spa-admin-root .hf-admin-shell-nav .hf-mobile-section-picker-btn {
    display: none !important;
  }

  .hf-spa-admin-root .hf-admin-form-actions--sticky {
    position: static;
    background: none;
    border-top: 0;
    padding: 0.75rem 0 0;
    margin: 0.75rem 0 0;
  }
}
