/* ── Approval Groups page ──────────────────────────────────────────────────── */

approval-groups-page {
  display: none; /* toggled by JS */
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  border-right: 1px solid var(--toolbar-border, #e5e9f0);
}

/* ── Dark mode overrides for action colors (shared with rules page) ─────────── */

@media (prefers-color-scheme: dark) {
  .apr-card {
    --apr-action-bg: rgba(234,179,8,0.18);
    --apr-action-color: #fbbf24;
  }
  .apr-card[data-action="allow"] {
    --apr-action-bg: rgba(34,197,94,0.18);
    --apr-action-color: #4ade80;
  }
  .apr-card[data-action="deny"] {
    --apr-action-bg: rgba(239,68,68,0.18);
    --apr-action-color: #f87171;
  }
}

/* ── Page shell ── */

.apr-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  max-width: 100%;
}

.apr-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  min-height: 54px;
  border-bottom: 1px solid var(--bs-border-color);
  background: var(--bs-tertiary-bg);
  flex-shrink: 0;
  gap: 12px;
}

.apr-title {
  margin: 0;
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.apr-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.apr-header-count {
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--bs-secondary-color);
}

/* ── Card list ── */

.apr-card-list {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Single card ── */

.apr-card {
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.apr-card:hover {
  border-color: color-mix(in srgb, var(--apr-action-color, #a16207) 40%, var(--bs-border-color));
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

/* ── Row 1: action badge + pattern + priority + actions ── */

.apr-card-row1 {
  display: flex;
  align-items: center;
  gap: 10px;
}

.apr-action-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.25em 0.65em;
  border-radius: 5px;
  flex-shrink: 0;
  background: var(--apr-action-bg, rgba(234,179,8,0.12));
  color: var(--apr-action-color, #a16207);
}

.apr-action-badge i {
  font-size: 0.7rem;
}

.apr-pattern {
  font-family: var(--bs-font-monospace, monospace);
  font-size: 0.82rem;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: var(--bs-tertiary-bg, rgba(0,0,0,0.02));
  padding: 0.1em 0.45em;
  border-radius: 4px;
}

.apr-priority-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--bs-secondary-color, #6b7280);
  flex-shrink: 0;
  white-space: nowrap;
  padding: 0.2em 0.5em;
  background: var(--bs-tertiary-bg, #f0f2f5);
  border-radius: 5px;
}

.apr-priority-badge i {
  font-size: 0.65rem;
}

.apr-card-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  margin-left: auto;
}

.apr-btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--bs-secondary-color, #9ca3af);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.1s;
}

.apr-btn-icon:hover {
  background: var(--bs-tertiary-bg, #f0f2f5);
  color: var(--bs-body-color, #374151);
}

.apr-btn-edit:hover {
  color: var(--bs-primary, #0d6efd);
  background: var(--bs-primary-bg-subtle, #eef2ff);
}

.apr-btn-delete:hover {
  color: var(--bs-danger, #dc3545);
  background: var(--bs-danger-bg-subtle, #fef0f0);
}

/* ── Row 2 / Row 3 ── */

.apr-card-row2 {
  padding-left: 0;
}

.apr-card-row3 {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Tags ── */

.apr-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.74rem;
  font-weight: 500;
  padding: 0.2em 0.6em;
  border-radius: 5px;
  background: var(--bs-tertiary-bg, #f0f2f5);
  color: var(--bs-secondary-color, #6b7280);
  white-space: nowrap;
}

.apr-tag i {
  font-size: 0.7rem;
}

.apr-tag code {
  font-size: inherit;
  background: transparent;
  padding: 0;
  color: inherit;
}

.apr-tag-note {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Empty state ── */

.apr-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  color: var(--bs-secondary-color, #9ca3af);
  gap: 8px;
  flex: 1;
}

.apr-empty i {
  font-size: 2rem;
  opacity: 0.4;
}

.apr-empty p {
  margin: 0;
  font-size: 0.9rem;
}

/* ── Form ── */

.apr-form {
  margin: 16px 20px 0;
  border: 1px solid var(--bs-border-color);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bs-body-bg);
  flex-shrink: 0;
}

.apr-form-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 0.9rem;
  background: var(--bs-tertiary-bg);
  border-bottom: 1px solid var(--bs-border-color);
}

.apr-form-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--bs-secondary-color);
  border-radius: 6px;
  margin-left: auto;
  cursor: pointer;
  font-size: 1.1rem;
}

.apr-form-close:hover {
  background: var(--bs-secondary-bg, rgba(128,128,128,0.1));
  color: var(--bs-body-color);
}

.apr-form-body {
  padding: 1.25rem;
}

.apr-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 1rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--bs-border-color);
}

/* ── Tool picker (used inside Override/LowPrio form) ── */

.apr-tool-picker {
  border: 1px solid var(--bs-border-color, #dee2e6);
  border-radius: 6px;
  padding: 0.5rem;
  background: var(--bs-tertiary-bg, rgba(0,0,0,0.02));
}

.apr-tool-list {
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.apr-tool-group-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bs-secondary-color, #6c757d);
  padding: 0.4rem 0.4rem 0.1rem;
  margin-top: 0.25rem;
}

.apr-tool-item {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  width: 100%;
  padding: 0.3rem 0.4rem;
  border: none;
  border-radius: 4px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: var(--bs-body-color);
  transition: background 0.12s;
}

.apr-tool-item:hover {
  background: var(--bs-secondary-bg, rgba(128,128,128,0.1));
}

.apr-tool-item.selected {
  background: var(--bs-primary-bg-subtle, #cfe2ff);
  color: var(--bs-primary, #0d6efd);
}

.apr-tool-name {
  font-size: 0.78rem;
  flex-shrink: 0;
}

.apr-tool-desc {
  font-size: 0.75rem;
  color: var(--bs-secondary-color, #6c757d);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Group card ── */

.apr-group-card {
  cursor: pointer;
}

.apr-group-card:hover {
  border-color: var(--bs-primary, #0d6efd);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.apr-group-name {
  font-weight: 600;
  font-size: 0.92rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.apr-group-default-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2em 0.55em;
  border-radius: 4px;
  flex-shrink: 0;
  background: var(--bs-secondary-bg, rgba(100,116,139,0.15));
  color: var(--bs-secondary-color, #64748b);
}

/* ── Mobile ── */

@media (max-width: 600px) {
  .apr-header {
    padding: 10px 14px;
    min-height: 50px;
  }

  .apr-card-list {
    padding: 10px 12px;
    gap: 8px;
  }

  .apr-card {
    padding: 12px;
    gap: 6px;
  }

  .apr-card-row1 {
    gap: 7px;
  }

  .apr-action-badge {
    font-size: 0.66rem;
    padding: 0.2em 0.5em;
  }

  .apr-card-actions {
    gap: 0;
  }

  .apr-btn-icon {
    width: 28px;
    height: 28px;
    font-size: 0.8rem;
  }

  .apr-tag {
    font-size: 0.7rem;
  }

  .apr-tag-note {
    max-width: 180px;
  }

  .apr-form {
    margin: 10px 12px 0;
  }

  .apr-form-body {
    padding: 1rem;
  }
}
