/* View Forms — layout aligned with reference (tabs, filter card, table) */

.admin-forms-view {
  --afv-accent: var(--theme-red-bright, #c42d2d);
  --afv-surface: #f4f5f7;
  --afv-card: var(--surface-card, #fff);
  --afv-border: var(--theme-gray-200, #e5e7eb);
  --afv-text: var(--theme-gray-900, #111827);
  --afv-muted: var(--theme-gray-500, #6b7280);
  --afv-blue: #2563eb;
  --afv-blue-soft: #eff6ff;
  --afv-green: #16a34a;
  --afv-green-soft: #dcfce7;
  --afv-peach: #ffedd5;
  width: 100%;
  max-width: none;
  margin: 0;
  /* Horizontal inset comes from `.dashboard-main` in App.css — avoid double padding */
  padding-left: 0;
  padding-right: 0;
  padding-bottom: 40px;
  box-sizing: border-box;
}

.admin-forms-view__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.admin-forms-view__title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.admin-forms-view__accent {
  width: 4px;
  align-self: stretch;
  min-height: 40px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--afv-accent) 0%, var(--theme-maroon-deep, #5c0000) 100%);
  flex-shrink: 0;
}

.admin-forms-view__title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--afv-text);
  line-height: 1.2;
}

.admin-forms-view__back {
  flex-shrink: 0;
  border: 1px solid var(--afv-border);
  border-radius: 10px;
  padding: 10px 16px;
  background: var(--afv-card);
  color: var(--afv-text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}

.admin-forms-view__back:hover {
  background: var(--theme-gray-50, #f9fafb);
}

/* Primary tabs: Opened | Archive */
.admin-forms-view__tabs {
  display: inline-flex;
  border-radius: 10px;
  padding: 4px;
  background: var(--afv-surface);
  border: 1px solid var(--afv-border);
  gap: 4px;
  margin-bottom: 20px;
}

.admin-forms-view__tab {
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: transparent;
  color: var(--afv-muted);
  transition: background 0.15s, color 0.15s;
}

.admin-forms-view__tab:hover {
  color: var(--afv-text);
}

.admin-forms-view__tab--active {
  background: linear-gradient(180deg, var(--theme-maroon-bright, #9a1818) 0%, var(--theme-maroon-deep, #5c0000) 100%);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* Toolbar row: title + toggle + badge */
.admin-forms-view__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  margin-bottom: 16px;
}

.admin-forms-view__toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.admin-forms-view__section-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--afv-text);
}

.admin-forms-view__count-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--afv-peach);
  color: #9a3412;
  border: 1px solid rgba(234, 88, 12, 0.25);
}

.admin-forms-view__seg {
  display: inline-flex;
  border-radius: 10px;
  padding: 3px;
  background: var(--afv-surface);
  border: 1px solid var(--afv-border);
  gap: 2px;
}

.admin-forms-view__seg-btn {
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: transparent;
  color: var(--afv-muted);
  white-space: nowrap;
}

.admin-forms-view__seg-btn--active {
  background: linear-gradient(180deg, var(--theme-maroon-bright, #9a1818) 0%, var(--theme-maroon-deep, #5c0000) 100%);
  color: #fff;
}

/* Filter card */
.admin-forms-view__filter-card {
  background: var(--afv-surface);
  border: 1px solid var(--afv-border);
  border-radius: 14px;
  padding: 18px 20px 20px;
  margin-bottom: 20px;
}

.admin-forms-view__filter-title {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 700;
  color: var(--afv-text);
}

.admin-forms-view__filter-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 720px) {
  .admin-forms-view__filter-grid {
    grid-template-columns: 1.4fr 1fr;
    align-items: end;
  }
}

.admin-forms-view__field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--afv-muted);
  margin-bottom: 6px;
}

.admin-forms-view__field input,
.admin-forms-view__field select {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--afv-border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--afv-text);
}

.admin-forms-view__field input::placeholder {
  color: var(--theme-gray-400, #9ca3af);
}

.admin-forms-view__field input:focus-visible,
.admin-forms-view__field select:focus-visible {
  outline: 2px solid var(--theme-maroon-border, rgba(128, 0, 0, 0.35));
  outline-offset: 1px;
}

/* Table shell */
.admin-forms-view__table-shell {
  background: var(--afv-card);
  border: 1px solid var(--afv-border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--surface-card-shadow, 0 1px 3px rgba(0, 0, 0, 0.06));
}

.admin-forms-view__table-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  background: var(--theme-gray-50, #f9fafb);
  border-bottom: 1px solid var(--afv-border);
  font-size: 13px;
  color: var(--afv-muted);
}

.admin-forms-view__table-controls label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.admin-forms-view__table-controls select {
  border: 1px solid var(--afv-border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
}

.admin-forms-view__table-wrap {
  overflow-x: auto;
}

.admin-forms-view__table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 860px;
}

.admin-forms-view__table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--afv-muted);
  background: var(--theme-gray-100, #f3f4f6);
  padding: 12px 16px;
  border-bottom: 1px solid var(--afv-border);
  white-space: nowrap;
}

.admin-forms-view__table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--theme-gray-100, #f3f4f6);
  font-size: 14px;
  vertical-align: middle;
}

.admin-forms-view__table tbody tr:last-child td {
  border-bottom: none;
}

.admin-forms-view__table tbody tr:hover td {
  background: rgba(0, 0, 0, 0.02);
}

.admin-forms-view__name-cell {
  min-width: 200px;
}

.admin-forms-view__name-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-weight: 700;
  color: var(--afv-text);
}

.admin-forms-view__name-sub {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 400;
  color: var(--afv-muted);
  line-height: 1.35;
}

.admin-forms-view__badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.admin-forms-view__badge--opened {
  background: var(--afv-green-soft);
  color: var(--afv-green);
  border: 1px solid rgba(22, 163, 74, 0.35);
}

.admin-forms-view__badge--archived {
  background: var(--theme-gray-100, #f3f4f6);
  color: var(--afv-muted);
  border: 1px solid var(--afv-border);
}

.admin-forms-view__badge--superseded {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid rgba(180, 83, 9, 0.25);
}

.admin-forms-view__pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  background: var(--theme-gray-100, #f3f4f6);
  color: var(--afv-muted);
}

.admin-forms-view__actions {
  white-space: nowrap;
}

.admin-forms-view__btn-view {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(37, 99, 235, 0.35);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: #fff;
  color: var(--afv-blue);
}

.admin-forms-view__btn-view:hover:not(:disabled) {
  background: var(--afv-blue-soft);
}

.admin-forms-view__btn-view:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.admin-forms-view__btn-delete {
  margin-left: 8px;
  border: none;
  background: none;
  color: var(--theme-red-bright, #c42d2d);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  font-family: inherit;
}

.admin-forms-view__btn-delete:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.admin-forms-view-icon {
  flex-shrink: 0;
}

.admin-forms-view__group {
  margin-bottom: 24px;
}

.admin-forms-view__group:last-child {
  margin-bottom: 0;
}

.admin-forms-view__empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--afv-muted);
  font-size: 14px;
}

.admin-forms-view .admin-form-builder-msg {
  margin: 0 0 12px;
}
